Challenge

Project 1- Building a Master TCL/TK Macro

Aim:

To create a master TCL/TK macro

Procedure:

Buttons that will call all utilities created as assignments during this course

set a .window
catch {destroy $a}
toplevel $a -class topLevel
wm geometry $a 260x560+5+10; update
wm title $a "Master"
wm resizable $a 0 0
wm deiconify $a
button $a.01 -text "Normals" -command "normals" -bg yellow -font {times 10 bold}; place $a.01 -x 25 -y 20 -width 200 -height 40
button $a.02 -text "Final_Checks" -command "final_checks" -bg yellow -font {times 10 bold}; place $a.02 -x 25 -y 80 -width 200 -height 40
button $a.03 -text "Checking_Edges" -command "checking_edges" -bg yellow -font {times 10 bold}; place $a.03 -x 25 -y 140 -width 200 -height 40
button $a.04 -text "Creating_Entities" -command "creating_entities" -bg yellow -font {times 10 bold}; place $a.04 -x 25 -y 200 -width 200 -height 40
button $a.05 -text "Reflect" -command "reflect" -bg yellow -font {times 10 bold}; place $a.05 -x 25 -y 260 -width 200 -height 40
button $a.06 -text "Create_Mid" -command "create_mid" -bg yellow -font {times 10 bold}; place $a.06 -x 25 -y 320 -width 200 -height 40
button $a.07 -text "Element_Qality" -command "element_qality" -bg yellow -font {times 10 bold}; place $a.07 -x 25 -y 380 -width 200 -height 40
button $a.08 -text "Create_Connectors" -command "create_connectors" -bg yellow -font {times 10 bold}; place $a.08 -x 25 -y 440 -width 200 -height 40
button $a.09 -text "Identify_Identical" -command "identify_identical" -bg yellow -font {times 10 bold}; place $a.09 -x 25 -y 500 -width 200 -height 40

GUI when i run the macro

Procedure of full macro

set a .window
catch {destroy $a}
toplevel $a -class topLevel
wm geometry $a 260x560+5+10; update
wm title $a "Master"
wm resizable $a 0 0
wm deiconify $a
button $a.01 -text "Normals" -command "normals" -bg yellow -font {times 10 bold}; place $a.01 -x 25 -y 20 -width 200 -height 40
button $a.02 -text "Final_Checks" -command "final_checks" -bg yellow -font {times 10 bold}; place $a.02 -x 25 -y 80 -width 200 -height 40
button $a.03 -text "Checking_Edges" -command "checking_edges" -bg yellow -font {times 10 bold}; place $a.03 -x 25 -y 140 -width 200 -height 40
button $a.04 -text "Creating_Entities" -command "creating_entities" -bg yellow -font {times 10 bold}; place $a.04 -x 25 -y 200 -width 200 -height 40
button $a.05 -text "Reflect" -command "reflect" -bg yellow -font {times 10 bold}; place $a.05 -x 25 -y 260 -width 200 -height 40
button $a.06 -text "Create_Mid" -command "create_mid" -bg yellow -font {times 10 bold}; place $a.06 -x 25 -y 320 -width 200 -height 40
button $a.07 -text "Element_Qality" -command "element_qality" -bg yellow -font {times 10 bold}; place $a.07 -x 25 -y 380 -width 200 -height 40
button $a.08 -text "Create_Connectors" -command "create_connectors" -bg yellow -font {times 10 bold}; place $a.08 -x 25 -y 440 -width 200 -height 40
button $a.09 -text "Identify_Identical" -command "identify_identical" -bg yellow -font {times 10 bold}; place $a.09 -x 25 -y 500 -width 200 -height 40
#Creating_Normals
proc normals {} {
set n .window
catch {destroy $n}
toplevel $n -class topLevel
wm geometry $n 500x150+500+100; update
wm title $n "Normals_Check"
wm resizable $n 0 0
wm deiconify $n
button $n.02 -text "Normals_On" -command "normals_on a" -bg green -font {times 10 bold}; place $n.02 -x 20 -y 20 -width 200 -height 50
button $n.03 -text "Normals_Off" -command "normals_off b" -bg gray -font {times 10 bold}; place $n.03 -x 250 -y 20 -width 200 -height 50
proc normals_on {a} {
*setnormalsdisplaytype 1
*createmark elements 1 "displayed"
*normalsdisplay elements 1
*clearmarkall 1
*createmarkpanel elements 1 "select the elements you want reverse normals for"
*normalsreverse elements 1
*createmark elements 1 "displayed"
*normalsdisplay elements 1
}
proc normals_off {b} {
*normalsoff
}
}

#Final_Checks
proc final_checks {} {
set c_edge .window
catch {destroy $c_edge}
toplevel $c_edge -class topLevel
wm geometry $c_edge 500x500+200+200; update
wm title $c_edge "Final_Checks"
wm resizable $c_edge 0 0
wm deiconify $c_edge
button $c_edge.01 -text "Delete surfaces" -command "delete surfaces" -bg yellow -font {times 10 bold}; place $c_edge.01 -x 20 -y 50 -width 100 -height 25
button $c_edge.02 -text "Delete Points" -command "delete points" -bg gray -font {times 10 bold}; place $c_edge.02 -x 140 -y 50 -width 100 -height 25
button $c_edge.03 -text "Delete Lines" -command "delete lines" -bg blue -font {times 10 bold}; place $c_edge.03 -x 260 -y 50 -width 100 -height 25
button $c_edge.04 -text "Delete Solids" -command "delete solids" -bg green -font {times 10 bold}; place $c_edge.04 -x 380 -y 50 -width 100 -height 25
proc delete {c} {
*deleteelementsmode 0
*createmark $c 1 "displayed"
if {[hm_marklength $c 1] !=0} {*deletemark $c 1}
}
button $c_edge.05 -text "Empty Comps" -command "empty comps" -bg gray -font {times 10 bold}; place $c_edge.05 -x 20 -y 100 -width 100 -height 25
button $c_edge.06 -text "Empty Assy" -command "empty assemblies" -bg green -font {times 10 bold}; place $c_edge.06 -x 140 -y 100 -width 100 -height 25
button $c_edge.07 -text "Empty Loadcol" -command "empty loadcol" -bg blue -font {times 10 bold}; place $c_edge.07 -x 260 -y 100 -width 100 -height 25
button $c_edge.08 -text "Empty Loadstep" -command "empty loadstep" -bg yellow -font {times 10 bold}; place $c_edge.08 -x 380 -y 100 -width 100 -height 25
button $c_edge.09 -text "Empty Groups" -command "empty groups" -bg yellow -font {times 10 bold}; place $c_edge.09 -x 20 -y 150 -width 100 -height 25
button $c_edge.10 -text "Empty Vectcols" -command "empty vectcols" -bg gray -font {times 10 bold}; place $c_edge.10 -x 140 -y 150 -width 100 -height 25
button $c_edge.11 -text "Empty Beamcols" -command "empty beamsectcols" -bg blue -font {times 10 bold}; place $c_edge.11 -x 260 -y 150 -width 100 -height 25
button $c_edge.12 -text "Empty Contacts" -command "empty contactsurfs" -bg green -font {times 10 bold}; place $c_edge.12 -x 380 -y 150 -width 100 -height 25
proc empty {d} {
*EntityPreviewEmpty $d 1
if {[hm_marklength $d 1] !=0} {*deletemark $d 1}
}
button $c_edge.13 -text "Unused Props" -command "unused props" -bg gray -font {times 10 bold}; place $c_edge.13 -x 20 -y 200 -width 100 -height 25
button $c_edge.14 -text "Unused Mats" -command "unused mats" -bg green -font {times 10 bold}; place $c_edge.14 -x 140 -y 200 -width 100 -height 25
button $c_edge.15 -text "Unused Beamsec" -command "unused beamsects" -bg blue -font {times 10 bold}; place $c_edge.15 -x 260 -y 200 -width 100 -height 25
button $c_edge.16 -text "Unused Systs" -command "unused systs" -bg yellow -font {times 10 bold}; place $c_edge.16 -x 380 -y 200 -width 100 -height 25
proc unused {e} {
*EntityPreviewUnused $e 1
if {[hm_marklength $e 1] !=0} {*deletemark $e 1}
}
button $c_edge.17 -text "Reorder Comps" -command {reorder comps} -bg yellow -font {times 10 bold}; place $c_edge.17 -x 20 -y 250 -width 100 -height 25
button $c_edge.18 -text "Reorder Props" -command {reorder props} -bg blue -font {times 10 bold}; place $c_edge.18 -x 140 -y 250 -width 100 -height 25
button $c_edge.19 -text "Reorder Mats" -command {reorder mats} -bg green -font {times 10 bold}; place $c_edge.19 -x 260 -y 250 -width 100 -height 25
button $c_edge.20 -text "Reorder Assy" -command {reorder assems} -bg yellow -font {times 10 bold}; place $c_edge.20 -x 380 -y 250 -width 100 -height 25
proc reorder {f} {
*clearmarkall 1
*createmark $f 1 "all"
if {[hm_marklength $f 1] !=0} {*collectormarkmove $f 1 1 1}
}
button $c_edge.21 -text "Renumber Comps" -command {renumber comps} -bg yellow -font {times 10 bold}; place $c_edge.21 -x 20 -y 300 -width 100 -height 25
button $c_edge.22 -text "Renumber Props" -command {renumber props} -bg blue -font {times 10 bold}; place $c_edge.22 -x 140 -y 300 -width 100 -height 25
button $c_edge.23 -text "Renumber Elemts" -command {renumber elements} -bg green -font {times 10 bold}; place $c_edge.23 -x 260 -y 300 -width 100 -height 25
button $c_edge.24 -text "Renumber Nodes" -command {renumber nodes} -bg yellow -font {times 10 bold}; place $c_edge.24 -x 380 -y 300 -width 100 -height 25
proc renumber {g} {
*clearmarkall 1
*createmark $g 1 "all"
if {[hm_marklength $g 1] !=0} {*renumber $g 1 1 1 0 0}
}
}

#Checking_Edges
proc checking_edges {} {
set f_edge .window
catch {destroy $f_edge}
toplevel $f_edge -class topLevel
wm geometry $f_edge 500x150+200+200; update
wm title $f_edge "Checking_Edges"
wm resizable $f_edge 0 0
wm deiconify $f_edge
button $f_edge.01 -text "Creat_E_Comps" -command "creat_e_comps" -bg yellow -font {times 10 bold}; place $f_edge.01 -x 20 -y 50 -width 100 -height 25
button $f_edge.02 -text "Free_Edge" -command "free_edges" -bg gray -font {times 10 bold}; place $f_edge.02 -x 140 -y 50 -width 100 -height 25
button $f_edge.03 -text "T_Edges" -command "T_edges" -bg blue -font {times 10 bold}; place $f_edge.03 -x 260 -y 50 -width 100 -height 25
button $f_edge.04 -text "Preview_Equi" -command "preview_equi" -bg green -font {times 10 bold}; place $f_edge.04 -x 380 -y 50 -width 100 -height 25
button $f_edge.05 -text "Delete_Edges" -command "delete_edges" -bg green -font {times 10 bold}; place $f_edge.05 -x 200 -y 100 -width 100 -height 25

proc creat_e_comps {} {
*clearmarkall 1; *clearmarkall 2;
*createmark components 1 "Free Edges" "T Edges"
if {[hm_marklength components 1] !=0} {*deletemark components 1}
*collectorcreateonly components "Free Edges" "" 3
*collectorcreateonly components "T Edges" "" 7
}

proc free_edges {} {
*clearmarkall 1; *clearmarkall 2;
*createmark elements 1 "displayed"
if {[hm_marklength elements 1] !=0} {*findedges1 elements 1 0 0 0 30}
*createmark elements 2 "by collector" "^edges"
if {[hm_marklength elements 2] !=0} {*movemark elements 2 "Free Edges"}
*createmark components 1 "^edges"
if {[hm_marklength components 1] !=0} {*deletemark components 1}
*setdisplayattributes 4 1
*setcomponentdisplayattributes "Free Edges" 2 1;
}

proc T_edges {} {
*clearmarkall 1; *clearmarkall 2;
*createmark elements 1 "displayed"
if {[hm_marklength elements 1] !=0} {*findedges1 elements 1 1 0 0 30}
*createmark elements 2 "by collector" "^edges"
if {[hm_marklength elements 2] !=0} {*movemark elements 2 "T Edges"}
*createmark components 1 "^edges"
if {[hm_marklength components 1] !=0} {*deletemark components 1}
*setdisplayattributes 4 1
*setcomponentdisplayattributes "T Edges" 2 1;
}

proc preview_equi {} {
*clearmarkall 1; *clearmarkall 2;
*createmark elements 1 "displayed"
*equivalence elements 1 0 0.01 3 0 0
set a [hm_getusermark nodes]
eval *createmark nodes 1 $a
*nodemarkaddtempmark 1
}

proc delete_comp {h} {
*clearmarkall 1; *clearmarkall 2;
*createmark comps 1 $h
if {[hm_marklength comps 1] !=0} {*deletemark comps 1}
}

proc delete_edges {} {
delete_comp "Free Edges"
delete_comp "T Edges"
delete_comp "^edges"
*setdisplayattributes 2 1
}
delete_edges;
}

#Creating_Entities
proc creating_entities {} {
set entities .window
catch {destroy $entities}
toplevel $entities -class toplevel
wm title $entities "Creating_Components"
wm geometry $entities 400x300+200+200; update
wm resizable $entities 0 0
wm deiconify $entities
label $entities.01 -text "Component" -bg yellow -font {times 10 bold}; place $entities.01 -x 20 -y 20 -width 100 -height 40
label $entities.02 -text "Thickness" -bg green -font {times 10 bold}; place $entities.02 -x 20 -y 100 -width 100 -height 40
entry $entities.03 -textvariable r; place $entities.03 -x 150 -y 20 -width 200 -height 40
entry $entities.04 -textvariable s; place $entities.04 -x 150 -y 100 -width 200 -height 40
button $entities.05 -text "Create" -command {create $r $s } -bg red -font {times 20 bold}; place $entities.05 -x 80 -y 200 -width 150 -height 60
puts z
proc create {a t} {
set nastran [hm_info templatetype]
if {$nastran == "nastran"} {
set c $a
set d $t
*createmark comps 1 $c
if {[hm_marklength components 1 $c] !=0} {
puts [tk_messageBox -message "The component already exists" -icon warning -type ok -title prompt]
} else {
*createentity comps includeid=0 name=$c;
*createmark comps 1 $c
set compid [hm_getmark comps 1]
*createentity props cardimage=PSHELL includeid=0 name=$c;
*createmark props 2 $c
set propid [hm_getmark props 2]
*setvalue props id=$propid STATUS=1 95=$t;
*setvalue comps id=$compid propertyid= $propid;
}
}
}
}

#Entity_Reflect
proc reflect {} {
set ref .window
catch {destroy $ref}
toplevel $ref -class toplevel
wm title $ref "Creating_Components"
wm geometry $ref 500x100+200+200; update
wm resizable $ref 0 0
wm deiconify $ref
button $ref.01 -text "Inputs" -command "inputs" -bg yellow -font {times 10 bold}; place $ref.01 -x 25 -y 20 -width 200 -height 40
button $ref.02 -text "Entity_Eq" -command "entity_eq" -bg yellow -font {times 10 bold}; place $ref.02 -x 250 -y 20 -width 200 -height 40
# inputs
proc inputs {} {
proc nastran {a t} {
set nastran [hm_info templatetype]
if {$nastran=="nastran"} {
set c $a
set d $t
*clearmarkall 1
*createmark comps 1 $c
if {[hm_marklength comps 1 $c]!=0} {
puts [tk_messageBox -message "The component already exists" -icon warning -type ok -detail "" -title prompt]
} else {
*createentity comps includeid=0 name=$c;
*createmark components 1 $c
set compid [hm_getmark comps 1]
*createentity props cardimage=PSHELL includeid=0 name=$c;
*createmark props 2 $c
set propid [hm_getmark props 2]
*setvalue props id=$propid STATUS=1 95=$t;
*setvalue comps id=$compid propertyid=$propid;
}
}
}
proc Reflect {} {
*clearmarkall 1; *clearmarkall 2;
set name [hm_getstring Component_Name "Enter name of reflect component followed by _"]
*createmarkpanel comps 1 "Select the component containing original geometry to be reflected"
set o_geom [hm_getmark comp 1]
*createmarkpanel comps 1 "Select the component containing target geometry"
set t_geom [hm_getmark comp 1]
*createmarkpanel comps 1 "Select the FE component you want to reflect"
set o_fea [hm_getmark comp 1]
puts a
# component operation
set profile [hm_info templatetype]
foreach i $o_fea {
set t [hm_getthickness comps $i]
set old_n [hm_entityinfo name comps $i]
set n $name$t
$profile $n $t
*createmark elements 1 $old_n
*copymark elements 1 $n
*displaycollectorwithfilter components "off" "$old_n" 1 0
}
*createmark comps 2 "displayed"
*autocolorwithmark components 2
puts b
# Creating centriod
*clearmarkall 1; *clearmarkall 2;
*createmark surfaces 1 "by collector" $o_geom
set o_cog [hm_getcentroid surfaces 1]
*createnode [lindex $o_cog 0] [lindex $o_cog 1] [lindex $o_cog 2] 0
*createmark node 2 -1
set o_node [hm_getmark node 2]
*createmark surfaces 1 "by collector" $t_geom
set t_cog [hm_getcentroid surfaces 1]
*createnode [lindex $t_cog 0] [lindex $t_cog 1] [lindex $t_cog 2] 0
*createmark node 2 -1
set t_node [hm_getmark node 2]
puts c
#creating intercepts needed to define reflect plane
set intercepts [hm_getdistance nodes $o_node $t_node 0];
*clearmarkall 1;
*createnodesbetweennodes $o_node $t_node 1;
*createmark nodes 1 -1
set m_node [hm_getmark nodes 1];
set m_node_info [hm_nodevalue $m_node]; #getting the co-ordinate of mid node for plane definition {x y z}
puts d
# reflecting the component
*clearmarkall 1;
*createmark elements 1 "displayed"
*createplane 1 [lindex $intercepts 1] [lindex $intercepts 2] [lindex $intercepts 3] [lindex $m_node_info 0 0] [lindex $m_node_info 0 1] [lindex $m_node_info 0 2]
*reflectmarkwithoption elements 1 1 0;
puts e
}
Reflect;
}
#equivalence
proc entity_eq {} {
*clearmarkall 1 ; *clearmarkall 2;
*createmark component 1 "displayed"
*equivalence components 1 0.01 1 0
}
}

#Create_Mid
proc create_mid {} {
set mid .window
catch {destroy $mid}
toplevel $mid -class toplevel
wm title $mid "Creating_Components"
wm geometry $mid 250x100+200+200; update
wm resizable $mid 0 0
wm deiconify $mid
button $mid.01 -text "Mid_Line" -command "mid_line" -bg yellow -font {times 10 bold}; place $mid.01 -x 25 -y 20 -width 200 -height 40
proc mid_line {} {
*createlistbypathpanel lines 1 "select source lines by path"
set source [hm_getlist lines 1]
*createlistbypathpanel lines 2 "select destination lines by path"
set target [hm_getlist lines 2]
foreach i $source j $target {
*linescreatemidline 1 1 2 2
# *linecombine $i
}
}
}

#Element_Qality
proc element_qality {} {
set ele_q .window
catch {destroy $ele_q}
toplevel $ele_q -class toplevel
wm title $ele_q "Element_Qality"
wm geometry $ele_q 1000x700+200+200; update
wm resizable $ele_q 0 0
wm deiconify $ele_q
label $ele_q.01 -text "2D" -bg red -font {times 10 bold}; place $ele_q.01 -x 50 -y 5 -width 250 -height 30
entry $ele_q.02 -textvariable w; place $ele_q.02 -x 300 -y 50 -width 50 -height 40
button $ele_q.03 -text "Warpage" -command {warpage $w} -bg yellow -font {times 20 bold}; place $ele_q.03 -x 20 -y 50 -width 200 -height 40
entry $ele_q.04 -textvariable a; place $ele_q.04 -x 300 -y 100 -width 50 -height 40
button $ele_q.05 -text "Aspect" -command {aspect $a} -bg yellow -font {times 20 bold}; place $ele_q.05 -x 20 -y 100 -width 200 -height 40
entry $ele_q.06 -textvariable s; place $ele_q.06 -x 300 -y 150 -width 50 -height 40
button $ele_q.07 -text "Skew" -command {skew $s} -bg yellow -font {times 20 bold}; place $ele_q.07 -x 20 -y 150 -width 200 -height 40
entry $ele_q.08 -textvariable j; place $ele_q.08 -x 300 -y 200 -width 50 -height 40
button $ele_q.09 -text "Jacobian" -command {jacobian $j} -bg yellow -font {times 20 bold}; place $ele_q.09 -x 20 -y 200 -width 200 -height 40
entry $ele_q.10 -textvariable min_l; place $ele_q.10 -x 300 -y 250 -width 50 -height 40
button $ele_q.11 -text "MinLength" -command {minlength $min_l} -bg yellow -font {times 20 bold}; place $ele_q.11 -x 20 -y 250 -width 200 -height 40
entry $ele_q.12 -textvariable max_l; place $ele_q.12 -x 300 -y 300 -width 50 -height 40
button $ele_q.13 -text "MaxLength" -command {maxlength $max_l} -bg yellow -font {times 20 bold}; place $ele_q.13 -x 20 -y 300 -width 200 -height 40
entry $ele_q.14 -textvariable min_a_t; place $ele_q.14 -x 300 -y 350 -width 50 -height 40
button $ele_q.15 -text "MinAngleTria" -command {minangletria $min_a_t} -bg yellow -font {times 20 bold}; place $ele_q.15 -x 20 -y 350 -width 200 -height 40
entry $ele_q.16 -textvariable max_a_t; place $ele_q.16 -x 300 -y 400 -width 50 -height 40
button $ele_q.17 -text "MaxAngleTria" -command {maxangletria $max_a_t} -bg yellow -font {times 20 bold}; place $ele_q.17 -x 20 -y 400 -width 200 -height 40
entry $ele_q.18 -textvariable min_a_q; place $ele_q.18 -x 300 -y 450 -width 50 -height 40
button $ele_q.19 -text "MinAngleQuad" -command {minanglequad $min_a_q} -bg yellow -font {times 20 bold}; place $ele_q.19 -x 20 -y 450 -width 200 -height 40
entry $ele_q.20 -textvariable max_a_q; place $ele_q.20 -x 300 -y 500 -width 50 -height 40
button $ele_q.21 -text "MaxAngleQuad" -command {maxanglequad $max_a_q} -bg yellow -font {times 20 bold}; place $ele_q.21 -x 20 -y 500 -width 200 -height 40
label $ele_q.22 -text "3D" -bg red -font {times 10 bold}; place $ele_q.22 -x 550 -y 5 -width 250 -height 30
entry $ele_q.23 -textvariable 3D_w; place $ele_q.23 -x 775 -y 50 -width 50 -height 40
button $ele_q.24 -text "3D_Warpage" -command {3D_warpage $3D_w} -bg yellow -font {times 20 bold}; place $ele_q.24 -x 500 -y 50 -width 200 -height 40
entry $ele_q.25 -textvariable 3D_a; place $ele_q.25 -x 775 -y 100 -width 50 -height 40
button $ele_q.26 -text "3D_Aspect" -command {3D_aspect $3D_a} -bg yellow -font {times 20 bold}; place $ele_q.26 -x 500 -y 100 -width 200 -height 40
entry $ele_q.27 -textvariable 3D_s; place $ele_q.27 -x 775 -y 150 -width 50 -height 40
button $ele_q.28 -text "3D_Skew" -command {3D_skew $3D_s} -bg yellow -font {times 20 bold}; place $ele_q.28 -x 500 -y 150 -width 200 -height 40
entry $ele_q.29 -textvariable 3D_j; place $ele_q.29 -x 775 -y 200 -width 50 -height 40
button $ele_q.30 -text "3D_Jacobian" -command {3D_jacobian $3D_j} -bg yellow -font {times 20 bold}; place $ele_q.30 -x 500 -y 200 -width 200 -height 40
entry $ele_q.31 -textvariable 3D_tet; place $ele_q.31 -x 775 -y 250 -width 50 -height 40
button $ele_q.32 -text "3D_Tetra" -command {3D_tetra $3D_tet} -bg yellow -font {times 20 bold}; place $ele_q.32 -x 500 -y 250 -width 200 -height 40


proc warpage {w} {
set warp $w;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $warp 2 2 0 " 2D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc aspect {a} {
set asp $a;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestaspect elements 1 $asp 2 2 0 " 2D Aspect Ratio "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc skew {s} {
set skw $s;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestskew elements 1 $skw 2 2 0 " 2D Skew "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc jacobian {j} {
set jacob $j;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestjacobian elements 1 $jacob 2 2 0 " 2D Jacobian "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc minlength {min_l} {
set mnl $min_l;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $mn1 2 1 2 0 " 2D Length < "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc maxlength {max_l} {
set mxl $max_l;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $mxl 2 0 2 0 " 2D Length > "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc minangletria {min_a_t} {
set mnat $min_a_t;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $mnat 1 2 1 2 0 " 2D Tria Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc maxangletria {max_a_t} {
set mxat $max_a_t;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $mxat 1 2 0 2 0 " 2D Tria Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc maxanglequad {max_a_q} {
set mxaq $max_a_q;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $mxaq 1 2 0 2 0 " 2D Quad Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc minanglequad {min_a_q} {
set mnaq $min_a_q;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $mnaq 1 2 1 2 0 " 2D Quad Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc 3D_warpage {3D_w} {
set 3Dwarp $3D_w;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $3Dwarp 2 4 0 " 3D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc 3D_aspect {3D_a} {
set 3Daspt $3D_a;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestaspect elements 1 $3Daspt 2 4 0 " 3D Aspect Ratio "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc 3D_skew {3D_s} {
set 3Dskw $3D_s;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestskew elements 1 $3Dskw 2 4 0 " 3D Skew "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc 3D_jacobian {3D_j} {
set 3Djacob $3D_j;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestjacobian elements 1 $3Djacob 2 4 0 " 3D Jacobian "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc 3D_tetra {3D_tet} {
set 3Dtet $3D_tet;
*clearmarkall 1; *clearmarkall 2;
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtesttetracollapse elements 1 $3Dtet 2 0 " 3D Tetra Collapse "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
}

#Checking_Connectors
proc create_connectors {} {
set connector .window
catch {destroy $connector}
toplevel $connector -class topLevel
wm geometry $connector 250x280+500+100; update
wm title $connector "Connectors"
wm resizable $connector 0 0
wm deiconify $connector

# Buttons
button $connector.01 -text "Create collectors" -command {create} -font {times 12 bold}; place $connector.01 -x 65 -y 10 -width 120 -height 40
button $connector.02 -text "Welds" -command {weld} -font {times 12 bold}; place $connector.02 -x 65 -y 60 -width 120 -height 40
button $connector.03 -text "X Locator" -command {X_Loc} -font {times 12 bold}; place $connector.03 -x 65 -y 110 -width 120 -height 40
button $connector.04 -text "Y Locator" -command {Y_Loc} -font {times 12 bold}; place $connector.04 -x 65 -y 160 -width 120 -height 40
button $connector.05 -text "Z Locator" -command {Z_Loc} -font {times 12 bold}; place $connector.05 -x 65 -y 210 -width 120 -height 40

Proc create {} {
*clearmarkall 1; *clearmarkall 2;
*createmark component 1 welds; if {[hm_marklength components 1] == 0} {*createentity component name=welds color=3}
*createmark component 1 X_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=X_Loc color=56}
*createmark component 1 Y_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=Y_Loc color=5}
*createmark component 1 Z_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=Z_Loc color=6}
}
proc weld {} {
*clearmarkall 1; *clearmarkall 2;
*currentcollector components "welds"
*createmarkpanel nodes 2 "Select a1l nodes for creating spider we1d"
*rigidlinkinodecalandcreate 2 0 0 123456
}

proc X_Loc {} {
*currentcollector components "X_Loc"
*createmarkpanel nodes 1 "Select source node for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target node for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 156
}

proc Y_loc {} {
*currentcollector components "Y_Loc"
*createmarkpanel nodes 1 "Select source node for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target node for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 246
}

proc Z_loc {} {
*currentcollector components "Z_Loc"
*createmarkpanel nodes 1 "Select source node for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target node for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 246
}
}

#Identify_Identical
proc identify_identical {} {
set identical .window
catch {destroy $identical}
toplevel $identical -class topLevel
wm geometry $identical 220x100+5+10; update
wm title $identical "Connectors"
wm resizable $identical 0 0
wm deiconify $identical
button $identical.01 -text "Find_Identical" -command {find_identical} -font {times 12 bold}; place $identical.01 -x 65 -y 10 -width 120 -height 40
Proc find_identical {} {
*clearmarka11 1; *clearmarka11 2;
# list of all comps
*createmark comps 1 "a11"
set a11_comp [hm_getmark comps 1];
# list of a11 surfaces
foreach i $a11_comp {
*createmark surfaces 1 "by co11ector" $i
lappend a11_comp_ surf [hm_marklength surfaces 1]
}
# Input component
*createmarkpanel comps 2 "Select the geometric component of interest"
set target_comp [hm_getmark comp 2]
*isolateentitybymark 2
puts "Target comp id $target_comp"
*creatmark surfaces 2 "by collector" $target_comp
puts [set target_comp_surf [hm_marklength surfaces 2]]
set match_list_surf [1search -a1l $a11_comp_surf $target_comp_surf]
puts "Match list surface $match_list_surf"
foreach j $match_list_surf {
set compid [1index $a11_comp $j]
set comp_name [hm_entityinfo name components $compid]
*displaycollectorwithfilter components "on" "$comp_name" 0 1
}
}
find_identical;
}

Snippets:

GUI when i click on button Normals button

GUI when i click on button Final_check

GUI when i click on button Checking_Edges

GUI when i click button Creat_Entity

GUI when i click button Reflect

GUI when i click button Create_Mid

GUI when i click button Element_Qality

GUI when i click button Create_Connector

GUI when i click button Identify_Identical

* The macro has attached below.

Conclusion:

This macro helps not to search for the icons and helps to complete task faster.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.