--- a +++ b/trunk/scripts/action.plcopenxml.export.py @@ -0,0 +1,29 @@ +# Example Batch: +# set WD=%~d0%~p0 +# "C:\Program Files (x86)\3S CODESYS-V3.5.12.0\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP12" --runscript="%WD%\action.plcopenxml.export.py" --scriptargs="test.project" --noUI + +import sys +import os.path + +file=sys.argv[1] + +class ER(ExportReporter): + def error(self, object, message): + system.write_message(Severity.Error, "Error exporting %s: %s" % (object, message)) + def warning(self, object, message): + system.write_message(Severity.Warning, "Warning exporting %s: %s" % (object, message)) + def nonexportable(self, object): + system.write_message(Severity.Information, "Object not exportable: %s" % object) + @property + def aborting(self): + return False; + +if os.path.isfile(file): + reporter = ER() + proj = projects.open(file) + app = proj.active_application + app.export_xml(reporter, file + ".plcopen.xml", recursive = True) +else: + print("error: file not found '%s'" % file) + +