Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Export XML

2012-03-14
2012-03-20
  • Lohr-DCIA-EHE1

    Lohr-DCIA-EHE1 - 2012-03-14

    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
    ...

     
  • Anonymous - 2012-03-19

    Originally created by: M.Schaber

    Hi,

    Lohr_DCIA-EHE1 hat geschrieben:
    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.

    Zitat:
    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?

     
  • Lohr-DCIA-EHE1

    Lohr-DCIA-EHE1 - 2012-03-20

    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.

     
  • Anonymous - 2012-03-20

    Originally created by: M.Schaber

    Lohr_DCIA-EHE1 hat geschrieben:
    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).

     

Log in to post a comment.