Challenge

Week - 6 - Creating the GUI for final checks

OBJECTIVE:

Create a tk GUI for all the final checks/operations that include:

  • Buttons to delete displayed geometric entities.
  • Buttons to delete empty entities
  • Button to re-order and re-number entities by name
  • A master button in red that will execute all above scripts in proper order to keep only the fea entities.

PROCEDURE:

  1. First, we need to create a window with all the buttons and labels as shown below.
  2. We need to assign various operations to these buttons like checking for unused entities to remove the unwanted entities in the model and to keep the required fea entities alone.
  3. *hm_marklength is used to prevent the null cases.
  4. *deletemark command is used to delete the unwamted entities.
  5. *renumber command is used to renumber the entities and it is set to start from 10000 and to increment by 1.
  6. A master button is created to perform all the individual operations in the correct order at the click of a single button.
  7. At last, the program is tested on a bigger model and found all those buttons working correctly.

CODE:

set a .window
catch {destroy $a}
toplevel $a -class Toplevel
wm title $a "FINAL CHECKS"
wm geometry $a 600x650+300+150
wm resizable $a 0 0
wm deiconify $a

label $a.label1 -text "TO DELETE ENTITIES" -bg grey -font {times 12 bold}; place $a.label1 -x 25 -y 20 -width 550 -height 30
label $a.label2 -text "TO REMOVE EMPTY ENTITIES" -bg grey -font {times 12 bold}; place $a.label2 -x 25 -y 110 -width 550 -height 30
label $a.label3 -text "REORDER ENTITIES BY NAME" -bg grey -font {times 12 bold}; place $a.label3 -x 25 -y 290 -width 550 -height 30
label $a.label4 -text "REORDER ENTITIES BY ID" -bg grey -font {times 12 bold}; place $a.label4 -x 25 -y 390 -width 550 -height 30
label $a.label5 -text "RENUMBER ENTITIES" -bg grey -font {times 12 bold}; place $a.label5 -x 25 -y 480 -width 550 -height 30
label $a.label6 -text "***********************************************************************************************" -bg grey -font {times 8 bold}; place $a.label6 -x 25 -y 560 -width 550 -height 15


# DELETE SURFACES, POINTS, LINES AND SOLIDS     ##########
 
button $a.11 -text "DELETE SURFACES" -command {set i surfaces; delete $i} -bg yellow -font {times 8 bold}; place $a.11 -x 25 -y 70 -width 130 -height 20
button $a.12 -text "DELETE POINTS" -command {set i points; delete $i} -bg yellow -font {times 8 bold}; place $a.12 -x 165 -y 70 -width 130 -height 20
button $a.13 -text "DELETE LINES" -command {set i lines; delete $i} -bg yellow -font {times 8 bold}; place $a.13 -x 305 -y 70 -width 130 -height 20
button $a.14 -text "DELETE S0LIDS" -command {set i solids; delete $i} -bg yellow -font {times 8 bold}; place $a.14 -x 445 -y 70 -width 130 -height 20

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

#  REMOVE EMPTY ENTITIES	##########	

button $a.21 -text "EMPTY COMPS" -command {set j comps; empty $j} -bg yellow -font {times 8 bold}; place $a.21 -x 25 -y 160 -width 135 -height 20
button $a.22 -text "EMPTY ASSEMBLY" -command {set j assembly; empty $j} -bg yellow -font {times 8 bold}; place $a.22 -x 165 -y 160 -width 135 -height 20
button $a.23 -text "EMPTY LOAD COLL" -command {set j loadcollectors; empty $j} -bg yellow -font {times 8 bold}; place $a.23 -x 305 -y 160 -width 135 -height 20
button $a.24 -text "EMPTY LOAD STEP" -command {set j loadsteps; empty $j} -bg yellow -font {times 8 bold}; place $a.24 -x 445 -y 160 -width 135 -height 20

button $a.31 -text "UNUSED GROUPS" -command {set c groups; unused $c} -bg yellow -font {times 8 bold}; place $a.31 -x 25 -y 200 -width 135 -height 20
button $a.32 -text "UNUSED CROSS SECTION" -command {set c crosssections; unused $c} -bg yellow -font {times 7 bold}; place $a.32 -x 165 -y 200 -width 135 -height 20
button $a.33 -text "UNUSED SET" -command {set c sets; unused $c} -bg yellow -font {times 8 bold}; place $a.33 -x 305 -y 200 -width 135 -height 20
button $a.34 -text "UNUSED CURVE" -command {set c curves; unused $c} -bg yellow -font {times 8 bold}; place $a.34 -x 445 -y 200 -width 135 -height 20


button $a.41 -text "UNUSED CONTACTS" -command {set c contacts; unused $c} -bg yellow -font {times 8 bold};  place $a.41 -x 25 -y 240 -width 135 -height 20
button $a.42 -text "UNUSED MATS" -command {set c materials; unused $c} -bg yellow -font {times 8 bold}; place $a.42 -x 165 -y 240 -width 135 -height 20
button $a.43 -text "UNUSED PROPERTIES" -command {set c properties; unused $c} -bg yellow -font {times 8 bold}; place $a.43 -x 305 -y 240 -width 135 -height 20
button $a.44 -text "UNUSED BEAM SEC" -command {set c beamsections; unused $c} -bg yellow -font {times 8 bold}; place $a.44 -x 445 -y 240 -width 135 -height 20

proc empty {j} { 
	*EntityPreviewEmpty $j 1
	if {[hm_marklength $j 1!=0]} {*deletemark $j 1}
}	
proc unused {c} { 
	*EntityPreviewUnused $c 1
	if {[hm_marklength $c 1!=0]} {*deletemark $c 1}
}	
	
#  REORDER		##########

button $a.51 -text "REORDER COMPONENTS" -command {set k comps; reorder_name $k} -bg yellow -font {times 9 bold}; place $a.51 -x 80 -y 340 -width 200 -height 30
button $a.52 -text "REORDER PROPERTIES" -command {set k properties; reorder_name $k} -bg yellow -font {times 9 bold}; place $a.52 -x 310 -y 340 -width 200 -height 30

button $a.61 -text "REORDER COMPONENTS" -command {set l comps; reorder_id $l} -bg yellow -font {times 9 bold}; place $a.61 -x 80 -y 440 -width 200 -height 30
button $a.62 -text "REORDER PROPERTIES" -command {set l properties; reorder_id $l} -bg yellow -font {times 9 bold}; place $a.62 -x 310 -y 440 -width 200 -height 30

proc reorder_name {k} { 
	*clearmarkall 1
	*createmark $k 1 "all"
	if {[hm_marklength $k 1!=0]} {
	*collectormarkmove $k 1 1 1}
}
proc reorder_id {l} { 
	*clearmarkall 1
	*createmark $l 1 "all"
	if {[hm_marklength $l 1!=0]} {
	*collectormarkmove $l 1 1 2}
}
	
#  RENUMBER		##########

button $a.71 -text "RENUMBER COMPONENTS" -command {set m comps; renumber $m} -bg yellow -font {times 9 bold}; place $a.71 -x 80 -y 520 -width 200 -height 25
button $a.72 -text "RENUMBER PROPERTIES" -command {set m properties; renumber $m} -bg yellow -font {times 9 bold}; place $a.72 -x 310 -y 520 -width 200 -height 25
	
proc renumber {m} { 
	*clearmarkall 1
	*createmark $m 1 "all"
	if {[hm_marklength $m 1!=0]} {
	*renumber $m 1 10000 1 0 0}
}

#  MASTER BUTTON  ##########

button $a.82 -text "MASTER" -command { master} -bg red -font {times 11 bold}; place $a.82 -x 150 -y 590 -width 300 -height 25

proc master {} { 
set b {surfaces poins lines solids};  foreach i $b {delete $i}
set b {comps assembly loadcollectors loadsteps}; foreach j $b {empty $j}
set b {groups crosssections curves contacts materials properties beamsections}; foreach c $b {unused $c}
set b {components properties}; foreach k $b {reorder_name $k}
set b {components properties}; foreach l $b {reorder_id $l}
set b {components properties}; foreach m $b {renumber $m}
}


GRAPHICAL USER INTERFACE:

CONCLUSION:

  • Learned to create a gui- based program that helps the user to conduct final checks/operations to remove/reorder/renumber all the unwanted entities and to keep only the fea entities in the model.
  • Learned to reorder and renumber the entities.
  • Created a master button to perform all the operations at the click of a single button.
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.