🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Set distance between two nodes

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

Hi all.

I need help on tcl hypermesh scripting. What command do you use to set a distance between 2 nodes. Manually i would press F4, select two nodes as if i'm measuring the distance and then just type in new distance value to my preferred distance. When i look into the command file, the command is *nodemodify, but the problem of this command is that it use the coordinate of the nodes rather than a specified distance value.

Thank u very much in advance.

Find more posts tagged with

Sort by:
1 - 3 of 31
    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    You can use the command

    hm_getdistance entity_type id1 id2 syst_id

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hello,

    here is a simple example how to implement such a function.

    I have included the inputs, so you can check it.

    *createmarkpanel nodes 1 'Select first node';

    set node_list1 [hm_getmark nodes 1];

    if { ! [ Null node_list1 ] } {

    set nodeId1 [ lindex $node_list1 0 ]

    set x1 [ hm_getentityvalue nodes $nodeId1 'x' 0 ]

    set y1 [ hm_getentityvalue nodes $nodeId1 'y' 0 ]

    set z1 [ hm_getentityvalue nodes $nodeId1 'z' 0 ]

    }

    *createmarkpanel nodes 2 'Select the second node';

    set node_list2 [hm_getmark nodes 2];

    if { ! [ Null node_list2 ] } {

    set nodeId2 [ lindex $node_list2 0 ]

    set x2 [ hm_getentityvalue nodes $nodeId2 'x' 0 ]

    set y2 [ hm_getentityvalue nodes $nodeId2 'y' 0 ]

    set z2 [ hm_getentityvalue nodes $nodeId2 'z' 0 ]

    }

    *clearmark nodes 1;

    *clearmark nodes 2;

    set dx [expr $x2 - $x1]

    set dy [expr $y2 - $y1]

    set dz [expr $z2 - $z1]

    tk_messageBox -message 'Distance dx dy dz: $dx $dy $dz'

    set offsetx [hm_getfloat 'Offset X = 'Please specify the X - offset]

    set offsety [hm_getfloat 'Offset Y = 'Please specify the Y - offset]

    set offsetz [hm_getfloat 'Offset Z = 'Please specify the Z - offset]

    set nx [expr $x2 + $offsetx]

    set ny [expr $y2 + $offsety]

    set nz [expr $z2 + $offsetz]

    *nodemodify $nodeId2 $nx $ny $nz

    Regards,

    Mario

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi all

    I think SFUL wants to set the distance from node1 to node2

    I wrote this example, please test it

    ex: hm_setdistance 1 2 500.0 ==> when you F4 measuring distance from node id 1 to node id 2, it shows 500.0

    proc hm_setdistance {node1 node2 newdistance} {

    #get current distance

    foreach id {1 2} {

    set nodevalue [expr [hm_nodevalue [set node$id]]]

    set i -1

    foreach coord {x y z} {

    set $coord$id [lindex $nodevalue [incr i]]

    }

    }

    set currentdistance [expr sqrt(\

    ($x1-$x2)*($x1-$x2)+\

    ($y1-$y2)*($y1-$y2)+\

    ($z1-$z2)*($z1-$z2))]

    set deltadistance [expr $newdistance-$currentdistance]

    set temp [hm_getmark nodes 1]

    *createmark nodes 1 $node2

    *createvector 1 [expr $x2-$x1] [expr $y2-$y1] [expr $z2-$z1]

    *translatemark nodes 1 1 $deltadistance

    eval *createmark nodes 1 $temp

    }