Example of dummy post object
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
Answers
-
Below is an example of a post object that when evaluated will change the value in the details view from 0 to 15.
The xml file is:
<extension version="1" name="PostObject"> <guid shortid="PostObject">8fc89783-8ea1-4669-a2cf-7f381f2434e9</guid> <script src="post_object.py" /> <interface context="Mechanical"> <images>images</images> <!-- Create a toolbar and add a button to insert a ACT load --> <toolbar name="PostObject" caption="PostObject"> <entry name="PostObject" icon="group"> <callbacks> <!-- This will add the ACT object to the tree --> <onclick>createPostObject</onclick> </callbacks> </entry> </toolbar> </interface> <simdata context="Mechanical"> <!-- define the child --> <object name="Object" version="1" caption="Result" icon="child" isload="true" color="#0000FF"> <!-- Specify the allowed target of this object --> <target type="analysis" location="post"/> <callbacks> <!-- The "action" will add a context menu option on the object. --> <action name="Evaluate" caption="Evaluate Result" icon="update">evaluateResult</action> </callbacks> <property name="MyResult" caption= "My Result" control="float" readonly="true" default="0.0"> </property> </object> </simdata> </extension>
The post_object.py file is:
def createPostObject(analysis): """ The method is called when the toolbar button is clicked.
Keyword arguments: analysis -- the active analysis """ # Add a "Object" object [defined in XML] in solution tree of the analyis. analysis.CreatePostObject("Object",ExtAPI.ExtensionManager.CurrentExtension) def evaluateResult(obj): """The method is called when the "Evaluate" action button is clicked orfrom the generateChildren method. Keyword arguments: obj -- the object to avaluate """ # Set the State property to Evaluated. obj.Properties["MyResult"].Value = 15.0 ExtAPI.DataModel.Tree.Refresh()
7