Week - 12 - Creating the locator, writing and reading the node data
Report week 12 Creating the locator, writing and reading the node data
Objective: finish creating the locator, writing and reading the node data task
Problem Statement:
- Connector :
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.
- Reading nodes from a file :
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.
- Identical comp identifier
Create a macro that accepts a geometric component as input from the user and shows potential duplicate geometries ( Geometries that match the surface count)
Tcl command explanation:
1.
set a .window
catch {destroy $a}
toplevel $a -class toplevel
wm title $a "Connector"
wm geometry $a 190x240+100+200
button $a.01 -text "Create Comps" -command "CreateComps" -bg grey -font {times 12 bold}; place $a.01 -x 20 -y 30 -width 150 -height 30
button $a.02 -text "Welds" -command "weldcreation" -bg grey -font {times 12 bold}; place $a.02 -x 20 -y 70 -width 150 -height 30
button $a.03 -text "X-Loc" -command "xloc" -bg grey -font {times 12 bold}; place $a.03 -x 20 -y 110 -width 150 -height 30
button $a.04 -text "Y-Loc" -command "yloc" -bg grey -font {times 12 bold}; place $a.04 -x 20 -y 150 -width 150 -height 30
button $a.05 -text "Z-Loc" -command "zloc" -bg grey -font {times 12 bold}; place $a.05 -x 20 -y 190 -width 150 -height 30
proc CreateComps {} {
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "Welds"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=Welds
}
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "X_Loc"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=X_Loc
}
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "Y_Loc"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=Y_Loc
}
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "Z_Loc"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=Z_Loc
}
}
proc weldcreation {} {
*clearmarkall 1;
*clearmarkall 2;
*currentcollector components "Welds"
*createmarkpanel nodes 2 "Select Nodes"
*rigidlinkinodecalandcreate 2 0 0 123456
}
proc xloc {} {
*clearmarkall 1;
*clearmarkall 2;
*currentcollector components "X_Loc"
*createmarkpanel nodes 1 "Select First Node - Independent Node"
set first [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select Second Node - Dependent Node"
set second [hm_getmark nodes 2]
*rigid $first $second 156
}
proc yloc {} {
*clearmarkall 1;
*clearmarkall 2;
*currentcollector components "Y_Loc"
*createmarkpanel nodes 1 "Select First Node - Independent Node"
set first [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select Second Node - Dependent Node"
set second [hm_getmark nodes 2]
*rigid $first $second 246
}
proc zloc {} {
*clearmarkall 1;
*clearmarkall 2;
*currentcollector components "Z_Loc"
*createmarkpanel nodes 1 "Select First Node - Independent Node"
set first [hm_getmark nodes 1]
*createmarkpanel nodes 2 "Select Second Node - Dependent Node"
set second [hm_getmark nodes 2]
*rigid $first $second 345
}
2.
proc read {} {
set filename [tk_getOpenFile -title "Select File"]
set fileid [open $filename r];
while {![eof $fileid]} {
set Coordinate [gets $fileid row]
if {$Coordinate > 0} {
set row [split $row ,];
set x [lindex $row 0]
set y [lindex $row 1]
set z [lindex $row 2]
*createnode $x $y $z
*createmark nodes 1 -1
set nid [hm_getmark nodes 1]
*tagcreate nodes $nid "$nid"
}
}
close $fileid;
}
read ;
3.
proc Cgeom {} {
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "a11"
set a11_comp [hm_getmark comps 1];
foreach i $a11_comp {
*createmark surfaces 1 "by co11ector" $i
lappend a11_comp_ surf [hm_marklength surfaces 1]
}
*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
}
}
Cgeom;
Conclusion:the task is finished by above code
