[r2]: / trunk / scripts / action.plcopenxml.export.py  Maximize  Restore  History

Download this file

30 lines (23 with data), 974 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)