tcl programme for node move

Altair Forum User
Altair Forum User
Altair Employee
edited November 2020 in Community Q&A

hello 

 

I am working on tcl programme  which will move selected node 

 

in a vector defined by selecting nodes

 

I have written programme for that put node is not moving in direction I wanted

 

have look at programme 

 

and how clearmark command works??

Unable to find an attachment - read this blog

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    hello 

     

    so I continue working on my script

     

    So I think error lies in the  *createvector comand I am not able to provide proper x and y component for the vector creation

     

    So am I right??


     

    *createmarkpanel nodes 1 'select node'

    set node_list [hm_getmark nodes 1 ]  

    if {[llength $node_list] == 0} {
        hm_errormessage 'no'
        return
        }
    #*clearmark nodes 1


    *createlistpanel nodes 2 'Select direction by node1->node2'

    set vectnodelist [hm_getlist nodes 2]

    set nodeid1 [hm_getentityvalue nodes [lindex $vectnodelist 0] 'id' 0];

    set nodeid2 [hm_getentityvalue nodes [lindex $vectnodelist 1] 'id' 0];

    *createvector 1 $nodeid1 $nodeid2 0

    *translatemark nodes 1 1 5 

    *clearmark nodes 1

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    so finally I have found solution for this problem

     

    *createmarkpanel nodes 1 'select node'

    set node_list [hm_getmark nodes 1 ]  

    if {[llength $node_list] == 0} {
        hm_errormessage 'no'
        return
        }
    #*clearmark nodes 1


    *createlistpanel nodes 2 'Select direction by node1->node2'
    set vectnodelist [hm_getlist nodes 2]

    set nodeid1 [hm_getentityvalue nodes [lindex $vectnodelist 0] 'id' 0];

    set nodeid2 [hm_getentityvalue nodes [lindex $vectnodelist 1] 'id' 0];


    foreach {tot x y z} [hm_getdistance nodes $nodeid1 $nodeid2 0] { 
        *createvector 1 $x $y $z

    set elemsize [hm_getfloat 'elemsize' 'Enter elem size']


        *translatemark nodes 1 1 $elemsize
    }

    *clearmark nodes 1
     

     

     

    Thank you everyone on forum 

    I have made this based on previous post only 

     

    thank you

  • tinh
    tinh Altair Community Member
    edited July 2016

    It's fine

    hint for you to create a vector:

    lassign [lindex [hm_getplanepanel] 0 0] vx vy vz

    (from version HM13)

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    thank you tinh

     

    I will work on that

     

    I want to write a program  where while midsurfacing hm should capture the thickness of plate and auto assign it afterwards ???

  • tinh
    tinh Altair Community Member
    edited July 2016

    Hi,

    did you try using Midmesh thickness tool? 

    menu Mesh>assign>Midmesh Thickness

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    thanks for that I will try that option

     

    I want to cycle a particular tcl until I say to stop it

     

    so how can I do it

     

    like cycling particular command e.g. like program for translate and split it should continue to repeat same commands until I stop it

     

    ??

  • tinh
    tinh Altair Community Member
    edited July 2016

    Hi

    maybe:

    while 1 {

       *createmarkpanel nodes 1 'Select nodes to translate:'

       if {[hm_marklength nodes 1]==0} break

       #create vector and translate...

     

    }

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    while 1 {

     

    *createmarkpanel nodes 1 'select node'

     

    set node_list [hm_getmark nodes 1 ]

     

    if {[llength $node_list] == 0} {

    hm_errormessage 'no'

    return

    }

    #*clearmark nodes 1

     

     

    *createlistpanel nodes 2 'Select direction by node1->node2'

    set vectnodelist [hm_getlist nodes 2]

     

    set nodeid1 [hm_getentityvalue nodes [lindex $vectnodelist 0] 'id' 0];

     

    set nodeid2 [hm_getentityvalue nodes [lindex $vectnodelist 1] 'id' 0];

     

     

    foreach {tot x y z} [hm_getdistance nodes $nodeid1 $nodeid2 0] {

    *createvector 1 $x $y $z

     

    #set elemsize [hm_getfloat 'elemsize' 'Enter elem size']

     

     

    *translatemark nodes 1 1 0.196

     

    }

     

    *clearmark nodes 1

     

    hm_setpanelproc {hm_callpanel 'edit element';}

     

    return

     

    }

     

     

    so this is my program

     

    at the end there is a call panel so I think because of that its not working

     

    after I split when I press return it should return to  '*createmarkpanel nodes 1 'select node''

     

    so????

  • tinh
    tinh Altair Community Member
    edited July 2016

    no, the cause is command 'return' at the end

    remove it

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    I tried it without return command but

     

    when I press return command on the edit element panel it wont return to first command

     

    so??

  • tinh
    tinh Altair Community Member
    edited July 2016

    yes,

    maybe you cannot use hm_setpanelproc to call a panel. this function will return immediately, moreover it will clear panel created by *createmarkpanel

    so you don't see the panel repeated by 'while' loop

    Thinking another way

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    So is there any other way to call up that panel and continue the while loop??

     

    so how can I do this whole process other way with while loop??

     

    Or at least tell how to create a button on user tab I followed tut but I am not able to create it??

     

     

  • tinh
    tinh Altair Community Member
    edited July 2016

    I think it is not possible to call hm panels in a loop as you expect

    So try redefining your problem

     

    Your button had wrong constructor:

    *createbutton(5,'SURFACETRIM',00,5,GRAY,'Launch the succsesful.tcl script','EvalTcl','succsesful.tcl')

     

    should be

    *createbutton(5,'SURFACETRIM',0,0,5,GRAY,'Launch the succsesful.tcl script','EvalTcl','succsesful.tcl')

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    sorry for wrong file

     

    I already have corrected that mistake

    Your button had wrong constructor:

    *createbutton(5,'SURFACETRIM',00,5,GRAY,'Launch the succsesful.tcl script','EvalTcl','succsesful.tcl')

     

    still its not working?? I am win7 user and I have located this userpage.mac panel in DOCUENTS FOLDER

     

  • tinh
    tinh Altair Community Member
    edited July 2016

    check again initial directory

    menu View>command window

    type in :

    pwd

     

    ==> userpage.mac should be in that folder

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2016

    Thank you 

     

    That worked I was placing it in wrong directory

    now it works fine 

     

    Thank you very much