API - All Assembly Parts - Set End Of Part to Top Or Bottom

API - All Assembly Parts - Set End Of Part to Top Or Bottom

Anonymous
Not applicable
460 Views
1 Reply
Message 1 of 2

API - All Assembly Parts - Set End Of Part to Top Or Bottom

Anonymous
Not applicable

So, I have a snippet of code that I want to go through my assembly and roll the end of all parts up to expedite calculations. The issue is, it is grabbing the proxies instead of the actual components, so it throws an error.

 

Dim oDoc as Document 
oDoc = ThisDoc.Document

Dim oOcc as ComponentOccurrence

Dim oAsmCompDef As AssemblyComponentDefinition 
oAsmCompDef = oDoc.ComponentDefinition

For Each oOcc In oAsmCompDef.Occurrences.AllLeafOccurrences
   
    If oOcc.Definition.Type <> ObjectTypeEnum.kAssemblyComponentDefinitionObject Then 
         oOcc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)
    End If 
Next 
0 Likes
461 Views
1 Reply
Reply (1)
Message 2 of 2

Vladimir.Ananyev
Alumni
Alumni

Here is the VBA sample that does this work:

Private Sub SetEOF()
    Dim oAssyDoc As AssemblyDocument
    Set oAssyDoc = ThisApplication.ActiveDocument
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = oAssyDoc.ComponentDefinition
    
    Dim oOcc As ComponentOccurrence
    
    For Each oOcc In oAsmCompDef.Occurrences.AllLeafOccurrences
        If oOcc.Definition.Type = ObjectTypeEnum.kPartComponentDefinitionObject Then
            Dim oDef As PartComponentDefinition
            Set oDef = oOcc.Definition
            Call oDef.SetEndOfPartToTopOrBottom(True)
        End If
    Next
    oAssyDoc.Update
    Beep
End Sub

 Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes