Jump to content
Andy@LamteqSolutions

HYPERMESH - Selecting nodes via Tag Names

Recommended Posts

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? 

Share this post


Link to post
Share on other sites

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
}

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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]
..."
 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...