CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

Export XML
https://forum.codesys.com/viewtopic.php?f=18&t=4820
Page 1 of 1

Author:  Lohr_DCIA-EHE1 [ Wed Mar 14, 2012 4:18 pm ]
Post subject:  Export XML

I want to export the properties of the function block (FB) named "MX_DirectVarAxis".
The function block has properties and methods.


The following script does not work:

import sys

str_PathXmlFile = "C:\\TestScripts\\TestExp.xml"

# create the export reporter
class Reporter(ExportReporter):
def error(self, message):
system.write_message(Severity.Error, message)

def warning(self, message):
system.write_message(Severity.Warning, message)

def nonexportable(self):
print("non exportable")

@property
def aborting(self):
return False

# create the exporter instance.
reporter = Reporter()

proj = projects.primary

obj = proj.find("MX_DirectVarAxis", True)[0]

print obj.get_name()

obj.export_xml(reporter, str_PathXmlFile, True)


The script showed the following messages:

...
reporter = Reporter()
proj = projects.primary
obj = proj.find("MX_DirectVarAxis", True)[0]
print obj.get_name()
MX_DirectVarAxis
obj.export_xml(reporter, str_PathXmlFile, True)
calling(self: IronPython.NewTypes.System.Object#IExportReporter_1$1)
def aborting(self:)
return False
...

Author:  M.Schaber [ Mon Mar 19, 2012 11:18 am ]
Post subject:  Re: Export XML

Hi,

Lohr_DCIA-EHE1 wrote:
I want to export the properties of the function block (FB) named "MX_DirectVarAxis".
The function block has properties and methods.

The following script does not work:


As far as I can see, the script looks fine.

Quote:
The script showed the following messages:
...
reporter = Reporter()
proj = projects.primary
obj = proj.find("MX_DirectVarAxis", True)[0]
print obj.get_name()
MX_DirectVarAxis
obj.export_xml(reporter, str_PathXmlFile, True)
calling(self: IronPython.NewTypes.System.Object#IExportReporter_1$1)
def aborting(self:)
return False
...


That looks like a trace of a successfull run of the script.

Did you get any error messages or exceptions? Was the TestExp.xml file created?

Author:  Lohr_DCIA-EHE1 [ Tue Mar 20, 2012 10:15 am ]
Post subject:  Re: Export XML

The export-file has been created.

But the the properties and methods of the function block are missing. If I try to find a property and to export it as XML-File an error message of the reporter shows, that the property is not exportable.

Author:  M.Schaber [ Tue Mar 20, 2012 11:04 am ]
Post subject:  Re: Export XML

Lohr_DCIA-EHE1 wrote:
The export-file has been created.

But the the properties and methods of the function block are missing. If I try to find a property and to export it as XML-File an error message of the reporter shows, that the property is not exportable.


Properties alone are not exportable, as properties cannot exist without their parents. If you export manually (via the project menu "Export PLCOpenXML..." command), you cannot select a property without the parent node being selected.

However, POUs should be exported with all their properties etc. if the "recursive" parameter is set to True. In our internal test cases, it works(the PLCOpenXML files contain the properties).

If it is not working for you, it's best if you contact me via our support department, giving detailed steps to repeat (possibly including an example project archive).

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/