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 Thu Sep 19, 2019 8:51 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Aug 16, 2019 7:14 pm 
Offline

Joined: Wed Jul 31, 2019 1:56 pm
Posts: 4
Hello all,
My goal is to have the same project be able to automatically decide which objects to include in a build based on what device its going to run on, or at least have an easy way to switch between possibilities. My first thought was to make a Python script that includes/excludes a pre-set list of objects in a build. I've been trying to use the .exclude_from_build property, however every object I've tried it on results in an error about it not having this attribute. After some research online, I saw someone used .build_properties before using .exclude_from_build, however tying this yields the same exact error.
Is there something I'm doing wrong/not doing? Is this the right way to go about my goal in the first place? Any ideas are greatly appreciated.

Codesys V3.5 SP12 Patch 1


Top
   
PostPosted: Tue Aug 20, 2019 8:44 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 254
Hi KP_Henrob.

KP_Henrob wrote:
Hello all,
My goal is to have the same project be able to automatically decide which objects to include in a build based on what device its going to run on, or at least have an easy way to switch between possibilities. My first thought was to make a Python script that includes/excludes a pre-set list of objects in a build. I've been trying to use the .exclude_from_build property, however every object I've tried it on results in an error about it not having this attribute. After some research online, I saw someone used .build_properties before using .exclude_from_build, however tying this yields the same exact error.
Is there something I'm doing wrong/not doing? Is this the right way to go about my goal in the first place? Any ideas are greatly appreciated.

Codesys V3.5 SP12 Patch 1

Here is some example code:
Code:
proj = projects.primary

for obj in proj.get_children(True):
    if obj.build_properties and obj.build_properties.exclude_from_build_is_valid:
        name = obj.get_name()
        print("Object '{}' supports exclude from build".format(name))

        if name == "MyFB":
            obj.build_properties.exclude_from_build = True

BR
Martin

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

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 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