Challenge

Project 1- Building a Master TCL/TK Macro

Report Project 1- Building a Master TCL/TK Macro

Objective:finish Project 1- Building a Master TCL/TK Macro

Problem Statement:

  • Build a master tcl/tk macro
  • It should contain buttons that will call all utilities created as assignments during this course
  • Segregate the buttons as per their utility. Color code the buttons as you see fit.
  • Display labels that indicate an idea of your segregation
  • The design must look ergonomic and clutter free
  • Test all the buttons thoroughly on am empty file too.
  • Make sure that there are no null cases

Tcl command explanation:

set a .window
catch {destroy $a}
toplevel $a -class toplevel
wm title $a "Master-01"
wm geometry $a 360x780+100+200

label $a.21 -text "2D" -font {times 10 bold}; place $a.21 -x 30 -y 00 -width 50 -height 20

button $a.01 -text "Warpage" -command "Warpage" -bg grey -font {times 12 bold}; place $a.01 -x 10 -y 30 -width 100 -height 30

entry $a.02 -textvariable ::warpage ; place $a.02 -x 120 -y 30 -width 40 -height 30

button $a.03 -text "Aspect" -command "Aspect" -bg grey -font {times 12 bold}; place $a.03 -x 10 -y 70 -width 100 -height 30

entry $a.04 -textvariable ::aspect ; place $a.04 -x 120 -y 70 -width 40 -height 30

button $a.05 -text "Skew" -command "Skew" -bg grey -font {times 12 bold}; place $a.05 -x 10 -y 110 -width 100 -height 30

entry $a.06 -textvariable ::skew ; place $a.06 -x 120 -y 110 -width 40 -height 30

button $a.07 -text "MinLength" -command "MinLength" -bg grey -font {times 12 bold}; place $a.07 -x 10 -y 150 -width 100 -height 30

entry $a.08 -textvariable ::minlength ; place $a.08 -x 120 -y 150 -width 40 -height 30

button $a.09 -text "MaxLength" -command "MaxLength" -bg grey -font {times 12 bold}; place $a.09 -x 10 -y 190 -width 100 -height 30

entry $a.10 -textvariable ::maxlength ; place $a.10 -x 120 -y 190 -width 40 -height 30

button $a.11 -text "Jacobian" -command "Jacobian" -bg grey -font {times 12 bold}; place $a.11 -x 10 -y 230 -width 100 -height 30

entry $a.12 -textvariable ::jacobian ; place $a.12 -x 120 -y 230 -width 40 -height 30

button $a.13 -text "TriaMinAngle" -command "TriaMinAngle" -bg grey -font {times 11 bold}; place $a.13 -x 10 -y 270 -width 100 -height 30

entry $a.14 -textvariable ::triaminangle ; place $a.14 -x 120 -y 270 -width 40 -height 30

button $a.15 -text "TriaMaxAngle" -command "TriaMaxAngle" -bg grey -font {times 11 bold}; place $a.15 -x 10 -y 310 -width 100 -height 30

entry $a.16 -textvariable ::triamaxangle ; place $a.16 -x 120 -y 310 -width 40 -height 30

button $a.17 -text "QuadMinAngle" -command "QuadMinAngle" -bg grey -font {times 10 bold}; place $a.17 -x 10 -y 350 -width 100 -height 30

entry $a.18 -textvariable ::quadminangle ; place $a.18 -x 120 -y 350 -width 40 -height 30

button $a.19 -text "QuadMaxAngle" -command "QuadMaxAngle" -bg grey -font {times 10 bold}; place $a.19 -x 10 -y 390 -width 100 -height 30

entry $a.20 -textvariable ::quadmaxangle ; place $a.20 -x 120 -y 390 -width 40 -height 30

label $a.22 -text "3D" -font {times 10 bold}; place $a.22 -x 200 -y 00 -width 50 -height 20

button $a.23 -text "Warpage" -command "Warpage3D" -bg grey -font {times 12 bold}; place $a.23 -x 180 -y 30 -width 100 -height 30

entry $a.24 -textvariable ::warpage3d ; place $a.24 -x 290 -y 30 -width 40 -height 30

button $a.27 -text "Aspect" -command "Aspect" -bg grey -font {times 12 bold}; place $a.27 -x 180 -y 70 -width 100 -height 30

entry $a.28 -textvariable ::aspect3d ; place $a.28 -x 290 -y 70 -width 40 -height 30

button $a.29 -text "TetCollapse" -command "TetCollapse" -bg grey -font {times 12 bold}; place $a.29 -x 180 -y 110 -width 100 -height 30

entry $a.30 -textvariable ::tetcollapse ; place $a.30 -x 290 -y 110 -width 40 -height 30

button $a.31 -text "MinLength" -command "MinLength" -bg grey -font {times 12 bold}; place $a.31 -x 180 -y 150 -width 100 -height 30

entry $a.32 -textvariable ::minlength3d ; place $a.32 -x 290 -y 150 -width 40 -height 30

button $a.33 -text "MaxLength" -command "MaxLength" -bg grey -font {times 12 bold}; place $a.33 -x 180 -y 190 -width 100 -height 30

entry $a.34 -textvariable ::maxlength3d ; place $a.34 -x 290 -y 190 -width 40 -height 30

button $a.25 -text "Jacobian" -command "Jacobian" -bg grey -font {times 12 bold}; place $a.25 -x 180 -y 230 -width 100 -height 30

entry $a.26 -textvariable ::jacobian3d ; place $a.26 -x 290 -y 230 -width 40 -height 30

label $a.36 -text "Edges" -bg white -font {times 10 bold}; place $a.36 -x 200 -y 270 -width 100 -height 30

button $a.37 -text "Free Edge" -command {FreeEdges} -bg grey -font {times 10 bold}; place $a.37 -x 180 -y 310 -width 70 -height 25

button $a.38 -text "T Edge" -command {TEdges} -bg grey -font {times 10 bold}; place $a.38 -x 270 -y 310 -width 70 -height 25

button $a.39 -text "Both" -command {Both} -bg grey -font {times 10 bold}; place $a.39 -x 180 -y 350 -width 70 -height 25

button $a.40 -text "OFF" -command {OFF} -bg grey -font {times 10 bold}; place $a.40 -x 270 -y 350 -width 70 -height 25

label $a.41 -text "ElementQuality" -bg white -font {times 10 bold}; place $a.41 -x 90 -y 00 -width 100 -height 20

label $a.42 -text "Normals" -bg white -font {times 10 bold}; place $a.42 -x 110 -y 440 -width 100 -height 20

button $a.43 -text "Normalson" -command {Normalson} -bg grey -font {times 10 bold}; place $a.43 -x 50 -y 470 -width 70 -height 25

button $a.44 -text "Normalsreverse" -command {Normalsreverse} -bg grey -font {times 10 bold}; place $a.44 -x 130 -y 470 -width 100 -height 25

button $a.45 -text "Normalsoff" -command {Normalsoff} -bg grey -font {times 10 bold}; place $a.45 -x 240 -y 470 -width 70 -height 25

button $a.46 -text "Reflect" -command {Reflect} -bg grey -font {times 10 bold}; place $a.46 -x 140 -y 510 -width 70 -height 25

label $a.47 -text "IDs_Check" -bg white -font {times 10 bold}; place $a.47 -x 120 -y 550 -width 100 -height 20

button $a.48 -text "Renumber" -command {renumber} -bg grey -font {times 10 bold}; place $a.48 -x 50 -y 570 -width 70 -height 25

button $a.49 -text "ReorderN" -command {reorderbyname} -bg grey -font {times 10 bold}; place $a.49 -x 150 -y 570 -width 70 -height 25

button $a.50 -text "ReorderID" -command {reorderbyid} -bg grey -font {times 10 bold}; place $a.50 -x 250 -y 570 -width 70 -height 25

label $a.52 -text "Delete" -bg white -font {times 10 bold}; place $a.52 -x 110 -y 620 -width 100 -height 20

button $a.51 -text "Solids" -command "delete solids" -bg grey -font {times 10 bold}; place $a.51 -x 50 -y 650 -width 60 -height 25

button $a.53 -text "Surfaces" -command "delete surfaces" -bg grey -font {times 10 bold}; place $a.53 -x 120 -y 650 -width 60 -height 25

button $a.54 -text "Lines" -command "delete Lines" -bg grey -font {times 10 bold}; place $a.54 -x 190 -y 650 -width 60 -height 25

button $a.55 -text "Points" -command "delete points" -bg grey -font {times 10 bold}; place $a.55 -x 260 -y 650 -width 60 -height 25

label $a.56 -text "Empty" -bg white -font {times 10 bold}; place $a.56 -x 110 -y 690 -width 100 -height 20

button $a.57 -text "Comps" -command "empty comps" -bg grey -font {times 10 bold}; place $a.57 -x 80 -y 710 -width 70 -height 25

button $a.58 -text "Assemblies" -command "empty assemblies" -bg grey -font {times 10 bold}; place $a.58 -x 170 -y 710 -width 80 -height 25

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

proc Warpage3D {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $::warpage3d 2 4 0 "3D Warpage"
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

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

proc Aspect {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestaspect elements 1 $::aspect3d 2 4 0 " 3D Aspect Ratio "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc Skew {} {
*clearmarkall 1
*clearmarkall 2
*createmark elements 1 "displayed"
*elementtestskew elements 1 $::skew 2 2 0 " 2D Skew "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc TetCollapse {} {
*clearmarkall 1
*clearmarkall 2
*createmark elements 1 "displayed"
*elementtesttetracollapse elements 1 $::tetcollapse 2 0 " 3D Tetra Collapse "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc MinLength {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $::minlength 2 1 2 0 " 2D Length < "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

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

proc MinLength {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $::minlength3d 2 1 4 0 " 3D Length < "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc MaxLength {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $::maxlength3d 2 0 4 0 " 3D Length > "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

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

proc Jacobian {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestjacobian elements 1 $::jacobian3d 2 4 0 " 3D Jacobian "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc TriaMinAngle {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $::triaminangle 1 2 1 2 0 " 2D Tria Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc TriaMaxAngle {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $::triamaxangle 1 2 0 2 0 " 2D Tria Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc QuadMinAngle {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $::quadminangle 0 2 1 2 0 " 2D Quad Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc QuadMaxAngle {} {
*clearmarkall 1
*clearmarkall 2
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $::quadmaxangle 0 2 0 2 0 " 2D Quad Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}

proc FreeEdges {} {
*setdisplayattributes 4 1
*createmark elements 1 "displayed"
if {[hm_entityinfo exist comps FreeEdges ]==0 } {
*findedges1 elements 1 0 0 0 30
*setvalue comps name={^edges} name={FreeEdges}
*createmark components 1 "FreeEdges"
*setvalue components mark=1 color=3
*createmark elems 1 "displayed"
*equivalence elems 1 0.01 0 0 0
*equivalence elems 1 0.01 3 0 0
*createmark nodes 1 "retrieve"
*nodemarkaddtempmark 1
} else {
tk_messageBox -message "Already Exists" -icon info -type ok
}
}

proc TEdges {} {
*setdisplayattributes 4 1
*createmark elements 1 "displayed"
if {[hm_entityinfo exist comps TEdges ]==0 } {
*findedges1 elements 1 0 0 0 30
*setvalue comps name={^edges} name={TEdges}
*createmark components 1 "TEdges"
*setvalue components mark=1 color=30
} else {
tk_messageBox -message "Already Exists" -icon info -type ok
}
}

proc Both {} {
FreeEdges;
TEdges;
}

proc OFF {} {
*createmark components 1 "FreeEdges" "TEdges"
*deletemark components 1
*setdisplayattributes 2 0
*clearmark nodes 1
*nodecleartempmark 1
}

proc Normalson {} {
*clearmarkall 1
*setnormalsdisplaytype 1
*createmark elements 1 "displayed"
*normalsdisplay elements 1
}

proc Normalsoff {} {
*normalsoff
}

proc Normalsreverse {} {
*createmark elements 1 "displayed"
*normalsreverse elements 1
}

proc abaqus {a t1} {
set n [concat $a$t1]
if {[hm_entityinfo exist comps $n]==0} {
*createentity comps name=$n
*createmark comps 1 $n
set compid [hm_getmark comps 1]} else {puts "Entity already exists"}
if {[hm_entityinfo exist props $n]==0} {
*createentity props cardimage=SHELLSECTION includeid=0 name=$n
*createmark properties 2 $n
set propid [hm_getmark props 2]
set clr [hm_getvalue comps name=$n dataname=color]
*setvalue props id=$propid STATUS=1 111=$t1 color=$clr
*setvalue comps id=$compid propertyid ={props $propid}}
}
proc Reflect {a} {
*clearmarkall 1 ; *clearmarkall 2
set name [hm_getstring Component_Name "Enter the reflect component name ends with _"]
*createmarkpanel comps 1 "Select the reflect component"
set o_geom [hm_getmark comps 1]
*createmarkpanel comps 1 "Select the target geometry Component"
set t_geom [hm_getmark comps 1]
*createmarkpanel comps 1 "Select the reflect FE components"
set o_fea [hm_getmark comps 1]
set profile [hm_info templatetype]
foreach i $o_fea {
set t [hm_getthickness comps $i]
set old_n [hm_entityinfo name comps $i]
set u [string index $t 0]
set v [string index $t 2]
set p p
set Ts $u$p$v
set n [concat $name$Ts]
$profile $name $Ts
*createmark elems 1 $old_n
*copymark elems 1 $n
*displaycollectorwithfilter comps "off" "$old_n" 1 0
}
*createmark comps 2 "displayed"
*autocolorwithmark comps 2
*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 nodes 2 -1
set o_node [hm_getmark nodes 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 nodes 2 -1
set t_node [hm_getmark nodes 2]
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_nodeinfo [hm_nodevalue $m_node]
*clearmarkall 1
*createmark elems 1 "displayed"
*createplane 1 [lindex $intercepts 1] [lindex $intercepts 2] [lindex $intercepts 3] [lindex $m_nodeinfo 0 0] [lindex $m_nodeinfo 0 1] [lindex $m_nodeinfo 0 2]
*reflectmarkwithoption elems 1 1 0
*clearmarkall 1; *clearmarkall 2
*createmark comps 1 "displayed"
*equivalence comps 1 0.01 1 0 0
}

proc renumber {a} {
*clearmarkall 1
*createmark $a 1 "all"
if {[hm_marklength $a 1] !=0} {*renumber $a 1 100 1 0 0 }
}

proc reorderbyname {a} {
*clearmarkall 1
*createmark $a 1 "all"
if {[hm_marklength $a 1] !=0} {*collectormarkmove $a 1 1 1}
}

proc reorderbyid {a} {
*clearmarkall 1
*createmark $a 1 "all"
if {[hm_marklength $a 1] !=0} {*collectormarkmove $a 1 1 2}
}

proc delete {a} {
*createmark $a 1 "displayed"
if {[hm_marklength $a 1] !=0} {*deletemark $a 1}
}

proc empty {a} {
*EntityPreviewEmpty $a 1
if {[hm_marklength $a 1] !=0} {*deletemark $a 1}
}

Conclusion:task is finished by above code

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.