All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: To create a macro that performs checking element qualities Objective: To Create element quality check macro for 2D and 3D element Create a tk widget for each criteria, On pressing the button the elements should be highlighted using temp nodes Entry boxes next to…
Akash M
updated on 05 Dec 2021
Aim:
To create a macro that performs checking element qualities
Objective:
To Create element quality check macro for 2D and 3D element
Create a tk widget for each criteria, On pressing the button the elements should be highlighted using temp nodes
Entry boxes next to the buttons will accept the quality criteria value
Code:
set a .window
catch {destroy $a}
toplevel $a -class TopLevel
wm title $a "Quality Check"
wm geometry $a 330x885+100+50; update
wm resizable $a 0 0
wm deiconify $a
label $a.01 -text "2D Elements Quality Check" -bg grey -font {times 10 bold}; place $a.01 -x 0 -y 0 -width 315 -height 50
button $a.02 -text "Min length" -command {min_length $min_l} -bg white -font {times 10}; place $a.02 -x 05 -y 55 -width 150 -height 50
button $a.03 -text "Max length" -command {max_length $max_l} -bg white -font {times 10}; place $a.03 -x 05 -y 110 -width 150 -height 50
button $a.04 -text "Warpage" -command {warpage $w} -bg white -font {times 10}; place $a.04 -x 05 -y 165 -width 150 -height 50
button $a.05 -text "Skew" -command {skew $s} -bg white -font {times 10}; place $a.05 -x 05 -y 220 -width 150 -height 50
button $a.06 -text "Aspect" -command {aspect $as} -bg white -font {times 10}; place $a.06 -x 05 -y 275 -width 150 -height 50
button $a.07 -text "Jacobian" -command {jacobian $j} -bg white -font {times 10}; place $a.07 -x 05 -y 330 -width 150 -height 50
button $a.08 -text "Min quad angle" -command {min_quad_angle $min_qa} -bg white -font {times 10}; place $a.08 -x 05 -y 385 -width 150 -height 50
button $a.09 -text "Max quad angle" -command {max_quad_angle $max_qa} -bg white -font {times 10}; place $a.09 -x 05 -y 440 -width 150 -height 50
button $a.10 -text "Min tria angle" -command {min_tria_angle $min_ta} -bg white -font {times 10}; place $a.10 -x 05 -y 495 -width 150 -height 50
button $a.11 -text "Max tria angle" -command {max_tria_angle $max_ta} -bg white -font {times 10}; place $a.11 -x 05 -y 550 -width 150 -height 50
entry $a.12 -textvariable min_l -bg white -font {times 10}; place $a.12 -x 165 -y 55 -width 150 -height 50
entry $a.13 -textvariable max_l -bg white -font {times 10}; place $a.13 -x 165 -y 110 -width 150 -height 50
entry $a.14 -textvariable w -bg white -font {times 10}; place $a.14 -x 165 -y 165 -width 150 -height 50
entry $a.15 -textvariable s -bg white -font {times 10}; place $a.15 -x 165 -y 220 -width 150 -height 50
entry $a.16 -textvariable as -bg white -font {times 10}; place $a.16 -x 165 -y 275 -width 150 -height 50
entry $a.17 -textvariable j -bg white -font {times 10}; place $a.17 -x 165 -y 330 -width 150 -height 50
entry $a.18 -textvariable min_qa -bg white -font {times 10}; place $a.18 -x 165 -y 385 -width 150 -height 50
entry $a.19 -textvariable max_qa -bg white -font {times 10}; place $a.19 -x 165 -y 440 -width 150 -height 50
entry $a.20 -textvariable min_ta -bg white -font {times 10}; place $a.20 -x 165 -y 495 -width 150 -height 50
entry $a.21 -textvariable max_ta -bg white -font {times 10}; place $a.21 -x 165 -y 550 -width 150 -height 50
label $a.22 -text "3D Elements Quality Check" -bg grey -font {times 10 bold}; place $a.22 -x 0 -y 605 -width 315 -height 50
button $a.23 -text "Warpage" -command {warpage_3d $war} -bg white -font {times 10}; place $a.23 -x 05 -y 660 -width 150 -height 50
button $a.24 -text "Tetra collapse" -command {tetcollapse $tet} -bg white -font {times 10}; place $a.24 -x 05 -y 715 -width 150 -height 50
button $a.25 -text "Volume skew " -command {volumeskew $vs} -bg white -font {times 10}; place $a.25 -x 05 -y 770 -width 150 -height 50
entry $a.26 -textvariable war -bg white -font {times 10}; place $a.26 -x 165 -y 660 -width 150 -height 50
entry $a.27 -textvariable tet -bg white -font {times 10}; place $a.27 -x 165 -y 715 -width 150 -height 50
entry $a.28 -textvariable vs -bg white -font {times 10}; place $a.28 -x 165 -y 770 -width 150 -height 50
button $a.29 -text "Clear nodes" -command {clear} -bg yellow -font {times 10}; place $a.29 -x 80 -y 825 -width 150 -height 50
proc min_length {min_l} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $min_l 2 1 2 0 " 2D Min Length "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc max_length {max_l} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestlength elements 1 $max_l 2 0 2 0 " 2D Max Length "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc warpage {w} {
*nodecleartempmark
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $w 2 2 0 " 2D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc skew {s} {
*nodecleartempmark
*nodecleartempmark
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestskew elements 1 $s 2 2 0 " 2D Skew "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc aspect {as} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestaspect elements 1 $as 2 2 0 " 2D Aspect Ratio "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc jacobian {j} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestjacobian elements 1 $j 2 2 0 " 2D Jacobian "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc min_quad_angle {min_qa} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $min_qa 0 2 1 2 0 " 2D Quad Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc max_quad_angle {max_qa} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $max_qa 0 2 0 2 0 " 2D Quad Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc min_tria_angle {min_ta} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $min_ta 1 2 1 2 0 " 2D Tria Min Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc max_tria_angle {max_ta} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestinterangle elements 1 $max_ta 1 2 0 2 0 " 2D Tria Max Angle "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc warpage_3d {war} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestwarpage elements 1 $war 2 4 0 " 3D Warpage "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc tetcollapse {tet} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtesttetracollapse elements 1 $tet 2 0 " 3D Tetra Collapse "
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc volumeskew {vs} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtestvolumetricskew elements 1 $vs 2 0 " 3D Volumetric Skew "
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
proc clear {} {
*nodecleartempmark
}
Procedure and code explanation:
Create mark for all the dispayed elements ans use element test command for respected quality criteria and save failed elements on seperate mark id.
Mask the marked elements and reverse the masked elements to get failed elements on display.
Create temp node for displayed nodes and and unmask all the elements and now you will be able to see the failed elemnts marked by temp nodes. *nodemarkaddtempmark 1 is used to add those temp nodes.
Create various procedure in the names of different quality checks for 2D and 3D elements and assign these procedures in different tk wiget buttons. This button will execute various quality check.
proc quality {value} {
*nodecleartempmark
*createmark elements 1 "displayed"
*elementtest(quality) entity_type mark_id $value output_mark_id dimension contour " title" (change as per quality type)
*maskentitymark elements 2 0
*maskreverse elements
*createmark nodes 1 "displayed"
*nodemarkaddtempmark 1
*unmaskall2
}
*nodecleartempmark - clear all the existing temp nodes mark_id $value output_mark_id dimension contour title
*createmark elements 1 "displayed" - store all the displayed elements to mark id 1.
*elementtestlength elements 1 $max_l 2 0 2 0 " 2D Max Length " - to check minimum and maximum length for 2D elements by giving respective value. $max_l is the user input value.
*elementtestwarpage elements 1 $w 2 2 0 " 2D Warpage " - to check warpage for 2D elements by giving respective value. $w is the user input value.
*elementtestskew elements 1 $s 2 2 0 " 2D Skew " - to check skewness for 2D elements by giving respective value. $s is the user input.
*elementtestaspect elements 1 $as 2 2 0 " 2D Aspect Ratio " - to check aspect ratio for 2D elements by giving respective value. $as is the user input.
*elementtestjacobian elements 1 $j 2 2 0 " 2D Jacobian " - to check jacobian for 2D elements by giving respective value. $j is the user input.
*elementtestinterangle elements 1 $min_qa 0 2 1 2 0 " 2D Quad Min Angle " - to check minimum quad angle for 2D elements by giving respective value. $min_qa is the user input.
*elementtestinterangle elements 1 $max_qa 0 2 0 2 0 " 2D Quad Max Angle " - to check maximum quad angle for 2D elements by giving respective value. $max_qa is the user input.
*elementtestinterangle elements 1 $min_ta 1 2 1 2 0 " 2D Tria Min Angle " - to check minimum tria angle for 2D elements by giving respective value. $min_ta is the user input.
*elementtestinterangle elements 1 $max_ta 1 2 0 2 0 " 2D Tria Max Angle " - to check maximum tria angle for 2D elements by giving respective value. $max_ta is the user input.
*elementtestwarpage elements 1 $war 2 4 0 " 3D Warpage " - to check warpage for 3D elements by giving respective value. $war is the user input value.
*elementtesttetracollapse elements 1 $tet 2 0 " 3D Tetra Collapse " - to check tetra collapse for 3D elements by giving respective value. $tet is the user input value.
*elementtestvolumetricskew elements 1 $vs 2 0 " 3D Volumetric Skew " - to check volumetric skew for 3D elements by giving respective value. $vs is the user input value.
*maskentitymark elements 2 0 - mask the failed elemnts stored in a mark id 2
*createmark nodes 1 "displayed" - store the failed elements( displayed elemnts since we mask those elemnts) nodes to mark id 2
*nodemarkaddtempmark 1 - add temp nodes to those failed elements
*unmaskall2 - unmask all the elements
set a .window is the command. .window is the window name or path by which it will be referred saved in.
catch {destroy $a} is the command where catch is used to hide errors and destroy is used to close any previously existing window by same name.
toplevel $a -class TopLevel is the command that builds the window.
wm title $a "Quality Check" is the command that is used to create title of the window.
wm geometry $a 330x885+100+50is the command that is used to create dimension of the window. 330x885 is width and height of the window. +100+50 is the origin of the hypermesh window where the windoe shoud be placed.
wm resizable $a 0 0 is the command that is used to fix the window means we can not resize the window by dragging. If you put 1 0, you can drag or resize the window on x axix, if you put 0 1, you can drag or resize it on y axix and if you put 1 1, you can drag and resize on both axis.
wm deiconify $a is the command that is used to make the window as active window.
And then we have to create two label "2D Elements Quality Check" and "3D Elements Quality Check". The syntax for create label is label $windowpath -text "Label" -bg grey -font {times 20 bold} ; place $windowpath -x value -y value -width value -height value. Using this syntax labels is created.
We have to create two buttons for all the quality ckecks. The syntax for create button is button $windowpath -text "text" -command {something}; place $windowpath -x value -y value -width value - height value. Command would be the user inputs for quality check.
We have to create entry box to give input values. The syntax for create entry box is entry $windoepath -textvariable "::var" place $windowpath -x value -y value -width value -height value. Textvariable should be the variable assigned to a command.
To run this code on hypermesh, open hyper mesh and go to preference and go to keyboard setting. Now, you can create your own shortcut key to run this file by uploading the tcl file into any keyboard button.
When you run this file new window will open. This is the window we created for adding and subtracting two numbers.
Output:
conclusion:
Sucessfully created a macro that performs quality check. Also created tk widget with entry boxes and buttons which will creates temp nodes on failing elements.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project - 2 - Generating the report for hypermesh file
Aim: To generate the report for hypermesh file Objective: To create an ergonomic and visually appealing excel (.xlsm) report that contains following information about your model: User name, date, time Profile/deck; count of component, prop, material, elements Count of empty comp/prop/mats Elements…
20 Dec 2021 07:48 AM IST
Project 1- Building a Master TCL/TK Macro
Aim: To create a master TCL/TK macro that performs several operations such as finding and correcting normals, final checks, creating components, reflecting geometry, creating connections and identify identical components. Objective: It should contain buttons that will call all utilities created as assignments during…
10 Dec 2021 05:13 AM IST
Week - 9 - Reflecting the geometry
Aim: To create a code that performs reflecting the geometry Objective: Create a macro that will reflect given multicomponent FE part with ease It should be independent of deck The inputs should be original CAD comp, reflected CAD comp and original FE comps …
07 Dec 2021 03:01 PM IST
Week - 12 - Creating the locator, writing and reading the node data
Aim: To create a code that performs connections, identify the identical components and reading nodes from a file. Objective: Create a macro that builds a GUI containing 4 buttons. Component creator, weld, xloc, yloc, zloc. Upon pressing the buttons corresponding 1D element must be created…
07 Dec 2021 12:35 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.