Working with iDs

Merula_20758
Merula_20758 Altair Community Member
edited October 2020 in Community Q&A

Dear all,

 

I am working right now on a topology optimization based on a tcl script. It is important to me to identify certain nodes in order for my load cases.

Lets say I have in my script something like

 *createnode 0 0 0 0 0 0 *createnode 0 1 0 0 0 0

 

and then a section where I want to apply a load to it. I did it like this:

 *createmark nodes 1  1(that 1 is the node id) *loadcreateonentity_curve nodes 1 1 1 0 0 150 0 0 150 0 0 0 0 0

 

The problem I have is, that the block with the createnode part can vary so the Ids are not always the same. I did not find a way to include a specific ID in the *createmark line in order to work with it later.... it does more or less: id: 1,2,3,4 as you progress creating your nodes.

I thought on selecting my nodes differently, maybe with *createmark nodes 1 'on plane' but I did not have sucess there either. How would you solve this problem? I must work with specific nodes I create but te nodes can vary so either I have to renumber it in a way I know which id it has, maybe based on coordinates or assign specific node Ids.

 

Thanks in advance for discussing this topic with me,

 

Best regards,

Merula

 

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2016

    Hello,

     

    maybe it helps if you save the node IDs, like this:

     

     *createnode 100 100 100 0 0 0 *createmark nodes 1 -1 set NID1 [hm_getmark nodes 1]

    now the node Id of the last created node (-1) is saved at NID1...

     

    Best Regards,

    Mario

     

  • Merula_20758
    Merula_20758 Altair Community Member
    edited February 2016

    Thanks Mario, that works great. I am having one issue though regarding this method

     

    if I want to combine several node Ids into one variable, something like

     

     set myIds $NID1 $NID2 ...

    and later I want to reuse my collector with the *createmark command, this does not work

     works: *createmark nodes 1 $NID1 $NID2  does not work *createmark nodes 1 $myIds

    Thanks in advance for your help and keep up the good work :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20'>

     

    Merula

  • tinh
    tinh Altair Community Member
    edited February 2016

    Hi

    please refer to

     

     

  • Merula_20758
    Merula_20758 Altair Community Member
    edited February 2016

    Thanks for the help. The answer was to use lists....like:

     set myIds '$NID1 NID2'

    what seems strange to me at the moment is, that in the thread you mentioned, it is highly suggested to use hm_createmark instead of *createmark. Would you agree? I try substituting it in my script but at the following statement it is impossible to get hm_createmark working like it should:

     eval *createmark nodes 1 {'by box'} [expr $x-$delta] [expr $y-$delta] [expr $z-$delta] [expr $x+$delta] [expr $y+$delta] [expr $z+$delta] 0 inside 0 0 0   what I tried is   hm_createmark nodes 1 [expr $x-$delta] [expr $y-$delta] [expr $z-$delta] [expr $x+$delta] [expr $y+$delta] [expr $z+$delta] 0 inside 0 0 0   Syntax error:  wrong # args: should be 'hm_createmark entity_type mark arg3 ?arg4?'

    Any thoughts ?

    Thanks in advance,

    Merula

  • tinh
    tinh Altair Community Member
    edited February 2016

    due to your 'by box' disappeared

    <img class=" data-emoticon="true" src="src" />/emoticons/default_laugh.png' title=':lol:'>

     

     

    actually hm_createmark will invoke the command 'eval *createmark...'

    so if you already know how 'eval' works, hm_createmark is unneccessary anymore

  • Merula_20758
    Merula_20758 Altair Community Member
    edited March 2016

    omg! Seemed I was overdue to go home that day. Did not see that!

     

    :D/emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20'>