Find more posts tagged with
Here's the script found on Altair site:
#-------------------------------------------------------------------------------------------- #This script deletes assemblies recursively, optionally comps will be deleted # steenbock@altair.de, 20141008 # V. 01 #-------------------------------------------------------------------------------------------- proc run {} { *clearmarkall 1 *createmarkpanel assems 1 'select assems 2 delete' #delete comps or not set answer [tk_dialog .owd 'Selected Assems: [hm_getmark assems 1]' 'Delete Components in Assems?' 'question' 0 'No' 'Yes' 'Cancel'] switch $answer { 0 {set delComps 0} 1 {set delComps 1} 2 {tk_messageBox -message 'Misson abort!' -type ok -icon warning; return;} } # loop whole assem tree foreach ass [hm_getmark assems 1] { deleteSubAssems $ass $delComps } *clearmarkall 1 } proc deleteSubAssems {assem delComps} { set output 1 if {[hm_entityinfo exist assem $assem] == 1} { set sub_ass [hm_getentityarray assemblies $assem assemblies] # part where comps will be deleted if {$delComps != 0} { set sub_comps [hm_getentityarray assemblies $assem components] if {[llength $sub_comps] > 0} { eval *createmark comps 1 $sub_comps if {$output ==1} {puts '\t\tdelete comps: $sub_comps'} *deletemark comps 1 } } # delete assem *createmark assems 1 $assem if {$output==1} {puts '\tdelete assem id=$assem ([hm_getentityvalue assemblies $assem name 1])'} *deletemark assems 1 if {[llength $sub_ass] > 0} { foreach a $sub_ass { deleteSubAssems $a $delComps } } } } #----------------------------------------------- run
Here's the script found on Altair site:
#-------------------------------------------------------------------------------------------- #This script deletes assemblies recursively, optionally comps will be deleted # steenbock@altair.de, 20141008 # V. 01 #-------------------------------------------------------------------------------------------- proc run {} { *clearmarkall 1 *createmarkpanel assems 1 'select assems 2 delete' #delete comps or not set answer [tk_dialog .owd 'Selected Assems: [hm_getmark assems 1]' 'Delete Components in Assems?' 'question' 0 'No' 'Yes' 'Cancel'] switch $answer { 0 {set delComps 0} 1 {set delComps 1} 2 {tk_messageBox -message 'Misson abort!' -type ok -icon warning; return;} } # loop whole assem tree foreach ass [hm_getmark assems 1] { deleteSubAssems $ass $delComps } *clearmarkall 1 } proc deleteSubAssems {assem delComps} { set output 1 if {[hm_entityinfo exist assem $assem] == 1} { set sub_ass [hm_getentityarray assemblies $assem assemblies] # part where comps will be deleted if {$delComps != 0} { set sub_comps [hm_getentityarray assemblies $assem components] if {[llength $sub_comps] > 0} { eval *createmark comps 1 $sub_comps if {$output ==1} {puts '\t\tdelete comps: $sub_comps'} *deletemark comps 1 } } # delete assem *createmark assems 1 $assem if {$output==1} {puts '\tdelete assem id=$assem ([hm_getentityvalue assemblies $assem name 1])'} *deletemark assems 1 if {[llength $sub_ass] > 0} { foreach a $sub_ass { deleteSubAssems $a $delComps } } } } #----------------------------------------------- run
this script is not working
Hi , If I want to delete all load collectors, load step along with empty and unused entity .which loop/command I need to use or command.
currently, I ma using below command for deleting empty comp.
proc cleanModel {n type} {
*EntityPreview$n $type 1
while {[hm_marklength $type 1] != 0} {
*deletemark $type 1
*EntityPreview$n $type 1
}
}
cleanModel Empty comps
cleanModel Unused props
cleanModel Unused mats
cleanModel Empty sets
cleanModel Empty assembly
you can use the following script
to delete empty components
*createmark comps 1 "all"
hm_getunusedoremptyentities mode=empty type=comps inputmark=1 outputmark=2
*deletemark comps 2
to delete unused property
*createmark prop 1 "all"
hm_getunusedoremptyentities mode=unused type=prop inputmark=1 outputmark=2
*deletemark prop 2
to delete unused assemblies
createmark assy 1 "all"
hm_getunusedoremptyentities mode=empty type=assy inputmark=1 outputmark=2
*deletemark assy 2
Will tell the logic, try to do yourself and let us know if you still need help.
EntityPreviewEmpty will check the empty assemblies in your model. Use this API and while loop to check and delete the empty assemblies
use deletemark to delete the entities.
Check this to understand how while loop works https://www.tutorialspoint.com/tcl-tk/tcl_while_loop.htm