Assume we have this model:

The script will find all edges and create set of nodes for each edge:

*clearmark comps 1
*clearmark elems 1
*createmark elems 1 "by comps" 1
# hm_getedgeloops = Returns surface and element entities of specific connection types.
# looptype=2 get all closed free (Bit1) edge loops for the displayed elements.
# The return is a "list of loops". Each loop is an ordered list of either surface edge or
# element node IDs that define each loop. The first value in each loop list is the loop type.
# The remaining values are the ordered node/surface edge IDs defining the loop. If the loop
# is closed, the first and last ID are the same.
set loops [hm_getedgeloops elems markid=1 looptype=2]
set n_loops [llength $loops]
puts "loops:  $loops"
puts "n_loops:  $n_loops"
set i 1
foreach loop $loops {
    puts $loop
    # delete first item in the list (loop type)
    set current [lreplace $loop 0 0]
    # delete last item in the list (the first and last IDs are the same)
    set current [lreplace $current end end]
    # create sets
    *clearmark sets 1
    *createentity sets cardimage=SET_GRID includeid=0 name="set_$i"
    *createmark sets 1 -1
    set setID [hm_getmark sets 1]
    *setvalue sets id=$setID ids={nodes $current}
    set i [expr $i+1]
}

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading