Challenge

Week - 8 - Creating component and property

  1. set a [hm_getstring "components =" "Enter the name of the component"]: This line prompts the user to enter the name of a component and stores the input in the variable a using the hm_getstring function. The prompt message is "Please Enter the name of component =".

  2. set b [hm_getstring "Thickness =" "Enter the value of thickness"]: This line prompts the user to enter the thickness value and stores the input in the variable b using the hm_getstring function. The prompt message is "Thickness =".

  3. set sol [hm_getsolver id]: This line retrieves the solver ID using the hm_getsolver function and stores it in the variable sol.

  4. if {$sol==1} {: This line starts an if statement, checking if the solver ID is equal to 1.

  5. proc optistruct {n t} {: This line defines a procedure named "optistruct" with two arguments n and t.

  6. *createentity comps includeid=0 name=$n$t: This command creates a component entity with the name formed by concatenating the values of n and t.

  7. *createmark comps 1 $n$t: This command creates a mark set 1 containing the components with the name formed by concatenating the values of n and t.

  8. set compsid [hm_getmark comps 1]: This line retrieves the component ID from the mark set created in the previous line and stores it in the variable compsid.

  9. *createentity props cardimage=PSHELL includeid=0 name=$n$t: This command creates a property entity of type "PSHELL" with the name formed by concatenating the values of n and t.

  10. *createmark props 1 $n$t: This command creates a mark set 1 containing the properties with the name formed by concatenating the values of n and t.

  11. set propsid [hm_getmark props 1]: This line retrieves the property ID from the mark set created in the previous line and stores it in the variable propsid.

  12. *setvalue props id=$propsid STATUS=1 95=$t: This command sets the value of the "STATUS" and "95" attributes of the property entity identified by propsid.

  13. *setvalue comp id=$compsid propertyid={props $propsid}: This command associates the component identified by compsid with the property identified by propsid.

  14. puts [optistruct $a $b]: This line calls the "optistruct" procedure with the values of a and b as arguments, and the result is printed.

  15. }: This line marks the end of the if statement.

  16. if {$sol==20} {: This line starts another if statement, checking if the solver ID is equal to 20.

  17. proc radioss {n t} {: This line defines a procedure named "radioss" with two arguments n and t.

  18. *createentity comps includeid=0 name=$n$t: This command creates a component entity with the name formed by concatenating the values of n and t.

  19. *createmark comps 1 $n$t: This command creates a mark set 1 containing the components with the name formed by concatenating the values of n and t.

  20. set compsid [hm_getmark comps 1]: This line retrieves the component ID from the mark set created in the previous line and stores it in the variable compsid.

  21. *createentity props cardimage=P1_SHELL includeid=0 name=$n$t: This command creates a property entity of type "P1_SHELL" with the name formed by concatenating the values of n and t.

  22. *createmark props 1 $n$t: This command creates a mark set 1 containing the properties with the name formed by concatenating the values of n and t.

  23. set propsid [hm_getmark props 1]: This line retrieves the property ID from the mark set created in the previous line and stores it in the variable propsid.

  24. *setvalue props id=$propsid STATUS=1 431=$t: This command sets the value of the "STATUS" and "431" attributes of the property entity identified by propsid.

  25. *setvalue comp id=$compsid propertyid={props $propsid}: This command associates the component identified by compsid with the property identified by propsid.

  26. puts [radioss $a $b]: This line calls the "radioss" procedure with the values of a and b as arguments, and the result is printed.

  27. }: This line marks the end of the if statement.

These lines of code handle user input, execute different procedures based on the solver ID, create entities (components and properties), associate components with properties, and print the results. The specific procedures "optistruct" and "radioss" perform different operations depending on the solver ID and the provided arguments.

This optistruct procedure creates a component and property in HyperMesh for optiStruct solver. Let's break down each line and explain its purpose:

*createentity comps includeid=0 name=$n$t

This line creates a component entity in HyperMesh with the name formed by concatenating n and t variables. The name=$n$t argument assigns the generated name to the component.

*createmark comps 1 $n$t set compsid [hm_getmark comps 1]

These two lines create a mark on the previously created component entity and retrieve the mark ID using hm_getmark. The mark ID is stored in the compsid variable and will be used later to reference the component.

*createentity props cardimage=PSHELL includeid=0 name=$n$t *createmark props 1 $n$t set propsid [hm_getmark props 1]

These lines create a property entity of type PSHELL (a thin shell property) in HyperMesh. Similar to the component creation, it assigns a name formed by concatenating n and t to the property. A mark is placed on the created property entity, and the mark ID is retrieved and stored in the propsid variable.

*setvalue props id=$propsid STATUS=1 95=$t

This line sets the value of the STATUS attribute of the property to 1, indicating that the property is active. Additionally, it sets the value of attribute 95 (which represents the thickness) to the value stored in the variable t.

*setvalue comp id=$compsid propertyid={props $propsid}

This line associates the component with the property by setting the propertyid attribute of the component to the ID of the created property entity. The component ID is specified using the compsid variable, and the property ID is specified as {props $propsid} to reference the created property.

Overall, this optistruct procedure creates a component and a PSHELL property in HyperMesh, assigns the provided thickness value to the property, and associates the component with the property. This allows you to define the necessary properties for optiStruct analysis in HyperMesh.

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.