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

dafedin
dafedin Member Posts: 21
10 Comments First Anniversary 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    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, GitHub-issue-creator Posts: 319
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    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"