How to create a simple loop?

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

I would like to create a simple loop however I'm not very good in programing... My script is like this but instead of '...' I would like to create a loop which would work till I press return or escape. Is there any simple method?

*createbutton(5, 'Triad', 18, 0, 4, BUTTON, 'Create Triad', 'macroTriad')

*beginmacro(macroTriad) <cr>

*createlistpanel(nodes,1,'Select nodes') <cr>

*createelement(103,1,1,1) <cr>

...

*createlistpanel(nodes,1,'Select nodes') <cr>

*createelement(103,1,1,1) <cr>

*endmacro() <cr>

Kind regards,

Lukasz

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2008

    Hi,

    I don't understand what you want exactly, a simple loop looks like this ...

    ------------------------------------------------------------------------------

    *createmarkpanel elements 1 'Select elements ...'

    set element_mark [hm_getmark elements 1]

    foreach eid $element_mark {

    tk_messageBox -message 'Element : $eid'

    }

    ------------------------------------------------------------------------------

    or

    ------------------------------------------------------------------------------

    set stop 0

    while {$stop == 0} {

    # your code here

    set stop 1

    }

    ------------------------------------------------------------------------------

    Regards,

    Mario

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2019

    hello...

     

    i would like to make a script to delete assemblies and sub assemblies in one action... that's need a loop script..please help me 

  • tinh
    tinh Altair Community Member
    edited February 2019

    Hi

    Use while loop:

    Condition is 'remain emptied assem' use *EntityPreviewEmpty and hm_marklength to check that condition

     

    Body is 'delete them' , use *deletemark

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2019

    can you give the full script for me. because i dont know how to make it

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    Hi MEIYARASU19

    Refer the example script from  below link 

    https://connect.altair.com/CP/script-list.html

  • tinh
    tinh Altair Community Member
    edited March 2019

    If you don't know how to make script I recommend you to learn tcl programming first, not to make tons of questions.

    Tcl is easy.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    If you don't know how to make script I recommend you to learn tcl programming first, not to make tons of questions.

    Tcl is easy.

    Thank you

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    Hi MEIYARASU19

    Refer the example script from  below link 

    https://connect.altair.com/CP/script-list.html

    Thank you