How can I retrieve the ACT extension XML/XML objects for a binary extension (.wbex)?

Member, Moderator, Employee Posts: 479
100 Answers 250 Likes 100 Comments Second Anniversary
✭✭✭✭
edited June 2023 in Structures

I have a binary extension and would like to automate creation of some objects of that extension. For automation I need to know what are the object names, types and location to be able to access them via Mechanical scripting API. The whole structure of an extension is defined in the XML, is there a way to retrieve that for a binary (.wbex) ACT extension?

Tagged:

Answers

  • Member, Moderator, Employee Posts: 479
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    Answer ✓

    When an ACT extension object is retrieved in Mechanical Scripting Console, it gives you access to the extension's DataModel. With this you can access all elements of the extension, for example: interfaces, toolbars, SimDatas, the whole XML file as well:

    Get extension XML and write out to a file:

    1. my_extension = ExtAPI.ExtensionManager.GetExtensionByName("HarmonicResponsePlotter")
    2. my_extension_xml = my_extension.DataModel.Xml
    3. my_extension_xml_file = open(r"\Output\Path\to\xml", "w")
    4. my_extension_xml_file.write(my_extension_xml)
    5. my_extension_xml_file.close()

    Access a toolbar using interfaces:

    1. my_extension = ExtAPI.ExtensionManager.GetExtensionByName("HarmonicResponsePlotter")
    2. print(my_extension.DataModel.Interfaces[2].Toolbars[0].Entries)

Welcome!

It looks like you're new here. Sign in or register to get started.