Dear all:
Question about scripting: I am creating a .NET program that is supposed to Open codesys, open template project, export a bunch of pou, then exit codesys.
Launch works, Open project works, Export works, But how do i tell codesys to close itself? I can tell windows to terminate codesys, but i would prefer to do it properly.
from__future__importprint_functionimportsysimportSystemproj=projects.primary# We're interested in POU nodes:POUGuid=Guid("6f9dac99-8de1-4efc-8465-68ac443b7d08")# We collect all POU nodes in that list.pous=[]# From the parent node on, we recursively add POU nodes:defCollectPous(node):ifnode.type==POUGuid:pous.append(node)else:forchildinnode.get_children():CollectPous(child)# Now we collect all the leaf nodes.fornodeinproj.get_children():CollectPous(node)# We print everything just to know what's going on.foriinpous:print("found: ",i.type,i.guid,i.get_name())# And now we export the files.forcandidateinpous:# We create a list of objects to export:# The object itsselfobjects=[candidate]# And sub-objects (POUs can have actions, properties, ...)objects.extend(candidate.get_children())# And the parent folders.parent=candidate.parentwhile((notparent.is_root)andparent.is_folder):objects.append(parent)parent=parent.parent# Create an unique file name:iflen(sys.argv)==1:filename="parent\\%s.export"%(candidate.get_name())else:filename="%s\\%s.export"%(sys.argv[1],candidate.get_name())# print some user informationprint("exporting ",len(objects)," objects to: ",filename)# and actually export the project.proj.export_xml(objects,filename)proj.close()print("script finished.")System.exit(0)//Dontwork
sorry I canΒ΄t help you with your issue, but I hope you can give me a hint on getting GUID for other objects than POUs.
Your code states "Guid("6f9dac99-8de1-4efc-8465-68ac443b7d08")". We can I find the GUID / ObjectIds`?
I wasnΒ΄t able to get details about the GUID of DataTypes (STRUCT/ENUM,..)m, Functions (FUN), GLOBALS and TYPES.
I want to create markdown of all available project elements.
Thanks for your help
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am looking for the same thing, so i don't have an answer, but in your case you could possibly use the --noUI flag when running codesys, if you don't care about showing what's happening.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all:
Question about scripting: I am creating a .NET program that is supposed to Open codesys, open template project, export a bunch of pou, then exit codesys.
Launch works, Open project works, Export works, But how do i tell codesys to close itself? I can tell windows to terminate codesys, but i would prefer to do it properly.
.NET:
Hi,
sorry I canΒ΄t help you with your issue, but I hope you can give me a hint on getting GUID for other objects than POUs.
Your code states "Guid("6f9dac99-8de1-4efc-8465-68ac443b7d08")". We can I find the GUID / ObjectIds`?
I wasnΒ΄t able to get details about the GUID of DataTypes (STRUCT/ENUM,..)m, Functions (FUN), GLOBALS and TYPES.
I want to create markdown of all available project elements.
Thanks for your help
Hello
I am looking for the same thing, so i don't have an answer, but in your case you could possibly use the --noUI flag when running codesys, if you don't care about showing what's happening.