Distinguish object types in project tree

FloWil
2015-09-14
2019-04-11
  • FloWil - 2015-09-14

    Is it possible to determine the of objects in the project tree while iterating over them?
    I need to distinguish between POUs and Visualization objects for example.

        
    for child in folderobject.get_children():
            if child.is_folder:
                print ('Found folder: {}'.format(child.get_name()))
                export_folder(child)
            else:
                print(child.type)
    

    child.type() will only return these guid, but from my current understanding i have no way tell what kind of object that is?

    Thanks in advance
    Florian

     
  • mkeller - 2015-09-14

    Hi FloWil.

    What's the use case behind your question?

    Some objects, which are supported by the ScriptEngine, have a special property. For example, the device object has the property "is_device".

    BR
    Martin

     
  • FloWil - 2015-09-15

    Yes so i saw the functions for testing for folder and devices.
    The use case is exporting of the project, but on a per-file basis.
    I basically need to have one POU/Visualisation in one exported file.

    This is also why i am not using the recursive export on the project, because it will stop exporting when encountering a subfolder of project. I have this working already for everything code related by using PLCOpenXML-files.
    Visualisations do not export to PLCOpenXML though at all as it seems?
    So the idea is to export them seperately in native format.

     
  • mkeller - 2015-09-15

    Hi FloWil.

    FloWil hat geschrieben:
    I basically need to have one POU/Visualisation in one exported file.

    For POUs you could check the object for the property "has_textual_declaration" because all POU objects have an textual declaration.

    FloWil hat geschrieben:
    Visualisations do not export to PLCOpenXML though at all as it seems?

    I think it is not part of the PLCopenXML specification.

    BR
    Martin

     
  • dbarral - 2019-04-10

    Hi Martin,

    M.Keller hat geschrieben:
    For POUs you could check the object for the property "has_textual_declaration" because all POU objects have an textual declaration.
    BR
    Martin

    Is there a property than can be checked for Visualizations?

    Regards,
    Daniel

     
  • mkeller - 2019-04-11

    Hi qbarral.

    dbarral hat geschrieben:
    Is there a property than can be checked for Visualizations?

    Sorry, but no.

    We have Scripting API for Text List and Image Pool but not for the Visual objects.

    BR
    Martin

     

Log in to post a comment.