Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: chandra.shekar.g

@chandra.shekar.g

 

 

Thank you! You gave me enough to get it working. I wanted to iterate through all occurrences and grab any and all 3D sketches to include. Below is the code.

    Public Sub CMandCL(ThisApplication As Inventor.Application)
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = ThisApplication.ActiveDocument
        Dim oSheet As Sheet
        oSheet = oDrawDoc.ActiveSheet
        If oDrawDoc.SelectSet.Count = 0 Then
            MsgBox("Please select at least one view.")
        Else
            Dim obj As Object
            For Each obj In oDrawDoc.SelectSet
                If TypeOf obj Is DrawingView Then
                    Dim oView As DrawingView = obj
                    oView.SetAutomatedCenterlineSettings()
                    Dim i As Integer = 0
                    Dim model As _Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
                    If TypeOf model Is AssemblyDocument Then
                        Dim assymodel As AssemblyDocument = model
                        For Each occ As ComponentOccurrence In assymodel.ComponentDefinition.Occurrences
                            If occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
                                Dim oDef As PartComponentDefinition = occ.Definition
                                If oDef.Sketches3D.Count > 0 Then
                                    For Each sketch As Sketch3D In oDef.Sketches3D
                                        i += 1
                                        Dim oProxy As Sketch3DProxy
                                        Call occ.CreateGeometryProxy(oDef.Sketches3D.Item(i), oProxy)
                                        Call oView.SetIncludeStatus(oProxy, True)
                                    Next
                                    i = 0
                                End If
                            End If
                        Next
                    End If
                End If
            Next
        End If
    End Sub
Tags (1)