CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Feb 19, 2019 3:47 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Apr 21, 2015 11:42 am 
Offline

Joined: Tue Apr 21, 2015 6:02 am
Posts: 5
Hi there,

I am new to Python programming and have a small issue, maybe:

How can I create a new folder in the device-tree or the POU-tree?

For example:
I want to create a new folder at: "Application/POUs" that should be named with "test".
So that I have a new folder at: "Application/POUs/test" where I can import any POUs.

Is that possible?
If yes might an example very helpfull.

Regards
Michael


Top
   
PostPosted: Tue Apr 21, 2015 12:54 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 233
Hi mvs.

A script object can create a folder under itself by calling the method create_folder(<Folder name>). See example.

Code:
proj = projects.primary

objs = proj.find('Folder', recursive = True)
folder = objs[0]

folder.create_folder('SubFolder')

objs = folder.find('SubFolder')
if not objs[0].is_folder:
   raise Exception('Object is not a folder')

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Tue Apr 21, 2015 1:27 pm 
Offline

Joined: Tue Apr 21, 2015 6:02 am
Posts: 5
Hi Martin,

I tested it and it works great.

Many thanks

Michael


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited