ACT: drop-down list of analyses as a property of Custom Load Object

dafedin
dafedin Member Posts: 21
First Comment Name Dropper

Hello!

In my ACT extension, I need to get a Property for a Custom Load Object with the drop-down list of all Mechanical analyses in Project Tree and the appropriate function to process user action (selection) and get selected analysis inside my ACT main script as Analysis Object.
Is it possible? Does somebody have an example of code?

I would appreciate for help
Thanks

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 734
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    Hi @dafedin . Not sure I fully understand your question, but maybe this post helps: https://discuss.ansys.com/discussion/573/how-can-i-add-options-to-a-drop-down-menu

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary

    Have a look at the Mechanical Template 7 by clicking on the ACT Templates tab here:
    https://catalog.ansys.com/Developers.cshtml

    Here is another example where a drop-down lists all named selections containing 2 nodes. In this example we internally use the Tree object's ID, which is what you will likely want to do:

                <property name="Path" caption="Path" control="select" readonly = "false">
                  <callbacks>
                    <onactivate>FillDropDown</onactivate>
                    <value2string>v2sPath</value2string>
                    <getvalue>v2sPath</getvalue>
                  </callbacks>
                </property>
    
    def FillDropDown(result,property):
        named_selections = ExtAPI.DataModel.Components
        property.Options.Clear()
        for ns in named_selections:
            if ns.SelectionType.ToString() == 'MeshNodes':
                if ns.Ids.Length == 2:
                    table.Properties["Path"].Options.Add(str(ns.Id))
    
    def v2sPath(load, prop, val):
        try:
            #loop over NS list to match ID and then return Name
            named_selections = ExtAPI.DataModel.Components
            for ns in named_selections:
                if ns.Id == int(val):
                    if ns.SelectionType.ToString() == 'MeshNodes' and ns.Ids.Length == 2:
                        return ns.Name
                    else:
                        #return "NS_INVALID"
                        return ns.Name
        except:
            return "NS_DELETED"