Challenge

Week - 8 - Creating component and property

OBJECTIVE

  • To create a macro 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 the deck, the code should decide, whether a property needs to be created or not.

CODE

Here I have written the code to run for two profiles Radioss and optistruct in two different functions

  • The component is created using *createentity comp with a name that user has entered in entry GUI
  • similarly, the property is created using (*createentity prop)
  • The thickness of the individual property is set using (*setvalue props ) command with the user-defined thickness
  • now the updated property is assigned to the respective component using (*propertyupdate )
  • Then in order to create components based on the profile I have implemented if condition which is assigned to button named (create) in GUI
set ::c_name {}
set ::T {}
proc optistruct {} {
*createentity comps includeid=0 name= $::c_name 
set prop  $::c_name
append prop _$::T 
*createentity props cardimage=PSHELL includeid=0 name=$prop
*setvalue props name=$prop STATUS=1 95=$::T
*createmark components 1 "$::c_name"
*propertyupdate components 1 "$prop"
}
proc radioss {} {
*createentity comps cardimage=Part includeid=0 name=$::c_name
set prop  $::c_name
append prop _$::T 
*createentity props cardimage=P1_SHELL includeid=0 name=$prop
*setvalue props name=$prop STATUS=1 431=$::T
*createmark components 1 "$::c_name"
*propertyupdate components 1 "$prop"
}
proc create {} {
set a1 radioss
set b1 optistruct
set c1 [hm_info templatetype]
if {$a1==$c1} {
radioss
} else {
optistruct
}
}
set a .component_info
catch {destroy $a}
toplevel $a
wm geometry $a 600x60+200+200
wm resizable $a 0 0
wm deiconify $a
label $a.01 -text "Component_name" -bg "grey" 
place $a.01 -x 10 -y 10 -width 100 -height 40
entry $a.02 -textvariable ::c_name
place $a.02 -x 120 -y 10 -width 140 -height 40
label $a.03 -text "Thickness" -bg "grey" 
place $a.03 -x 270 -y 10 -width 100 -height 40
entry $a.04 -textvariable ::T
place $a.04 -x 380 -y 10 -width 140 -height 40
button $a.1 -text "Create" -bg "green" -command create
place $a.1 -x 530 -y 10 -width 60 -height 40
​
GUI
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.