ACT: drop-down list of analyses as a property of Custom Load Object
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
-
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
1 -
Have a look at the Mechanical Template 7 by clicking on the ACT Templates tab here:
https://catalog.ansys.com/Developers.cshtmlHere 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"
1