Script to get radii values in geometry and create beam sections based on radii.
hi,
i had created a script that could get the values of hole radii and create a beam section for each radii. Here's the script for the same.
but i am facing the error as below
Error:
Script:
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols includeid=0 name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
for {set k 0} {$k < $n} {incr k} {
set r [hm_holedetectiongetholedetails $k radius]
}
set j 1
for {set i 0} {$i < $n} {incr i} {
set rad [lindex $r $i]
*createentity beamsects includeid=$i name="beamsection_$j"
*setvalue beamsects id=$j sectiontype=60
*setvalue beamsects id=$j beamsect_dim1=$rad
incr j
}
hm_holedetectionend
i do not understand as to what i am doing wrong. Help is greatly appreciated.
Thanks,
Best Answer
-
Bhargav Panchal_20668 said:
No I am not using include files. the includeID in *createentity command is for the id of beamsectioncollector (here $bscid in above code) i have tried removing it and the code works fine but still the issue of rest of sections getting their default values instead of "hmcirc" and radius as hole radius instead of 10 persist
Also I have attached the hm file again in this post for your reference
The include id is definitely not the id of the beam section collector but the id of the include file in which you want the beam section collector and if that include file doesn't exist it just goes into the main model file. Hence the use of hm_getlatestentityid.
As far as the rest of the latest code I am still going through that but I have a version that works on my end.
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
puts "n: $n"
for {set i 0; set j 1} {$i < $n} {incr i; incr j} {
*createentity beamsects name="beamsection_$j"
*setvalue beamsects id=[hm_latestentityid beamsects] sectiontype=60
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[lindex [hm_holedetectiongetholedetails $i radius] 2]
}
hm_holedetectionendI also attached a file with the code but since attachments seem to be acting strange I copied it above too.
1
Answers
-
In your first for loop you are resetting r and not appending. See if this helps:
set n [hm_holedetectiongetnumberofholes]
set r {}
for {set k 0} {$k < $n} {incr k} {
lappend r [hm_holedetectiongetholedetails $k radius]
}
set j 1
for {set i 0} {$i < $n} {incr i} {
set rad [lindex $r $i]
*createentity beamsects includeid=$i name="beamsection_$j"
*setvalue beamsects id=$j sectiontype=60
*setvalue beamsects id=$j beamsect_dim1=$rad
incr j
}1 -
Ben Buchanan said:
In your first for loop you are resetting r and not appending. See if this helps:
set n [hm_holedetectiongetnumberofholes]
set r {}
for {set k 0} {$k < $n} {incr k} {
lappend r [hm_holedetectiongetholedetails $k radius]
}
set j 1
for {set i 0} {$i < $n} {incr i} {
set rad [lindex $r $i]
*createentity beamsects includeid=$i name="beamsection_$j"
*setvalue beamsects id=$j sectiontype=60
*setvalue beamsects id=$j beamsect_dim1=$rad
incr j
}Hi Ben,
Yes! that did help, appreciate your support.
Although i m still getting the error as below
And here's my script (slightly modified):
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols includeid=0 name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
set j 1
for {set i 0} {$i < $n} {incr i} {
*createentity beamsects includeid=$i name="beamsection_$j"
*startnotehistorystate {Modified Radius DIM1 of Beam Section}
*setvalue beamsects id=$i beamsect_dim1=[hm_holedetectiongetholedetails $i radius]
*endnotehistorystate {Modified Radius DIM1 of Beam Section}
*startnotehistorystate {Modified Section Type of Beam Section}
*setvalue beamsects id=$i sectiontype=60
*endnotehistorystate {Modified Section Type of Beam Section}
incr j
}
hm_holedetectionendIs the syntax wrong with line 4 of error log(ref image)?
Many thanks
0 -
Bhargav Panchal_20668 said:
Hi Ben,
Yes! that did help, appreciate your support.
Although i m still getting the error as below
And here's my script (slightly modified):
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols includeid=0 name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
set j 1
for {set i 0} {$i < $n} {incr i} {
*createentity beamsects includeid=$i name="beamsection_$j"
*startnotehistorystate {Modified Radius DIM1 of Beam Section}
*setvalue beamsects id=$i beamsect_dim1=[hm_holedetectiongetholedetails $i radius]
*endnotehistorystate {Modified Radius DIM1 of Beam Section}
*startnotehistorystate {Modified Section Type of Beam Section}
*setvalue beamsects id=$i sectiontype=60
*endnotehistorystate {Modified Section Type of Beam Section}
incr j
}
hm_holedetectionendIs the syntax wrong with line 4 of error log(ref image)?
Many thanks
In the *setvalue command the i is not the id of the beamsection, it is the id of the include file it which the beam section will reside. Try hm_latestentityid:
*createentity beamsects includeid=$i name="beamsection_$j"
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[hm_holedetectiongetholedetails $i radius]By the way you can remove all the *startnotehistorystate and *endnotehistorystate commands from your script as that is just part of the undo/redo functionality.
1 -
Ben Buchanan said:
In the *setvalue command the i is not the id of the beamsection, it is the id of the include file it which the beam section will reside. Try hm_latestentityid:
*createentity beamsects includeid=$i name="beamsection_$j"
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[hm_holedetectiongetholedetails $i radius]By the way you can remove all the *startnotehistorystate and *endnotehistorystate commands from your script as that is just part of the undo/redo functionality.
Hi,
I have modified the script by using hm_latestentityid as below
but i am still facing the same error as before :
And I am unable to get as to why is it not taking the id of include file in which the beam section will reside, as in previous case as well as this case both $i & [hm_latestentityid] should return an integer value.
Many Thanks,
0 -
Bhargav Panchal_20668 said:
Hi,
I have modified the script by using hm_latestentityid as below
but i am still facing the same error as before :
And I am unable to get as to why is it not taking the id of include file in which the beam section will reside, as in previous case as well as this case both $i & [hm_latestentityid] should return an integer value.
Many Thanks,
They both will give integers but they may not be giving the same integer. When modifying the beam section with setvalue you want to make sure you have the id of the beam section that you just created. Which hm_latestentityid get latest should do.
You can also use setvalue with names so you could try:
*setvalue beamsects name="beamsection_$j" beamsect_dim1=[hm_holedetectiongetholedetails $i radius]
to see what you get. Besides that nothing sticks out.
Is there a message in the bottom left message area when you get the error?
To further debug I would run the script with some puts statements like below. If that doesn't shed some light on the problem, then run commands in the console individually to see if it works that way or to see that happens.
*createentity beamsects includeid=$i name="beamsection_$j"
puts "id: [hm_latestentityid beamsects] radius: [hm_holedetectiongetholedetails $i radius]
*setvalue beamsects id=$i beamsect_dim1=[hm_holedetectiongetholedetails $i radius]Once you get the id and radius output you can check to see if those are the numbers you were expecting then try running the setvalue command in the console with those numbers to see if that works.
1 -
Ben Buchanan said:
They both will give integers but they may not be giving the same integer. When modifying the beam section with setvalue you want to make sure you have the id of the beam section that you just created. Which hm_latestentityid get latest should do.
You can also use setvalue with names so you could try:
*setvalue beamsects name="beamsection_$j" beamsect_dim1=[hm_holedetectiongetholedetails $i radius]
to see what you get. Besides that nothing sticks out.
Is there a message in the bottom left message area when you get the error?
To further debug I would run the script with some puts statements like below. If that doesn't shed some light on the problem, then run commands in the console individually to see if it works that way or to see that happens.
*createentity beamsects includeid=$i name="beamsection_$j"
puts "id: [hm_latestentityid beamsects] radius: [hm_holedetectiongetholedetails $i radius]
*setvalue beamsects id=$i beamsect_dim1=[hm_holedetectiongetholedetails $i radius]Once you get the id and radius output you can check to see if those are the numbers you were expecting then try running the setvalue command in the console with those numbers to see if that works.
Guess I should have done this earlier but I just check the help for hm_holedetectiongetholedetails and it looks like the use is a little different then what you are doing.
Looks like you need to do something like this:
set curHoleData [hm_holedetectiongetholedetails $i]
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[lindex $curHoldeData 2]
1 -
Ben Buchanan said:
They both will give integers but they may not be giving the same integer. When modifying the beam section with setvalue you want to make sure you have the id of the beam section that you just created. Which hm_latestentityid get latest should do.
You can also use setvalue with names so you could try:
*setvalue beamsects name="beamsection_$j" beamsect_dim1=[hm_holedetectiongetholedetails $i radius]
to see what you get. Besides that nothing sticks out.
Is there a message in the bottom left message area when you get the error?
To further debug I would run the script with some puts statements like below. If that doesn't shed some light on the problem, then run commands in the console individually to see if it works that way or to see that happens.
*createentity beamsects includeid=$i name="beamsection_$j"
puts "id: [hm_latestentityid beamsects] radius: [hm_holedetectiongetholedetails $i radius]
*setvalue beamsects id=$i beamsect_dim1=[hm_holedetectiongetholedetails $i radius]Once you get the id and radius output you can check to see if those are the numbers you were expecting then try running the setvalue command in the console with those numbers to see if that works.
great, thanks for all your help. but replacing include id by beamsects name="beamsection_$" didn't help either. i guess i could rename the beamsections with the dimensions of holes and then update the radii manually at the very least
0 -
Bhargav Panchal_20668 said:
great, thanks for all your help. but replacing include id by beamsects name="beamsection_$" didn't help either. i guess i could rename the beamsections with the dimensions of holes and then update the radii manually at the very least
I am going to see if I can find a model and test on my end. We must be close to getting it to work.
One other thought I had, have you looked into the connector functionality to see if there is something there that might help you?
https://help.altair.com/hwdesktop/hwx/topics/pre_processing/connectors/connectors.htm
0 -
Ben Buchanan said:
I am going to see if I can find a model and test on my end. We must be close to getting it to work.
One other thought I had, have you looked into the connector functionality to see if there is something there that might help you?
https://help.altair.com/hwdesktop/hwx/topics/pre_processing/connectors/connectors.htm
yes I have! I have found that bolts can be created automatically by using attachments ( rigid spiders) & connect attachments as below:
By providing appropriate settings to the connector configuration file for attachments and connect attachments it is possible to get different properties for each bolt elements(CBAR) which can by manipulated after running existing script where beamsections are assigned.
I have also gone over the altair help pages for *beamsectionsetdatastandard, *beamsectionsetdataroot, *createdouble array (commands used when beam section is created via hyperbeam).
what i have observed (& i may be wrong) is that *setvalue beamsects id=1 beamsect_dim1=8 command is created in the command file when beam section is edited manually via entity editor window, maybe this doesn't work when used with variable substitution
whereas following set of code is created while using hyperbeam
*beamsectioncreatestandardsolver 11 0 "HMCirc" 0
*beamsectionsetdataroot 1 1 0 2 7 1 0 1 1 0 0 0 0
*createdoublearray 3 53 10 10
*beamsectionsetdatastandard 1 3 1 11 0 "HMCirc"
*createmark beamsects 1 "circle_section.1"
*updatehmdb beamsects 1so i guess i should be trying to solve the issue with this approach
i have uploaded the .hm (Ver2022.2) file for your reference
0 -
Bhargav Panchal_20668 said:
yes I have! I have found that bolts can be created automatically by using attachments ( rigid spiders) & connect attachments as below:
By providing appropriate settings to the connector configuration file for attachments and connect attachments it is possible to get different properties for each bolt elements(CBAR) which can by manipulated after running existing script where beamsections are assigned.
I have also gone over the altair help pages for *beamsectionsetdatastandard, *beamsectionsetdataroot, *createdouble array (commands used when beam section is created via hyperbeam).
what i have observed (& i may be wrong) is that *setvalue beamsects id=1 beamsect_dim1=8 command is created in the command file when beam section is edited manually via entity editor window, maybe this doesn't work when used with variable substitution
whereas following set of code is created while using hyperbeam
*beamsectioncreatestandardsolver 11 0 "HMCirc" 0
*beamsectionsetdataroot 1 1 0 2 7 1 0 1 1 0 0 0 0
*createdoublearray 3 53 10 10
*beamsectionsetdatastandard 1 3 1 11 0 "HMCirc"
*createmark beamsects 1 "circle_section.1"
*updatehmdb beamsects 1so i guess i should be trying to solve the issue with this approach
i have uploaded the .hm (Ver2022.2) file for your reference
but somehow it only updates the the first entity on the list (snap provided as attachment) and beamsection names and radii values got jumbled up somehow
also i have observed that the rest of the sections in the lists have been assigned default values of radius and section config
i have changed the code as below:
set bscid [hm_latestentityid beamsectcols]
incr bscid
*createentity beamsectcols includeid=$bscid name="PBar"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
set j 1
for {set i 0} {$i < $n} {incr i} {
set curHoleData [hm_holedetectiongetholedetails $i]
set roundoffval [lindex $curHoleData 2]
set finalroundoff [format "%0.1f" $roundoffval]
*beamsectioncreatestandardsolver 11 0 "HMCirc" 0
*beamsectionsetdataroot 1 1 0 2 7 1 0 1 1 0 0 0 0
*createdoublearray 3 $finalroundoff 10 10
*beamsectionsetdatastandard 1 3 1 11 0 "HMCirc"
*createmark beamsects 1 "circle_section.$j"
*updatehmdb beamsects 1
*renamecollector beamsects "circle_section.$j" "PBar_Rad_$finalroundoff"
*clearmarkall 1
incr j
}
hm_holedetectionend0 -
Bhargav Panchal_20668 said:
but somehow it only updates the the first entity on the list (snap provided as attachment) and beamsection names and radii values got jumbled up somehow
also i have observed that the rest of the sections in the lists have been assigned default values of radius and section config
i have changed the code as below:
set bscid [hm_latestentityid beamsectcols]
incr bscid
*createentity beamsectcols includeid=$bscid name="PBar"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
set j 1
for {set i 0} {$i < $n} {incr i} {
set curHoleData [hm_holedetectiongetholedetails $i]
set roundoffval [lindex $curHoleData 2]
set finalroundoff [format "%0.1f" $roundoffval]
*beamsectioncreatestandardsolver 11 0 "HMCirc" 0
*beamsectionsetdataroot 1 1 0 2 7 1 0 1 1 0 0 0 0
*createdoublearray 3 $finalroundoff 10 10
*beamsectionsetdatastandard 1 3 1 11 0 "HMCirc"
*createmark beamsects 1 "circle_section.$j"
*updatehmdb beamsects 1
*renamecollector beamsects "circle_section.$j" "PBar_Rad_$finalroundoff"
*clearmarkall 1
incr j
}
hm_holedetectionendAre you using include files? If not I would not even include the include id in the createentity command. That will remove one variable so we can try and get to the bottom of what is going on. Something like this:
*createentity beamsectcols name="PBar"
Also, where did you post your hm? I don't see it?
0 -
No I am not using include files. the includeID in *createentity command is for the id of beamsectioncollector (here $bscid in above code) i have tried removing it and the code works fine but still the issue of rest of sections getting their default values instead of "hmcirc" and radius as hole radius instead of 10 persistBen Buchanan said:Are you using include files? If not I would not even include the include id in the createentity command. That will remove one variable so we can try and get to the bottom of what is going on. Something like this:
*createentity beamsectcols name="PBar"
Also, where did you post your hm? I don't see it?
Also I have attached the hm file again in this post for your reference
0 -
Bhargav Panchal_20668 said:
No I am not using include files. the includeID in *createentity command is for the id of beamsectioncollector (here $bscid in above code) i have tried removing it and the code works fine but still the issue of rest of sections getting their default values instead of "hmcirc" and radius as hole radius instead of 10 persist
Also I have attached the hm file again in this post for your reference
The include id is definitely not the id of the beam section collector but the id of the include file in which you want the beam section collector and if that include file doesn't exist it just goes into the main model file. Hence the use of hm_getlatestentityid.
As far as the rest of the latest code I am still going through that but I have a version that works on my end.
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
puts "n: $n"
for {set i 0; set j 1} {$i < $n} {incr i; incr j} {
*createentity beamsects name="beamsection_$j"
*setvalue beamsects id=[hm_latestentityid beamsects] sectiontype=60
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[lindex [hm_holedetectiongetholedetails $i radius] 2]
}
hm_holedetectionendI also attached a file with the code but since attachments seem to be acting strange I copied it above too.
1 -
Ben Buchanan said:
The include id is definitely not the id of the beam section collector but the id of the include file in which you want the beam section collector and if that include file doesn't exist it just goes into the main model file. Hence the use of hm_getlatestentityid.
As far as the rest of the latest code I am still going through that but I have a version that works on my end.
*clearmarkall 1
*clearmarkall 2
*createentity beamsectcols name="beamsectcol1"
hm_holedetectioninit
*createmarkpanel surfaces 1
hm_holedetectionsetentities surfs 1
hm_holedetectionsetholeparams hole_shape=31
hm_holedetectionfindholes 1
set n [hm_holedetectiongetnumberofholes]
puts "n: $n"
for {set i 0; set j 1} {$i < $n} {incr i; incr j} {
*createentity beamsects name="beamsection_$j"
*setvalue beamsects id=[hm_latestentityid beamsects] sectiontype=60
*setvalue beamsects id=[hm_latestentityid beamsects] beamsect_dim1=[lindex [hm_holedetectiongetholedetails $i radius] 2]
}
hm_holedetectionendI also attached a file with the code but since attachments seem to be acting strange I copied it above too.
hi Ben i have tested the code on my end and it is working flawlessly in latest version as well. thanks a ton once again for all your help and support
i have also made few tweaks to the existing code such as adding new components and properties and assigning them properties and beam sections etc
i guess i was stuck at *setvalue command, but thanks again anyways. cheers!
0 -
Bhargav Panchal_20668 said:
hi Ben i have tested the code on my end and it is working flawlessly in latest version as well. thanks a ton once again for all your help and support
i have also made few tweaks to the existing code such as adding new components and properties and assigning them properties and beam sections etc
i guess i was stuck at *setvalue command, but thanks again anyways. cheers!
Your welcome. The setvalue command is really powerful so hopefully this helped you understand it more so you can use it a lot in the future.
0