Jump to content
Sign in to follow this  

TCL - Checking IDs

Recommended Posts



I have created this TCL script, which should check, if a certain ID for a specified entity-type is free and if not provide the next free one.

proc check_ID {entity_type target_ID} {
*createmark $entity_type 1 $target_ID
set mark_list [hm_getmark $entity_type 1]
*clearmark $entity_type 1
if {[llength $mark_list] > 0} {return 0}
return 1

proc next_free_ID {entity_type target_ID} {
hm_usermessage "Finding next free ID for $entity_type $target_ID"
while {![check_ID $entity_type $target_ID]} {incr target_ID}
return $target_ID

proc silentmode_start {} {
*entityhighlighting 0
hm_commandfilestate 0
hm_blockmessages 1
hm_blockerrormessages 1
hm_blockredraw 1
hwbrowsermanager view flush false
hm_setmouse 0

proc silentmode_stop {} {
*entityhighlighting 1
hm_commandfilestate 1
hm_blockmessages 0
hm_blockerrormessages 0
hm_blockredraw 0
hwbrowsermanager view flush true
hm_setmouse 1

puts [next_free_ID "elems" 5000]

The problem is, this script is very slow. Already on a small model with about 10000 elements it takes a long time to run, or Hypermesh freezes completely.

Is there any way how i can make this run faster?

For example the renumber-function in Hypermesh can do basically the same thing, but in real time.


Thanks & Best regards

Share this post

Link to post
Share on other sites

Hi there,

you can use hm_entityinfo exist elems $ElemId to verify ElemId is free or not

and hm_entityinfo maxid elems to get maximum ID so incr it you will get next free id

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.

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.

Sign in to follow this  

  • Create New...