Challenge

Week - 8 - Creating component and property

Objective:

Creation of a macro for creating component and property.

Problem statement:

When we are working on large models we everytime need to create componenets,properties and then we need to assign thickness to therespective component, manually doing this will be a tedious process .So the solution we have currently in industry is that , they will be creating a file having dummy components and dummy properties assigned to it.Once after the meshing is done, this file is exported and then the dummy names are to be replaced with the actual component names byy using the find and replace option in text editor. But this is also not a tidy solution. So we need to have a macro which will ask the user enter the componen name first and once after that it will ask for thickness of component .Once we enter these details then a componenet with the name which the user entered will be created along with a property which having the same name as the new component created and thickness also will be assigned with it and it wuill be assigned to the componenet as well.And this process should not be depend upon on the solver in which the user is working.So componenet creation, property assigning everything should be done by the code itself depending upon the profile the user is in.

Code:

set n [ hm_getstring "components =" "Enter the name" ]
set t [ hm_getstring "thickness=" "Enter the value of the thickness" ]

set sol [hm_getsolver id]

if { $sol == 1 } {
proc optistruct { name t } {

*createentity comps includeid=0 name=$name$t
*createmark comps 1 $name$t
set compid [ hm_getmark comps 1 ]
*createentity props cardimage=PSHELL includeid=0 name=$name$t
*createmark props 2 $name$t
set propid [ hm_getmark props 2 ]
*setvalue props id=$propid STATUS=1 95=$t
*setvalue comps id=$compid propertyid={props $propid}

}
puts [ optistruct $n $t ]
}

if { $sol == 20 } {

proc radioss { name t } {

*createentity comps cardimage=Part includeid=0 name= $name$t
*createmark comps 1 $name$t
set compid [hm_getmark comps 1 ]
*createentity props cardimage=P1_SHELL includeid=0 name=$name$t
*createmark props 1 $name$t
set propid [hm_getmark props 1 ]
*setvalue props id=$propid STATUS=1 431=$t
*setvalue comps id=$compid propertyid={props $propid}


}
puts [ radioss $n $t ]
}

set n [ hm_getstring "components =" "Enter the name" ]
set t [ hm_getstring "thickness=" "Enter the value of the thickness" ]

set sol [hm_getsolver id]

if { $sol == 1 } {
proc optistruct { name t } {

*createentity comps includeid=0 name=$name$t
*createmark comps 1 $name$t
set compid [ hm_getmark comps 1 ]
*createentity props cardimage=PSHELL includeid=0 name=$name$t
*createmark props 2 $name$t
set propid [ hm_getmark props 2 ]
*setvalue props id=$propid STATUS=1 95=$t
*setvalue comps id=$compid propertyid={props $propid}

}
puts [ optistruct $n $t ]
}

if { $sol == 20 } {

proc radioss { name t } {

*createentity comps cardimage=Part includeid=0 name= $name$t
*createmark comps 1 $name$t
set compid [hm_getmark comps 1 ]
*createentity props cardimage=P1_SHELL includeid=0 name=$name$t
*createmark props 1 $name$t
set propid [hm_getmark props 1 ]
*setvalue props id=$propid STATUS=1 431=$t
*setvalue comps id=$compid propertyid={props $propid}


}
puts [ radioss $n $t ]
}

By entering the above tcl code for creating the macros, the command window is shown as shown in below fig.

The above fig shows to enter the name of the component which is asked by the user. EX:fender

After entering the name for the component as shown in the above fig.Now it will ask the how much of thickness is to assigned say as 5.

After given the name of the component and thickness, in the tree filter we can observed that a component named as fender is created and

assigned a thickness of 5 as shown.

Conclusion:

Thus, i have created a component and assigned the thickness to it for makeing the job easier in a significant manner.

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.