🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

TCL Hypermesh syntax again: loop to store elements

Hello,

Here again on my script, thanks to @Michael Herve and @Marc Arnold I go ahead little by little.

Now I try to store in a set some elements depending of their coordinates.

To simplify here, I have just a row of nodes, 2 rows of elements, and I would like to store elements only if their centerX is bigger than the X of the nodes.

I can't understant why my list $toKeepElems seems to remain empty with the following loop. I print the variables to see what happens and it seems it should be ok but at the end I have nothing with "puts $toKeepElems".

#Selecting nodes (user) and then elements connected to those nodes (with "by node id")
*createmarkpanel nodes 1 'Select Nodes'
set selectedNodes [hm_getmark nodes 1]
*createmark elems 1 "by node id" {*}$selectedNodes
set selectedElems [hm_getmark elems 1]
 
#Storing X coordinate of one of the nodes
set nodeA_id [lindex $selectedNodes 0]
set nodeA_xyz [join [hm_nodevalue $nodeA_id]]
set nodeA_x [lindex $nodeA_xyz 0]
 
#Creating an empty list to store elements
set toKeepElems {}
 
#Looping to store elements
foreach elemC $selectedElems {
set cx [hm_getvalue element id=$elemC dataname=centerx]
puts $cx
puts $nodeA_x
if {$cx > $nodeA_x} {
puts "We are in\n"
lappend $toKeepElems $elemC
}
}
 
#Displaying results
puts $selectedElems
puts $toKeepElems
 
Do you see where I am wrong?
Thanks!
 
image

Find more posts tagged with

Sort by:
1 - 1 of 11