11-09-2018
08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-09-2018
08:18 AM
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