Loop FOR for meshing n geometries
Hello everyone, I'm Matthieu and I'm new here.
I'm currently using Hypermesh to mesh a lot of CATParts with one or more modified parameters. With Catia i built a CATVBA to iterate the parameter, and export it.
I would like to do the same with hypermesh, using volume tetra command: import, mesh, save, delete.
The file I built is attached. But I can't get it to work. It always says "::tcl_puts ?-nonnewline? ?channel1Id? string"
If I don't use the closed brace at the first line for the for loop it does exactly what I whant for the first file, i.e i=1. All my Catparts are properly arranged.
Thanks for any help&time. I also put my TCL code down there in case some don't want do download file.
Matthieu
for {set i 1} {$i < 10} {incr i} {
puts
*createmark collections 1
*clearmark collections 1
*createmark collections 2
*clearmark collections 2
*createmark controllers 1
*clearmark controllers 1
*loaddefaultattributevaluesfromxml
*start_batch_import 3
*setgeomrefinelevel 1
*geomimport "auto_detect" "G:/Matthieu/file8.CATPart" "CleanupTol=-0.01" "CreationType=Parts" "DoNotMergeEdges=off" "ImportBlanked=off" "SplitComponents=Part" "TargetUnits=CAD units"
*end_batch_import
*drawlistresetstyle
*createstringarray 3 "pars: post_cln tet_clps='0.100000,0.300000,0.500000,1.000000,0.505000,0.100000'" \
"tet: 99 1.3 -1 0 0.8 0" "2d: 1 0 1 0.01 0.0005 30 1"
*createmark solids 1 1
*tetmesh solids 1 0 elements 0 -1 1 3
*writefile "G:/Matthieu/LOOPé$i.hm" 1
*startnotehistorystate {Deleted Component "auto001"}
*createmark components 1
*clearmark components 1
*createmark components 1 "auto001"
*deletemark components 1
*endnotehistorystate {Deleted Component "auto001"}
*startnotehistorystate {Deleted Component "Part1"}
*createmark components 1
*clearmark components 1
*createmark components 1 "Part1"
*deletemark components 1
*endnotehistorystate {Deleted Component "Part1"}}
Find more posts tagged with
Thanks a lot, it works nicely now. I saw online on tcl tutorials that for each FOR loops a puts has to be created.. thanks again
'puts' command is just a command for writting data to the screen or to a file, similar to 'printf' in C.
it is not mandatory to use it.
Usually we include it to quickly debug tcl codes, printing variables for example to the tcl console.
Hey,
Now that the script works, i would like to reflect my meshing with a plane defined by 3 nodes. It works well when i do it by hand, but when I go with script, it creates this kind of horrible meshing.. Here is the code I use directly after the tetmesh
*createmark elements 1 2757-24056
*duplicatemark elements 1 1
*createmark elements 1 24057-45356
*createplane 1 -0.40824829 -0.40824829 0 -0.320710678 -0.179289322 -0.5
*reflectmarkwithoption elements 1 1 0
I only used the command.tcl file and took this part of the script
If someone has an idea how to have a good reflect with script! Thanks again for any help
Hey,
Now that the script works, i would like to reflect my meshing with a plane defined by 3 nodes. It works well when i do it by hand, but when I go with script, it creates this kind of horrible meshing.. Here is the code I use directly after the tetmesh
*createmark elements 1 2757-24056
*duplicatemark elements 1 1
*createmark elements 1 24057-45356
*createplane 1 -0.40824829 -0.40824829 0 -0.320710678 -0.179289322 -0.5
*reflectmarkwithoption elements 1 1 0I only used the command.tcl file and took this part of the script
If someone has an idea how to have a good reflect with script! Thanks again for any help
Generally you don't want to use ids in creating your marks in a script unless you are doing something to ensure they are going to be those ids because the ids could be different each time a mesh is created. This appears to be what is happening here, not all the elements are getting selected.
I would suggest using something like:
hm_createmark elems 1 "by comp" <comp id>
Then after the duplicate the elements are already on the mark so you can skip the second createmark and just do the reflect.
Hey thanks a lot for your help. I have tried to select the component for the reason you explained but it wasn't possible to duplicate the comp using the subpanel.
So, i just used an amout of elements that is high compared to the biggest geometry I have. It isn't very future proof
Here is the sript for the symmetries
#SYM1
*createmark elements 1 1-2000000
*duplicatemark elements 1 0
*createplane 1 -0.707106781 -0.707106781 0 -0.5 0 0
*reflectmarkwithoption elements 1 1 0
#SYM2
*createmark elements 1 1-2000000
*duplicatemark elements 1 1
*createplane 1 -0.19245009 0.19245009 0 0 0 -0.5
*reflectmarkwithoption elements 1 1 0
#EQUIVALENCE
*createmark elements 1 "all"
*equivalence elements 1 0.0001 1 0 0
It works without the previous issues but isn't very elegant
I used the createmark elems by comp in this way, was that the way you thought about ?
*createmark elems 1 "by comp" <auto001>
*duplicatemark elements 1 0
*createplane 1 -0.707106781 -0.707106781 0 -0.5 0 0
*reflectmarkwithoption elements 1 1 0
But it keeps saying to me that no elements have been selected.
Same if I use reflect component *createmark components 1 "auto001"
Thanks again for your quick help,
Matthieu
Hey thanks a lot for your help. I have tried to select the component for the reason you explained but it wasn't possible to duplicate the comp using the subpanel.
So, i just used an amout of elements that is high compared to the biggest geometry I have. It isn't very future proof
Here is the sript for the symmetries
#SYM1
*createmark elements 1 1-2000000
*duplicatemark elements 1 0
*createplane 1 -0.707106781 -0.707106781 0 -0.5 0 0
*reflectmarkwithoption elements 1 1 0#SYM2
*createmark elements 1 1-2000000
*duplicatemark elements 1 1
*createplane 1 -0.19245009 0.19245009 0 0 0 -0.5
*reflectmarkwithoption elements 1 1 0#EQUIVALENCE
*createmark elements 1 "all"
*equivalence elements 1 0.0001 1 0 0It works without the previous issues but isn't very elegant
I used the createmark elems by comp in this way, was that the way you thought about ?
*createmark elems 1 "by comp" <auto001>
*duplicatemark elements 1 0
*createplane 1 -0.707106781 -0.707106781 0 -0.5 0 0
*reflectmarkwithoption elements 1 1 0But it keeps saying to me that no elements have been selected.
Same if I use reflect component *createmark components 1 "auto001"
Thanks again for your quick help,
Matthieu
Sorry for the confusion do not use <>. If you use id just put the number there and if you use name, like you are doing, use double quotes.
I think if you just remove the puts statement on the second line you should be good.
I think if you just remove the puts statement on the second line you should be good.