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
Answers
-
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.
0 -
Thank you for the reply.
I am still having issues. When I type in the line:
hm_getsolverid props 1
I receive this error message:
hm_getsolverid: pool name not found.
If I use the line:
hm_getsolverids props 1
Then i get an output:
{1 {}}
What does this mean?
0 -
what solver are you using?
it should return you the solverid and the idpool
can you provide some sample model?
0 -
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.
0 -
what about using property name instead of property ID?
It would bypass this confusion.
something like
*createmark elems 1 'by property name' 'SOME_NAME'
0 -
After trying to use the property name, I am still unable to mark properties or by using properties. Hypermesh can only mark with 'all' for the properties. Any other ideas?
0 -
I can't see what is the ouput from your last command.
the correct sentece should be your last one:
*createmark elems 1 'by property name' 'PSOLID_2.2'
hm_getmark elems 1
Just making sure: your property is correctly assigned to your elements in this case?
0 -
Here is the full output again, I am sure that the elements are attached to the property. I was able to select the property with hm_getmark and then delete it. Is there a way to find the elements attached to the property id using the property mark?
0 -
can't you send just one part of your model to try? maybe isolating the component that has the PSOLID_2.2 property.
0 -
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
0 -
-
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"?>
0 -
-
Could you please try using dos?
Type a line like this:
'C:\Program Files\Altair\2019\hm\bin\win64\hmopengl.exe' -tcl 'C:/Users/Eric/Documents/script.tcl'
My problems occur when running the sript from dos/system/ command prompt/run...
Thanks,
0 -
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
*loaddefaultattributevaluesfromxml0