Week - 7 - Checking and correcting the edges
File attached below
Details about the 1st procedure:
-
proc edge {} {: This line defines a procedure named "edge" with no arguments. The procedure's code is enclosed within the curly braces. -
*createmark elements 1 "displayed": This command creates a mark set 1 containing the elements that are currently displayed. The elements can be of any type (nodes, elements, etc.) that are visible in the current view. -
*setdisplayattributes 4 1: This command sets the display attributes of mark set 1 to have a color index of 4 and a display representation of 1. This means that the elements in mark set 1 will be displayed with the specified color and representation. -
if {[hm_entityinfo exist comps free_edges] == 0 } {*findedges1 elements 1 0 0 0 0}: This line checks if the entity named "comps" with the name "free_edges" exists. If it does not exist (the condition is true), the command*findedges1 elements 1 0 0 0 0is executed. The*findedges1command finds edges based on the elements in mark set 1 with various options specified. -
if {[hm_entityinfo exist comps free_edges] == 0} {*setvalue comps name=^edges name=free_edges}: This line checks if the entity named "comps" with the name "free_edges" exists. If it does not exist (the condition is true), the command*setvalue comps name=^edges name=free_edgesis executed. The*setvaluecommand sets the value of the specified entity to the given values, in this case, changing the name of the "comps" entity to "free_edges". -
*createmark components 1 "free_edges": This command creates a mark set 1 containing the components (groups of elements) that have the name "free_edges". This mark set will include the components that were previously assigned the name "free_edges" using the*setvaluecommand. -
*setvalue comps mark=1 color=#FF0000: This command sets the mark value of the components in mark set 1 to 1 and their color to #FF0000 (red). -
*setcomponentdisplayattributes "free_edges" 2 1: This command sets the display attributes of the components in mark set 1 with the name "free_edges". The components will be displayed with a color index of 2 and a display representation of 1. -
*createmark elements 1 "displayed": This command creates a mark set 1 containing the elements that are currently displayed. This is done again to update the mark set after finding and modifying the free edges. -
if {[hm_entityinfo exist comps T_edges] == 0 } {*findedges1 elements 1 1 0 0 0}: This line checks if the entity named "comps" with the name "T_edges" exists. If it does not exist (the condition is true), the command*findedges1 elements 1 1 0 0 0is executed. This command finds edges based on the elements in mark set 1 with various options specified. -
if {[hm_entityinfo exist comps T_edges] == 0} {*setvalue comps name=^edges name= T_edges}: This line checks if the entity named "comps" with the name "T_edges" exists. If it does not exist (the condition is true), the command*setvalue comps name=^edges name=T_edgesis executed. This changes the name of the "comps" entity to "T_edges". -
*createmark components 1 "T_edges": This command creates a mark set 1 containing the components (groups of elements) that have the name "T_edges". This mark set will include the components that were previously assigned the name "T_edges" using the*setvaluecommand. -
*setvalue comps mark=1 color=#00B0F0: This command sets the mark value of the components in mark set 1 to 1 and their color to #00B0F0 (a shade of blue). -
*setcomponentdisplayattributes "T_edges" 2 1: This command sets the display attributes of the components in mark set 1 with the name "T_edges". The components will be displayed with a color index of 2 and a display representation of 1. -
*createmark elements 1 "displayed": This command creates a mark set 1 containing the elements that are currently displayed. This is done again to update the mark set after finding and modifying the T_edges. -
*equivalence elements 1 0.01 3 0 0: This command performs equivalence on the elements in mark set 1. It merges nodes within a distance of 0.01 units. The equivalence is applied to all element types (specified by 3) and with no tolerance for angle and edge length (specified by 0 0). -
*createmark nodes 1 "retrieve": This command creates a mark set 1 containing nodes based on some criteria specified by the option "retrieve". The exact criteria for node selection are not mentioned in the code snippet. -
*nodemarkaddtempmark 1: This command adds a temporary mark to the nodes in mark set 1. Temporary marks are used to preserve the selection temporarily during the execution of the script.
These lines of code define the "edge" procedure and specify various operations on elements, components, and nodes. The code handles the creation and manipulation of marks, finding and modifying edges, setting display attributes, performing equivalence, and selecting nodes for further processing.
Other things to consider:
-
*clearmarkall 1: This command clears all the existing mark sets with mark number 1. -
proc edge {} {...}: This defines a procedure named "edge" with no arguments. The code inside the curly braces ({...}) represents the body of the procedure. -
The "edge" procedure contains the code for checking and creating free edges and T-edges in the model.
-
proc Del_edges {} {...}: This defines a procedure named "Del_edges" with no arguments. The code inside the curly braces ({...}) represents the body of the procedure. -
The "Del_edges" procedure contains the code for deleting the created edges.
-
set top .window: This line sets the variable "top" to the string ".window" which represents the name of the top-level window. -
catch {destroy $top}: This command catches any errors that occur during the destruction of the window specified by the variable "top". It prevents the program from terminating if the window doesn't exist. -
toplevel $top -class Toplevel: This creates a new top-level window with the name specified by the variable "top" and sets its class as "Toplevel". -
wm title $top "Edges Tools": This sets the title of the top-level window specified by the variable "top" as "Edges Tools". -
wm geometry $top 230x100+500+200: This sets the geometry (size and position) of the top-level window specified by the variable "top" to "230x100" pixels with the position "500+200" (x and y coordinates). -
wm resizable $top 0 0: This prevents the top-level window specified by the variable "top" from being resized. -
wm deiconify $top: This command makes the top-level window specified by the variable "top" visible and deiconified. -
wm attributes $top -topmost true: This sets the top-level window specified by the variable "top" to be always on top of other windows. -
button $top.01 -text "Check/Create the Free Edges" -command {edge}; place $top.01 -x 20 -y 20 -width 180: This line creates a button widget with the text "Check/Create the Free Edges" inside the top-level window specified by the variable "top". The button triggers the execution of the "edge" procedure when clicked. It is placed at coordinates (20, 20) within the window, and its width is set to 180 pixels. -
button $top.02 -text "Delete the created Edges" -command {Del_edges}; place $top.02 -x 20 -y 50 -width 180: This line creates another button widget with the text "Delete the created Edges" inside the top-level window specified by the variable "top". The button triggers the execution of the "Del_edges" procedure when clicked. It is placed at coordinates (20, 50) within the window, and its width is set to 180 pixels.
Overall, the code sets up a graphical user interface with two buttons that perform specific actions when clicked. The "Check/Create the Free Edges" button executes the "edge" procedure, and the "Delete the created Edges" button executes the "Del_edges" procedure.