How to extract the geo. properties by scripting?
As the subject, how could we extract the geo. properties by script in Mechanical.
We need get the mass, the inertial moment, the gravity center of an assembly by script.
We can insert a *GET command in the Solution to obtain the above information, as shown in the command below. However, the user wishes to retrieve this information by reading the geometry before solving. Is this achievable?
Answers
-
Any comments would be appreciated.
0 -
@Huadong It is going to be a long script. But steps would include:
#Getting all mesh GlobalMeshData = ExtAPI.DataModel.MeshDataByName("Global") # Mesh for a part meshData = GlobalMeshData.MeshRegionById(part_id) nodeIds= meshData.NodeIds for nodeId in nodeIds: if nodeId in meshDataNodeIds: # Calculate nodal mass based on contribution from connnected elements node = GlobalMeshData.NodeById(nodeId) if node != None: elementIds = node.ConnectedElementIds
The above is just a pseudo code. Please reachout to me directly for details if needed.
0 -
I do not believe that these quantities are calculated at an assembly level until solve time. Your best bet is probably to use the Selection Information panel to do the calculation. When you select multiple bodies, you will see the assembly data in the first row:
You can then export this table to file to read it in your script. See:
https://discuss.ansys.com/discussion/4547/how-to-modify-the-selection-information-column-control-settings
https://discuss.ansys.com/discussion/4534/open-the-selection-information-panel-in-mechanical
https://discuss.ansys.com/discussion/3394/how-do-i-fetch-selection-information-data-in-mechanicalAlternatively, if you want to do the calculations yourself, you might find these posts helpful:
https://discuss.ansys.com/discussion/423/extract-mass-per-body-through-scripting
https://discuss.ansys.com/discussion/2698/centre-of-gravity-mechanical-script
https://discuss.ansys.com/discussion/3175/how-to-capture-the-model-mass-information0