Move list of nodes
Hi all,
is there a possibilty to move a list of nodes instead of move each node seperately?
'''
for node in mesh.Nodes:
newLocX = Quantity(newX * correctionScaling, "m")
newLocY = Quantity(node.Y * correctionScaling, "m")
newLocZ = Quantity(newZ * correctionScaling, "m")
nodeMove.MoveNode(node.Id, newLocX, newLocY, newLocZ)
'''
For Example
'''
id, newLocX, newLocY, newLocZ = zip(*nodeList)
nodeMove.MoveNode(id, newLocX, newLocY, newLocZ)
'''
Answers
-
No. Since mechanical itself does not have that capability, API won't allow that. But you can always write your own function/class to write a short and cleaner code. Here is an example ( not tested ):
class NODE_MOVE: def __init__(self, node_move): self.node_move = node_move def move_multiple_nodes(self, ids,X_movs, Y_movs, Z_movs): for index, node_id in enumerate(): self.node_move.MoveNode(node_id, Quantity(X_movs[index],'m'),Quantity(Y_movs[index],'m'),Quantity(Z_movs[index],'m') ) mesh_edit = model.AddMeshEdit() node_move = mesh_edit.AddNodeMove() my_node_move = NODE_MOVE(node_move=node_move) id, newLocX, newLocY, newLocZ = zip(*nodeList) my_node_move.move_multiple_nodes(id, newLocX, newLocY, newLocZ)
0 -
Hi Rajesh,
thanks for the quick response,
However, I see no advantage in creating a separate class in this case, as the MoveNode function already exists. Each node is still moved individually, which does not give me a performance boost, as the MoveNode method is very slow for individual node moves and can quickly take 1 hour.
But good to know, that there is no way to do it.0 -
@SchluppIng Please raise a support request so that an enhancement can be created for mechanical.
0 -
Thanks, I raised a support question.
1