Move list of nodes

SchluppIng
SchluppIng Member Posts: 15
Name Dropper First Comment
**

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

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 128
    100 Comments 25 Likes Second Anniversary 5 Answers
    ✭✭✭✭
    edited December 2024

    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)
    
  • SchluppIng
    SchluppIng Member Posts: 15
    Name Dropper First Comment
    **

    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.

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 128
    100 Comments 25 Likes Second Anniversary 5 Answers
    ✭✭✭✭

    @SchluppIng Please raise a support request so that an enhancement can be created for mechanical.

  • SchluppIng
    SchluppIng Member Posts: 15
    Name Dropper First Comment
    **

    Thanks, I raised a support question.