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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
KP_Henrob hat geschrieben:
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:
proj=projects.primaryforobjinproj.get_children(True):
  ifobj.build_propertiesandobj.build_properties.exclude_from_build_is_valid:
    name=obj.get_name()
    print("Object '{}' supports exclude from build".format(name))
    ifname=="MyFB":
      obj.build_properties.exclude_from_build=True
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Originally created by: KP_Henrob
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
Hi KP_Henrob.
Here is some example code:
BR
Martin