Challenge

Week - 10 - Creating the midline and spot weld

Objective:-

Part A:

  • Create a macro to calculate the midline of a given tubular component
  • Select one end of the lines using line by path
  • Similarly, select the other ends using line by path option
  • Now calculate midline for each pair
  • Combine all these midlines to create a single midline.

Part B:

  • Create a macro to create spot welds
  • Select source nodes by the path from the user
  • Select target nodes by the path from the user
  • Create 1D spot welds for each node pair inappropriate component

 To create tcl for midlines and lines combine in part A and spotweld  for nodes-nodes

Problem statement:-

creation of midlines is okay but combining is somewhat tough. let's see the code and how it's working

Code 

set a .window
catch {destroy $a}
toplevel $a -class toplevel
wm title $a "Lines&1-1"
wm geometry $a 250x140+100+200

label $a.01 -text "Part-A" -bg grey -font {times 12 bold}; place $a.01 -x 10 -y 30 -width 100 -height 30

button $a.02 -text "Centerline" -command {Centerline} -bg green -font {times 12 bold}; place $a.02 -x 120 -y 30 -width 100 -height 30

label $a.03 -text "Part-B" -bg grey -font {times 12 bold}; place $a.03 -x 10 -y 70 -width 100 -height 30

button $a.04 -text "1-1 Rigids" -command {spotweld} -bg yellow -font {times 12 bold}; place $a.04 -x 120 -y 70 -width 100 -height 30

proc Centerline {} {
*createmark comps 1 "Centerline"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=Centerline
}
*createmark comps 1 "Centerline"
set compid [hm_getmark comps 1]
*clearmarkall 1
*clearmarkall 2
*createlistpanel lines 1 "select first lines"
set firstline [hm_getlist lines 1]
*createlistpanel lines 2 "select second lines"
set secondline [hm_getlist lines 2]
set k 1
foreach i $firstline j $secondline {
*clearmarkall 1;*clearmarkall 2;
*createlist lines 1 $i
*createlist nodes 1
*createlist lines 2 $j
*createlist nodes 2
*linescreatemidline 1 1 2 2
*clearmarkall 1;
*createmark lines 1 -1
set p [hm_getmark lines 1]
if {$k>1} {
*linecombine $p $p1 1
*clearmarkall 1;
*createmark lines 1 -1
set p1 [hm_getmark lines 1]
} else {
set p1 $p
}
incr k
}
}


proc spotweld {} {
*createlistbypathpanel nodes 1 "select source nodes"
set source [hm_getlist nodes 1]
*createlistbypathpanel nodes 2 "select destination nodes"
set destination [hm_getlist nodes 2]
*createentity comps name=Spotweld
*createmark comps 1 "Spotweld"
*elementtype 5 4
foreach s $source d $destination {
*rigid $s $d 123456
}
}

TCL command explanation:-

set a .window
catch {destroy $a}
toplevel $a -class toplevel
wm title $a "Lines&1-1"
wm geometry $a 250x140+100+200

label $a.01 -text "Part-A" -bg grey -font {times 12 bold}; place $a.01 -x 10 -y 30 -width 100 -height 30

button $a.02 -text "Centerline" -command {Centerline} -bg green -font {times 12 bold}; place $a.02 -x 120 -y 30 -width 100 -height 30

label $a.03 -text "Part-B" -bg grey -font {times 12 bold}; place $a.03 -x 10 -y 70 -width 100 -height 30

button $a.04 -text "1-1 Rigids" -command {spotweld} -bg yellow -font {times 12 bold}; place $a.04 -x 120 -y 70 -width 100 -height 30

creating a window with name Lines&1-1 and labels with part _A and B

buttons names with centre line and 1-1 Rigids with commands Centerline and spotweld creation

 

proc Centerline {} {
*createmark comps 1 "Centerline"
set id [hm_marklength comps 1]
if {$id!=1} {
*createentity comps name=Centerline
}
*createmark comps 1 "Centerline"
set compid [hm_getmark comps 1]
*clearmarkall 1
*clearmarkall 2
*createlistpanel lines 1 "select first lines"
set firstline [hm_getlist lines 1]
*createlistpanel lines 2 "select second lines"
set secondline [hm_getlist lines 2]
set k 1
foreach i $firstline j $secondline {
*clearmarkall 1;*clearmarkall 2;
*createlist lines 1 $i
*createlist nodes 1
*createlist lines 2 $j
*createlist nodes 2
*linescreatemidline 1 1 2 2
*clearmarkall 1;
*createmark lines 1 -1
set p [hm_getmark lines 1]
if {$k>1} {
*linecombine $p $p1 1
*clearmarkall 1;
*createmark lines 1 -1
set p1 [hm_getmark lines 1]
} else {
set p1 $p
}
incr k
}
}

creating centre line comp if exists, it will show error

after creating a centre line, the tool will ask to select lines as first-line and second lines

with the help of getting list command, it will save the  lines by the path and using these lines it will create a midline

with the help of the if loop it will save the line list and then combine the two lines

then it will save the line list id of created line and using the previous line it will create combined line output and goes on with increments

proc spotweld {} {
*createlistbypathpanel nodes 1 "select source nodes"
set source [hm_getlist nodes 1]
*createlistbypathpanel nodes 2 "select destination nodes"
set destination [hm_getlist nodes 2]
*createentity comps name=Spotweld
*createmark comps 1 "Spotweld"
*elementtype 5 4
foreach s $source d $destination {
*rigid $s $d 123456
}
}

here the procedure of spotweld follows

with the help of selecting source nodes and saving the nodes by list (hm_getlist nodes1)

selecting destination nodes and saving the nodes by list

creating components named spotweld

changing the element type to beam

using for loop for each node in source and destination it creates  beam using *rigid command (*rigid node1 node2 123456(dofs))

CONCLUSION:-

here the TCL of creating lines and 1-1 rigids are created with widget and shown below the screenshots

screenshots

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.