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 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…
Akash M
updated on 07 Dec 2021
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 and moved to the desired collector.
Create a macro that asks a .csv file as input and reads nodes from the file provided and also create tags for text in first column.
Create a macro that accepts a geometric component as input from the user and shows potential duplicate geometries ( Geometries that match the surface count)
Code:
1.Connector
proc connectors {} {
set a .connectors
catch {destroy $a}
toplevel $a -class TopLevel
wm title $a "Connectors"
wm geometry $a 200x250+100+50; update
wm resizable $a 0 0
wm deiconify $a
button $a.01 -text "Create collectors" -command {create} -bg white -font {times 10 bold}; place $a.01 -x 20 -y 20 -width 150 -height 30
button $a.02 -text "Welds" -command {weld} -bg white -font {times 10 bold}; place $a.02 -x 20 -y 70 -width 150 -height 30
button $a.03 -text "X Locator" -command {X_loc} -bg white -font {times 10 bold}; place $a.03 -x 20 -y 110 -width 150 -height 30
button $a.04 -text "Y Locator" -command {Y_loc} -bg white -font {times 10 bold}; place $a.04 -x 20 -y 150 -width 150 -height 30
button $a.05 -text "Z Locator" -command {Z_loc} -bg white -font {times 10 bold}; place $a.05 -x 20 -y 190 -width 150 -height 30
proc create {} {
*clearmarkall 1
*clearmarkall 2
*createmark comps 1 welds; if {[hm_marklength comps 1] == 0} {*createentity components name=welds color=3}
*createmark comps 1 X_loc; if {[hm_marklength comps 1] == 0} {*createentity components name=X_loc color=5}
*createmark comps 1 Y_loc; if {[hm_marklength comps 1] == 0} {*createentity components name=Y_loc color=6}
*createmark comps 1 Z_loc; if {[hm_marklength comps 1] == 0} {*createentity components name=Z_loc color=56}
}
proc weld {} {
*clearmarkall 1
*clearmarkall 2
*currentcollector components "welds"
*createmarkpanel nodes 1 "Select the nodes for spider weld"
*rigidlinkinodecalandcreate 1 0 0 123456
}
proc X_loc {} {
*clearmarkall 1
*clearmarkall 2
*currentcollector components "X_loc"
*createmarkpanel nodes 1 "Select source nodes for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target nodes for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 156
}
proc Y_loc {} {
*clearmarkall 1
*clearmarkall 2
*currentcollector components "Y_loc"
*createmarkpanel nodes 1 "Select source nodes for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target nodes for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 246
}
proc Z_loc {} {
*clearmarkall 1
*clearmarkall 2
*currentcollector components "Z_loc"
*createmarkpanel nodes 1 "Select source nodes for spot weld"
set source_node [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select target nodes for spot weld"
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 345
}
}
connectors;
2.Reading nodes from a file
proc write_nodes {} {
*clearmarkall 1
*clearmarkall 2
*createlistpanel nodes 1
set nodelist [hm_getlist nodes 1]
set filechannelid [open write_nodes w]
foreach i $nodelist {
set info [hm_nodevalue $i]
puts $filechannelid [lindex $info 0]
}
close $filechannelid
}
write_nodes
proc read_nodes {} {
set filename [tk_getOpenFile -title "Select node info file"]
set fileChannelId [open $filename r]
while {[eof $fileChannelId] == 0} {
puts [set lst_nodeCord [gets $fileChannelId]]
*createnode [lindex $lst_nodeCord 0] [lindex $lst_nodeCord 1] [lindex $lst_nodeCord 2];
}
close $fileChannelId
}
read_nodes;
3.Identical comp identifier
proc identify {} {
*clearmarkall 1; *clearmarkall 2;
# List of all components
*createmark comps 1 "all"
set all_comp [hm_getmark comps 1];
*clearmarkall 1; *clearmarkall 2;
# List of all surfaces
foreach i $all_comp {
*createmark surfaces 1 "by collector" $i
lappend all_comp_surf [hm_marklength surfaces 1]
}
*clearmarkall 1; *clearmarkall 2;
# Input components
*createmarkpanel comps 2 "Select the geometric components of interest"
set target_comp [hm_getmark comp 2]
*isolateentitybymark 2
puts "Target comp id $target_comp"
*clearmarkall 1; *clearmarkall 2;
*createmark surfaces 2 "by collector" $target_comp
puts [set target_comp_surf [hm_marklength surfaces 2]]
*clearmarkall 1; *clearmarkall 2;
set match_list_surf [lsearch -all $all_comp_surf $target_comp_surf]
puts "Match list surfaces $match_list_surf"
foreach j $match_list_surf {
*clearmarkall 1
set compid [lindex $all_comp $j]
set comp_name [hm_entityinfo name components $compid]
*displaycollectorwithfilter components "on" "$comp_name" 0 1
}
}
identify;
Procedure and code explanation:
1.Connector
Procedures are created for weld and x, y, z locators.
*clearmarkall command is used to clear the entities stored in a particular mark.
Create components for weld and x,y, z locators. *createentity command is used to create components
Weld, x_loc, y_loc, z_loc components are created.
We have to create spider weld and spot weld. In oreder to create welds, create different procedures for weld, x, y, z locators.
To create welds on a current components *currentcollector command is used.
*createmarkpanel nodes 1 is used to select the nodes by nodes panel for weld.
*rigidlinkinodecalandcreate 1 0 0 123456 command is used to create rbe2 elements for the selected nodes ans 123456 are degrees of freedom.
Using this same method create procedures for x, y, z locators and change the digrees of freedom as per the locators.
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 "Connectors" is the command that is used to create title of the window.
wm geometry $a 200x250+100+50 is the command that is used to create dimension of the window. 200x250 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.
We have to create buttons for 'create collectors', 'welds', 'x locator', 'y locator', 'z locator'. The syntax for create button is button $windowpath -text "text" -command {something}; place $windowpath -x value -y value -width value - height value.
2.Reading nodes from a file
Set the filename that we need to open. Foe that tk_getOpenFile is used which will show the open window and will ask the user to select the file having the nodes information.
Then set the file channel by opening the file in read mode.
Using gets command the file will be read by the code and the data in it will be set to the variable and the data will be dispayed in the command window and the node will be highlighted with temp nodes.
3.Identical comp identifier
This will show identical or same surface count components.
Create a selection of all components in a model and get surface count for each components by using the command "hm_marklength".
*craetemarkpanel command is used to select the component by the user.
The surafce count for the target component was calculated by command
lsearch -all $all_comp_surf $target_comp_surf is the command used to identify the same surface component.
Matchecd components lisi was saved in a seperated variable and the variavle contains a position of the matched variable
For each varible, a component was identified and isolated.
Conclusion:
Sucessfully created macro for creating connectors by using tk widget and also created macro for identify the same component and also for reading nodes from a file.
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
127 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.