HYPERMESH - Selecting nodes via Tag Names

Andy@LamteqSolutions
Andy@LamteqSolutions Altair Community Member
edited October 2020 in Community Q&A

Here's a bit of a challenge and certainly one which has bamboozled me so far...

 

Our models need to follow a particular numbering system, we already have a code which quickly renumbers literally everything in the model to a specific number range. But an add on we would like is to be able to rapidly renumber specific node numbers. In the models, we tag nodes with a label like 'N-9001' meaning that node number must be 9001 (long story but we work on include files which must slot together so certain nodes must be certain numbers). At the moment this is a manual process but what I would like is a code which could createmark by tag name N9001, then renumber node to 9001.

 

Can this be done? If so, how? 

Answers

  • tinh
    tinh Altair Community Member
    edited September 2018

    maybe: *createmark nodes 1 'by tag name' N-9001

    ???

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited September 2018

    Hi Andy,

     

    Something like this should help:

     

    *createmark tags 1 all
    set lst_tagIDs [hm_getmark tags 1]
    foreach tagID $lst_tagIDs {
        set tagval [hm_getvalue tags id=$tagID dataname=name]
        set tagdata [split $tagval :]
        set tagName [lindex $tagdata 0] 
        //Write procedure to Modify tagname to integer if it has any string in it (Remove N-)
        set tagNode [lindex $tagdata 1]
        *clearmark nodes 1
        *createmark nodes 1 $tagNode
        *renumbersolverid nodes 1 $tagName 1 0 0 0 0 0
    }

  • Andy@LamteqSolutions
    Andy@LamteqSolutions Altair Community Member
    edited September 2018

    Tinh and Livil,

     

    Many thanks for your help.

     

    Livil, the code is struggling (or rather I am struggling) with extracting the Node number the tag is currently applied to... this is what I get. 

     

    (Documents) 102 % set tagval [hm_getvalue tags id=9000003  dataname=name]
    N-9004:
    (Documents) 103 % set tagdata [split $tagval :]
    N-9004 {}
    (Documents) 104 %  set tagNode [lindex $tagdata 1]
    list element in braces followed by '' instead of space

     

    Now I have tried 

        *createmark  tags 1  'by tag name' N-9004:

     hm_getmark tags 1 (displays the right tag number)

       *createmark nodes 1 'by tag id' {*}[hm_getmark tags 1]

     

    But this seems to go off and find different nodes - and more of them, I was expecting 1 node but it seems to find 49!

  • Andy@LamteqSolutions
    Andy@LamteqSolutions Altair Community Member
    edited September 2018

    Success... 

     

    set tagval [hm_getvalue tags id=9000003  dataname=name]
    set tagNode [hm_getvalue tags id=9000003  dataname=entity]
        set S1 [string trim $tagval ':']
        set tagName [string trim $S1 'N-*']
        *createmark nodes 1 $tagNode
        *renumbersolverid nodes 1 $tagName 1 0 0 0 0 0

     

    obviously replace id=9000003 with the foreach command

     

    Thanks ever so much for your help

  • Andy@LamteqSolutions
    Andy@LamteqSolutions Altair Community Member
    edited September 2018

    Hmmm new problem.... here's my code

     

    *createmark tags 1 all
    set lst_tagIDs [hm_getmark tags 1]
    foreach  tagID $lst_tagIDs {
        set tagval [hm_getvalue tags id=$tagID  dataname=name]
        set tagNode [hm_getvalue tags id=$tagID  dataname=entity]
        set S1 [string trim $tagval ':']
        set tagName [string trim $S1 'N-*']
        *createmark nodes 1 $tagNode
        *renumbersolverid nodes 1 $tagName 1 0 0 0 0 0
    }

     

    Here's the error....

    extra characters after close-brace
    extra characters after close-brace
        while executing
    'foreach  tagID $lst_tagIDs {
        set tagval [hm_getvalue tags id=$tagID  dataname=name]
        set tagNode [hm_getvalue tags id=$tagID  dataname=entity]
    ...'
     

     

     

  • Andy@LamteqSolutions
    Andy@LamteqSolutions Altair Community Member
    edited September 2018

    Ok weird... deleted last } then put it back in... now works like a dream!