Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello Experts,
Can you please help me to get a code for identify suppressed parts and delete them from assembly?
i am using visual studio 2017 for VB API. I am struggling since a long for this. your help will really make me move forward and would really be appreciated for your inputs.
Thank you in advanced!!
Hi
when searching the keywords "visit component VB API" in the knowledge base you will find this article that looks close to your request: https://www.ptc.com/en/support/article/CS172949
Maybe you can start from there.
Instead of testing
If (subComponents.Item(i).Status = EpfcFeatureStatus.EpfcFEAT_ACTIVE
Try and find the "Suppressed" Status in the API wizard.
I don't work with VB, only C and Tcl, here some thoughts, ouput and code in Tcl.
Note: there a couple of reason why a feature may suppressed, I delete only the suppressed ones, not the ones suppressed by Pro/Program or other reasons.
# Simple proc to export text
# to debug and the user log
proc ToMessLog {msg} {
Debug $msg
ps_mess $msg
}
proc DelSuppComp {} {
# Get the current Model Name for output purpose only
set CurModel [ps_model current]
ToMessLog "Run Delete Suppressed Components in Assembly '$CurModel'"
# First get all components from the active Assembyl
# Order First to Last created (like in Creo)
set CompIDsFL [ps_visit type COMPONENT]
# reverse the order from '10 34 55' to '55 34 10'
# without doing this, a component may already deleted
set CompIDs [lreverse $CompIDsFL]
# Get the Status for each ID
# Do this for all ID, else we would need to do this within the foreach loop
set CompStats [ps_feat status $CompIDs]
# Note: Both lists (CompStats and CompIDs) have now the same amount of items
# Just a counter
set DelComp 0
foreach CompID $CompIDs CompStat $CompStats {
switch $CompStat {
SUPPRESSED {
set NumOfChild [llength [ps_feat children $CompID]]
# On feature delete you can specify this options in a list:
# NONE, CLIP, INTERACTIVE, RELATION_DELETE, RELATION_COMMENT, CLIP_ALL, OUT_OF_GROUP, CLIP_OUT_OF_GROUP, or KEEP_EMBED_DATUMS
set option NONE
if {$NumOfChild != 0} {
ToMessLog "Component ID '$CompID' has suppressed feature as well"
set option CLIP
}
# Finally delete the Component and increment the counter
ToMessLog "Delete Component ID '$CompID' Name '[ps_assy component_name $CompID]' with option '$option'"
ps_feat delete -option $option -- $CompID
incr DelComp
}
default {
#Do nothing here
}
}
}
ToMessLog "Deleted '$DelComp' components feature IDs..."
}
# Just call it
DelSuppComp
I used the engine.asm from PTC as an example, but added a reference datum plane to one bolt, here one image before and after including the Message Log.
Some Vars content
CompIDsFL {1360 1277 148 44 151 45 52 55 100 105 109 164 165 168}
CompIDs {168 165 164 109 105 100 55 52 45 151 44 148 1277 1360}
CompStats {SUPPRESSED SUPPRESSED ACTIVE SUPPRESSED ACTIVE ACTIVE ACTIVE SUPPRESSED ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE}
Copy/Paste of the Message Log:
Run Delete Suppressed Components in Assembly 'ENGINE.ASM'
Delete Component ID '168' Name 'CONNECTING_ROD.PRT' with option 'NONE'
Delete Component ID '165' Name 'PISTON.ASM' with option 'NONE'
Component ID '109' has suppressed feature as well
Delete Component ID '109' Name 'BOLT_5-28<BOLT>.PRT' with option 'CLIP'
Delete Component ID '52' Name 'BOLT_5-18<BOLT>.PRT' with option 'NONE'
Deleted '4' components feature IDs...
Have fun with VB 😉