- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to automate shrink-wrapping some parts. I managed to cobble together the code below and it works great for making a SW of the whole assembly... I need to exclude some parts however. If I manually create a SW, I see the parts I select in the AdditionalExcludedOccurrences as Varient/Object/ComponentOccurrence. In the long term I will create my list of parts to exclude based on their part number but for now I just what to figure out how to get any object into the AEO collection object.
I've tried hard coding a ComponentOccurrence in to the code below and I've tried using a CommandManager.Pick (as seen in code) I just can't figure out how to add an object to AdditionalExcludedOccurrences.
Sub STPMain() Dim app As Application Set app = ThisApplication Dim doc As AssemblyDocument Set doc = app.ActiveDocument Dim compDef As AssemblyComponentDefinition Set compDef = doc.ComponentDefinition 'create new part Dim SimpleName As String 'unused at this time SimpleName = Left(doc.FullDocumentName, Len(doc.FullDocumentName) - 4) Dim partDoc As PartDocument Set partDoc = app.Documents.Add(kPartDocumentObject, , True) doc.Activate Dim partCompDef As PartComponentDefinition Set partCompDef = partDoc.ComponentDefinition 'create collection of parts to exclude 'just one for now Dim ExcludeGroup As ObjectCollection Set ExcludeGroup = app.TransientObjects.CreateObjectCollection Call ExcludeGroup.Add(app.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "pick object")) Debug.Print ("ExcludeGroup count = " & ExcludeGroup.Count) Dim SWD As ShrinkwrapDefinition Set SWD = partCompDef.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(doc.FullDocumentName) SWD.CreateIndependentBodiesOnFailedBoolean = True SWD.DeriveStyle = kDeriveAsSingleBodyNoSeams SWD.RemoveInternalParts = True Call SWD.AdditionalExcludedOccurrences.Add(ExcludeGroup.Item(1)) 'help on this line please Debug.Print ("Excluded item count = " & SWD.AdditionalExcludedOccurrences.Count) Dim SWComp As ShrinkwrapComponent Set SWComp = partCompDef.ReferenceComponents.ShrinkwrapComponents.Add(SWD) End Sub
Mass Override for Each Model State
Custom Glyph Icon for iMates
Solved! Go to Solution.