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

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 454
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

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 454
    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:

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

    Access a toolbar using interfaces:

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