Diff of /trunk/scripts/action.plcopenxml.export.py [000000] .. [r2]  Maximize  Restore

Switch to unified view

a b/trunk/scripts/action.plcopenxml.export.py
1
# Example Batch:
2
# set WD=%~d0%~p0
3
# "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
4
5
import sys
6
import os.path
7
8
file=sys.argv[1]
9
10
class ER(ExportReporter):
11
    def error(self, object, message):   
12
        system.write_message(Severity.Error, "Error exporting %s: %s" % (object, message))
13
    def warning(self, object, message):   
14
        system.write_message(Severity.Warning, "Warning exporting %s: %s" % (object, message))
15
    def nonexportable(self, object):   
16
        system.write_message(Severity.Information, "Object not exportable: %s" % object)
17
    @property
18
    def aborting(self):
19
        return False;
20
21
if os.path.isfile(file):
22
    reporter = ER()
23
    proj = projects.open(file)
24
    app = proj.active_application
25
    app.export_xml(reporter, file + ".plcopen.xml", recursive = True)
26
else:
27
    print("error: file not found '%s'" % file)
28
29