TCL script *createmark problems
Hello,
I have a tcl script that uploads an FEM using ossmooth into hypermesh. Then two shrinkwraps are applied on the new iso-surface and the resulting mesh is exported as an stl file. The problem is when I call my script from the command prompt; hypermesh fails to locate elements by their property id. When I run the script in the hypermesh console no errors occur. Can anyone help me determine what is causing this strange behavior?
The string sent to the command prompt is written as:
'C:\Program Files\Altair\2019\hm\bin\win64\hmopengl.exe' -tcl 'C:/Users/Eric/Documents/script.tcl'
I cannot post the model because of work reasons. The script is below, the path names need to be updated with local file names:
#the property id to locate design elements
set design_id 23
#the voxel size for shrink wrap
set wrap_size 0.0500000000
# .fem file path
set fem_name 'temp_name'
# shape file results
set sh_name 'temp_sh_name'
# the stl output path
set stl_name 'tmp_stl'
#upload the file for fea re-anlalysis
*createstringarray 2 'isosurf: 3 3 0.500000 0 -1 0 0 10 30 1 0' 'other_params: 1 0 0 0 10 0'
if { [ catch {*ossmooth_12 0 1 0 1 $fem_name $sh_name '' 1 0 1 2} ] } {
puts 'Error Extracting ISO-Surface...'
}
#mask all
puts 'Creating New Component'
#create a new compoenet for the shrinkwrap
set comp_name_1 'component1_lattice_wrap1'
*createentity comps includeid=0 name=$comp_name_1
puts 'Applying Shrinkwrap 1'
#do the shrink wrap on the displayed elements
*currentcollector components $comp_name_1
#
# Script Error from command prompt
#
*createmark elems 1 'by property id' $design_id
#
# Script Error
#
*shrinkwrapmesh elements 1 2 $wrap_size 30 3 0 0 0 0 0 0
puts 'Applying Shrinkwrap 2'
#make another component for the second wrap
set comp_name_2 'component1_lattice_wrap2'
*createentity comps includeid=0 name=$comp_name_2
*currentcollector components $comp_name_2
*createmark elems 1 'by component name' $comp_name_1
*shrinkwrapmesh elements 1 2 $wrap_size 30 3 0 0 0 0 0 0
#divide the elems into triangles
*createmark elems 1 'by component name' $comp_name_2
*splitelements 22 1
#export to STL into the predefined path
puts 'Printing the STL file'
*createmark elems 1 'by component name' $comp_name_2
*createstringarray 2 'CONNECTORS_SKIP' 'HMMATCOMMENTS_XML'
hm_answernext yes
*feoutputwithdata 'C:/Program Files/Altair/2019/templates/feoutput/misc/triasto.stl' $stl_name 0 0 0 1 2
Thank you,
-Eric
Find more posts tagged with
What are you referring to as the solver? is it hypermesh? My script is called from the command prompt (using MATLAB). Hypermesh opens and I see the script perform the first part of my code but fails when trying to locate the elements via property id. At this point I debug my script with the opened hypermesh gui and properties cannot be marked for some reason.
I am unable to share my model because it is confidential.
Here is a sample of the model with the elements attached to the property. Only some of the elements, the materials and properties are in the file.
Thanks
I tried the same commands but elements are not marked. Try this script using the command prompt to see if it works on your version:
#tcl scipt for the shrink wrapping automation
set design_id 23
set wrap_size 0.0500000000
#upload the file for fea re-anlalysis
*createstringarray 2 'isosurf: 3 3 0.500000 0 -1 0 0 10 30 1 0' 'other_params: 1 0 0 0 10 0'
if { [ catch {*ossmooth_12 0 1 0 1 'C:/Users/Eric/Documents/debug_fem.fem' 'C:/Users/Eric/Documents/file.sh' '' 1 0 1 2} ] } {
puts 'Error Extracting ISO-Surface...'
}
#mask all
puts 'Creating New Component'
#create a new compoenet for the shrinkwrap
set comp_name_1 'component1_lattice_wrap1'
*createentity comps includeid=0 name=$comp_name_1
puts 'Applying Shrinkwrap 1'
#do the shrink wrap on the displayed elements
*currentcollector components $comp_name_1
*createmark elems 1 'by property id' $design_id
*shrinkwrapmesh elements 1 2 $wrap_size 30 3 0 0 0 0 0 0
puts 'Applying Shrinkwrap 2'
*createmark elems 1 'by property name' 'PSOLID_2.3'
hm_getmark elems 1
<?xml version="1.0" encoding="UTF-8"?>
I was able to fix my problem by doing two things at the beginning of my script:
1. Change my directory to the location of my hmsettings.tcl settings.
cd <path to folder>
2. Change the user preferences from hypermesh to optistruct.
*elementchecksettings 6 0 0 1 1 6 0 6 0 6 6 6 0 0 0 0 0 0 0 0 0 0 0
*entitybundleregister '__AUTOCONTACT_PREVIEW_BUNDLE_OPTISTRUCT' 'groups groups contactsurfs contactsurfs sets sets' 0
*templatefileset 'C:/Program Files/Altair/2019/templates/feoutput/optistruct/optistruct'
*setmacrofile 'C:/Program Files/Altair/2019/hm/scripts/UserProfiles/../optistruct/opti.mac'
*enablemacromenu 1
*createmark collections 1
*clearmark collections 1
*createmark collections 2
*clearmark collections 2
*createmark controllers 1
*clearmark controllers 1
*loaddefaultattributevaluesfromxml
i believe this is related to the use of solver_id vs internal_id.
HM has an internal ID associated to the properties that might not be the same as your solver id.
This happens because for some particular solvers and models, there might be another material/property sharing the same ID as your main property/ material.
Probably an example would be failure models in ax explicit model.
So, If you open your model and do something like this:
*createmarkpanel props 1
set prop_id [hm_getmark props 1]
It will return the internal ID of the property selected.
In order to get the solver ID, you need a command such as:
hm_getsolverid props 1
or on the other hand, having the solver_id you might use:
hm_getinternalid 'two_idpool' 1000 'bypoolname'
In my example below, i've created 2 props and manually changed their IDs through the browser, so that the solver IDs are 1000 and 2000.
But you can see that internally they have ids 1 and 2.
<?xml version="1.0" encoding="UTF-8"?>