Challenge

Week - 8 - Creating component and property

Report week 8 Creating component and property

Objective: complete creating component and property task

Problem Statement:

  • Ask the user to enter name of a component and its thickness
  • Write a code that will automatically create components and assign thickness to it
  • The code should decide on its own what type of collector should be created depending on the user profile/deck.
  • According to deck the code should decide , whether a property needs to be created or not.
  • Auto color the created component and property

Tcl command explanation:

(create window)

set a .window
catch {destroy $a}
toplevel $a -class TopLevel

wm title $a "Create Component"
wm geometry $a 350x250+100+50; update
wm resizable $a 0 0
wm deiconify $a

(create buttons)

label $a.01 -text "Component" -bg grey -font {times 10 bold}; place $a.01 -x 20 -y 20 -width 150 -height 50
label $a.02 -text "Thickness" -bg grey -font {times 10 bold}; place $a.02 -x 20 -y 80 -width 150 -height 50
entry $a.03 -textvariable ::comp_name -bg white -font {times 10}; place $a.03 -x 180 -y 20 -width 150 -height 50
entry $a.04 -textvariable ::T_value -bg white -font {times 10}; place $a.04 -x 180 -y 80 -width 150 -height 50
button $a.05 -text "Create" -command {create} -font {times 10 bold}; place $a.05 -x 100 -y 140 -width 150 -height 50

set ::comp_name {}
set ::T_value {}

(optistruct function)

proc optistruct {} {
set opti [hm_getsolver]
if {$opti == "optistruct"} {
*createmark comps 1 $::comp_name
if {[hm_entityinfo exist comps $::comp_name]!=0} {
puts [tk_messageBox -message "The Component already exists" -icon warning -type ok -title Message]
} else {
*createentity comps cardimage=Part includeid=0 name=$::comp_name
*createmark components 1 $::comp_name
set compid [hm_getmark comps 1]
*createentity props cardimage=PSHELL includeid=0 name=$::comp_name
*createmark props 2 $::comp_name
set propid [hm_getmark props 2]
*setvalue props id=$propid STATUS=1 95=$::T_value;
*setvalue comps id=$compid propertyid={props $propid}
*createmark components 1 "all"
*autocolorwithmark components 1
*createmark properties 1 "all"
*autocolorwithmark properties 1
}
}
}

(radioss function)

proc radioss {} {
set radi [hm_getsolver]
if {$radi == "radioss"} {
*createmark comps 1 $::comp_name
if {[hm_entityinfo exist comps $::comp_name]!=0} {
puts [tk_messageBox -message "The Component already exists" -icon warning -type ok -title Message]
} else {
*createentity comps cardimage=Part includeid=0 name=$::comp_name
*createmark components 1 $::comp_name
set compid [hm_getmark comps 1]
*createentity props cardimage=P1_SHELL includeid=0 name=$::comp_name
*createmark props 2 $::comp_name
set propid [hm_getmark props 2]
*setvalue props id=$propid STATUS=1 431=$::T_value;
*setvalue comps id=$compid propertyid={props $propid}
*createmark components 1 "all"
*autocolorwithmark components 1
*createmark properties 1 "all"
*autocolorwithmark properties 1
}
}
}

(create function)
proc create {} {
optistruct
radioss
}

Conclusion: the task is completed with above code

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.