Week - 12 - Creating the locator, writing and reading the node data
Aim:
To creat a macro for creating diffrent type of connector, Reading nodes of .csv file and identify identical components.
Procedure:
Connector like weld, xloc, yloc, zloc
proc connector () {
set top .connector
catch {destroy $top}
toplevel $top -class TopLevel
wm geometry $top 250x280+5+10; update
wm title $top "Connectors"
wm resizable $top 0 0
wm deiconify $top
# Buttons
buttons $top.01 -text "Create collectors" -command {create} -font {times 12 bold}; place $top.01 -x 65 -y 10 -width 120 -height 40
buttons $top.02 -text "Welds" -command {weld} -font {times 12 bold}; place $top.02 -x 65 -y 60 -width 120 -height 40
buttons $top.03 -text "X Locator" -command {X_Loc} -font {times 12 bold}; place $top.03 -x 65 -y 110 -width 120 -height 40
buttons $top.04 -text "Y Locator" -command {Y_Loc} -font {times 12 bold}; place $top.04 -x 65 -y 160 -width 120 -height 40
buttons $top.05 -text "Z Locator" -command {Z_Loc} -font {times 12 bold}; place $top.05 -x 65 -y 210 -width 120 -height 40
}
Proc create {} {
*clearmarka11 1; *clearmarka11 2;
*creatmark component 1 welds; if {[hm_marklength components 1] == 0} {*createentity component name=welds color=3}
*creatmark component 1 X_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=X_Loc color=56}
*creatmark component 1 Y_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=Y_Loc color=5}
*creatmark component 1 Z_Loc; if {[hm_marklength components 1] == 0} {*createentity component name=Z_Loc color=6}
}
proc weld {} {
*clearmarka11 1; *clearmarka11 2;
*currentcollector components “welds”
*createmarkpanel nodes 2 “Select a1l nodes for creating spider we1d”
*rigidlinkinodecalandcreate 2 0 0 123456
}
proc X_Loc {} {
*clearmarka11 1; *clearmaka11 2;
*currentco11ector components “X_Loc”
*createmarkpane1 nodes 1 “Select source node for spot weld”
set source_node [hm_getmark nodes 1]
*createmarkpane1 nodes 2 “Select target node for spot weld”
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 156
}
proc Y_Loc {} {
*clearmarka11 1; *clearmaka11 2;
*currentco11ector components “Y_Loc”
*createmarkpane1 nodes 1 “Select source node for spot weld”
set source_node [hm_getmark nodes 1]
*createmarkpane1 nodes 2 “Select target node for spot weld”
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 246
}
proc Z_Loc {} {
*clearmarka11 1; *clearmaka11 2;
*currentco11ector components “Z_Loc”
*createmarkpane1 nodes 1 “Select source node for spot weld”
set source_node [hm_getmark nodes 1]
*createmarkpane1 nodes 2 “Select target node for spot weld”
set target_node [hm_getmark nodes 2]
*rigid $source_node $target_node 246
}
connector;
Reading nodes from a file
proc read_nodes {} {
set filename [tk_getOpenFile -title "Select note info file"]
set fileChanne1Id [open $filename r]
while {[eof $fileChanne1Id] == 0} {
puts [set 1st_nodeCord [gets $fileChannelId]]
*createnode [1index $1st_nodeCord 0] [1index $1st_nodeCord 1] [1index $1st_nodeCord 2];
}
close $fileChannelId
}
read_nodes;
Identical comp identifie
Proc find {} {
*clearmarka11 1; *clearmarka11 2;
# list of all comps
*createmark comps 1 "a11"
set a11_comp [hm_getmark comps 1];
# list of a11 surfaces
foreach i $a11_comp {
*createmark surfaces 1 "by co11ector" $i
lappend a11_comp_ surf [hm_marklength surfaces 1]
}
# Input component
*createmarkpanel comps 2 "Select the geometric component of interest"
set target_comp [hm_getmark comp 2]
*isolateentitybymark 2
puts "Target comp id $target_comp"
*creatmark surfaces 2 "by collector" $target_comp
puts [set target_comp_surf [hm_marklength surfaces 2]]
set match_list_surf [1search -a1l $a11_comp_surf $target_comp_surf]
puts "Match list surface $match_list_surf"
foreach j $match_list_surf {
set compid [1index $a11_comp $j]
set comp_name [hm_entityinfo name components $compid]
*displaycollectorwithfilter components "on" "$comp_name" 0 1
}
}
find;
* I have attached the macro below for all the three cases
Conclusion:
This macro made CAE Engineer work life easier.