Renumbering Element and Node ID's
Hi,
I'll preface this by saying I'm an absolute beginner in tcl, so sorry if my questions are pretty basic.
I am trying to write a script that will loop through each of my components are renumber the elements and node IDs in line with a certain numbering system. I have managed to figure out the renumbering code via the command.cmf file but I'm having trouble being able to replicate the commands that I've used to select the bolt nodes which will have different IDs.
For example:
*retainmarkselections 1 *createmark components 1 'Part# Back Tophat' *displaycollectorsallbymark 1 'isolateonly' 1 1 *createmark groups 2 *displaycollectorsbymark groups 2 'isolate' 1 1 *retainmarkselections 0 *settopologydisplaytype 1 *createmark elements 1 'displayed' *renumbersolverid elements 1 10100000 1 0 0 0 0 0 *createmark nodes 1 'displayed' *renumbersolverid nodes 1 10100000 1 0 0 0 0 0 *createmark nodes 1 10100318 10100326 10100503 10100520 10101252 10101253 *renumbersolverid nodes 1 10190000 1 0 0 0 0 0 *retainmarkselections 1
The line *createmark nodes 1 10100318 10100326 10100503 10100520 etc is actually selected by going Geom > Points > Select by displayed > Select by geoms > lines > displayed > subtract from selection > save and then is retrieved in the renumber nodes panel by select nodes by geom > points > retrive. This works because all nodes that will be used in bolted connections are fixed points and are not on lines in the geometry. Is there any way to replicate this selection process in the .tcl script?
Ultimately I want to loop through each component by isolating them, each time changing the numbering i.e. 1st component starts on 1010000, 2nd component 1020000 etc or use the built-in hypermesh component ID to number the elements and nodes.
Also, could someone please point me in the direction of some basic tutorials that involve looping in tcl?
Many thanks,
Matt
Answers
-
I have written this, but it doesn't work. Not sure what I've done wrong.
hm_createmark nodes 1 'by lines' 'displayed' set ndsline [hm_getmark nodes 1] hm_createmark nodes 1 'by points' 'displayed' eval hm_markremove nodes 1 $ndsline # renumber bolt node IDs *renumbersolverid nodes 1 10190000 1 0 0 0 0 0
0 -
Hi Matt,
Here is a script I use for renumbering nodes and elements based on their collector. The expression for 'startid' can be modified as needed.
proc RenumNodesElems {} {
*createmarkpanel comps 1 'Select the Comps to Renumber'
*entityhighlighting 0
hm_blockmessages 1set comps [hm_getmark comps 1]
*clearmark comps 1
foreach comp $comps {
set startid [expr 100000*$comp + 1]
*createmark nodes 1 'by comp id' $comp
*renumbersolverid nodes 1 $startid 1 0 0
*clearmark nodes 1*createmark elems 1 'by comp id' $comp
*renumbersolverid elems 1 $startid 1 0 0
*clearmark elems 1
}
}RenumNodesElems
tk_messageBox -message 'Finished!' -type ok
*entityhighlighting 1
hm_blockmessages 0
0 -
Thanks Kevin,
This is exactly the sort of thing I was after. I'll see if I can edit it further to try and renumber my bolt nodes as well. Wish me luck!
0 -
Still struggling with trying to use geometry to select the nodes that are on fixed points but not on lines.
Any insight on to why this code doesn't work? I get the error that no nodes are selected.hm_createmark nodes 1 'by lines' 'displayed'
set ndsline [hm_getmark nodes 1]
*retainmarkselections 0
hm_createmark nodes 1 'by points' 'displayed'
hm_markremove nodes 1 $ndsline
# renumber bolt node IDs
*renumbersolverid nodes 1 10190000 1 0 0 0 0 0EDIT:
I actually figured it out myself. If anyone's interested in the code I used, I've pasted it below. There's probably a more efficient way to achieve the same result but it works!
*createmark lines 1 'displayed'
set dlines [hm_getmark lines 1]
*clearmark lines 1
hm_createmark points 2 'by lines' $dlines
*createmark points 1 'displayed'
*markdifference points 1 points 2
set bolts [hm_getmark points 1]
hm_createmark nodes 1 'by points' $bolts
*renumbersolverid nodes 1 10190000 1 0 0 0 0 0
0