How to create probe labels at a node using ACT?
nodeID = 1984 analysis=ExtAPI.DataModel.AnalysisByName('Static Structural') resultObject=ExtAPI.DataModel.GetObjectsByName('Equivalent Stress')[0] probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject) probeLabel.Scoping.Node = nodeID
The above script creates a probe for Equivalent Stress result object in Mechanical at node 1984. This API is new in v2022R1
Building on Rohiths answer, here are some some methods to change the color or add a note: resultObject = Tree.ActiveObjects[0]
with Transaction(): labelsForRes = Graphics.LabelManager.GetObjectLabels(resultObject) Graphics.LabelManager.DeleteLabels(labelsForRes) probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject) probeLabel.Scoping.Node = 1 probeLabel.Note = "NOT OK" probeLabel.Color = Ansys.ACT.Common.Graphics.Color(red=240, green=0, blue=0, alpha=50)
you can use the point cloud search from DPF to search for the nearest node
point cloud search
point data is [42.,0.,-23.] in mm
import mech_dpf import Ans.DataProcessing as dpf analysis = DataModel.AnalysisList[0] # mesh from result file DataSource = dpf.DataSources(analysis.ResultFileName) # Get Mesh and displacement from specific time scoping op = dpf.operators.mesh.mesh_provider() # operator instanciation op.inputs.data_sources.Connect(DataSource) # you can also provide the mesh_scoping in following line my_mesh = op.outputs.mesh.GetData() # point is [42.,0.,-23.], should be floats point_field=dpf.FieldsFactory.CreateVectorField(1,3,"Nodal") point_field.Add(1,[42.,0.,-23.]) point_field.Unit = "mm" op = dpf.operators.mesh.point_cloud_search() # operator instantiation op.inputs.search_domain.Connect(point_field) op.inputs.reference_domain.Connect(my_mesh) op.inputs.exclusive_search.Connect(True) op.inputs.tolerance.Connect(15) my_search_indices = op.outputs.search_indices.GetData() x=op.outputs.reference_indices.GetData() print("Node Id is : {0}".format(x.Ids[0]))
you can just extend the idea of the VectorField so that it can accommodate all your probe points, and then you can search for all nodes that are in the vicinity of those points.
VectorField
once you have the node collection getting a Stress value is not much efforts
Is it possible to create these probe labels based on xyz coordinates instead of node number? There seems to be probeLabel.Scoping.XYZ option but I don't know how to create the point.
labels_manager = Graphics.LabelManager result = Tree.FirstActiveObject with Transaction(): _old = labels_manager.GetObjectLabels(result) Graphics.LabelManager.DeleteLabels(_old) probe_label = labels_manager.CreateProbeLabel(result) point = Ansys.Mechanical.Graphics.Point([0,0,0],'mm') probe_label.Scoping.XYZ = point probe_label.Note = "NOT OK" probe_label.Color = Ansys.ACT.Common.Graphics.Color(red=240, green=0, blue=0, alpha=25)
@LauriK you can use the Graphics Point API
point = Ansys.Mechanical.Graphics.Point([0,0,0],'mm')
What I would like to achieve is, give coordinate inputs to Mechanical, then find a node close which has maximum stress value. Node would probably be really close <5mm to the coordinate given. Do I have to iterate through all nodes of the model to achieve this or is there maybe an easier way?
My problem is the following: I have a global model for which I have multiple probes put in place in critical locations. When I modify the global model I lose all the probes, even though I have modified only part of the global model. That is why I would like to import probes from previous iteration.
How do I create an annotation at xyz (without an value)?
... and how do I access the option Mechanical->Graphics->"Max Number of Annotations to Show" by python
@LauriK You can get the closest node to any arbitrary location by creating a CS at that location. Once you have this, make a worksheet based named selection with a single line of logic. Select the node with distance smallest from that local CS. The benefit of this is when you re-mesh, the NS will regenerate and re-select the closest node, so it will be stable no matter what changes you make. In scripting, you then can use the NS.Ids[0] to get the node id of the node in the named selection.
If for some reason you don't want to do this.... If you want to find the closest node to a point the most efficient way to do this would be to sort the nodes by X,Y,Z locations. You can then chop of large portions of the data knowing that it is sorted.
Lastly there is a DPF operator to find closest points (nodes) given a point cloud and list of points. For a single point, I think the Named Selection option is the easiest.
For PythonResults use CreateLabel:
CreateLabel
resultObject = Tree.FirstActiveObject point = Ansys.Mechanical.Graphics.Point([0,0,0],'mm') probeLabel = Graphics.LabelManager.CreateLabel(resultObject) probeLabel.Scoping.XYZ = point probeLabel.Note = "OK!"