Not applicable
11-01-2018
09:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been adding to the code for setting automated center lines so that it also includes 3D sketches in the selected drawing view. Code went together fairly easy or so I thought. I tried different methods for doing this but the outcome is always the same. Not sure what I am missing or why it is behaving the way it is. Code is below and attached is a screen shot of the outcome. Using Inventor Pro 2018.3.1. Issue is the same on Windows 7 and Windows 10. In the image the far left detail is correct. The rest has the 3D sketch coming in not properly oriented. Any help would be appreciated.
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 modelpane As BrowserPane = oDrawDoc.BrowserPanes.Item("Model")
For Each node As BrowserNode In modelpane.TopNode.BrowserNodes
Dim nodedef As BrowserNodeDefinition = node.BrowserNodeDefinition
If nodedef.Label = oSheet.Name Then
For Each viewnode As BrowserNode In node.BrowserNodes
Dim viewnodedef As BrowserNodeDefinition = viewnode.BrowserNodeDefinition
If viewnodedef.Label.StartsWith(oView.Name) Then
Dim firstnode As BrowserNode = viewnode.BrowserNodes.Item(1)
For Each secondnode As BrowserNode In firstnode.BrowserNodes
For Each thirdnode As BrowserNode In secondnode.BrowserNodes
Dim thirdnodedef As BrowserNodeDefinition = thirdnode.BrowserNodeDefinition
If thirdnodedef.Label.StartsWith("3D") Then
Dim sketch As Object = thirdnode.NativeObject
If oView.GetVisibility(sketch) = False Then
thirdnode.Expanded = True
End If
Else
For Each fourthnode As BrowserNode In thirdnode.BrowserNodes
Dim fourthnodedef As BrowserNodeDefinition = fourthnode.BrowserNodeDefinition
If fourthnodedef.Label.StartsWith("3D") Then
Dim sketch As Object = fourthnode.NativeObject
If oView.GetVisibility(sketch) = False Then
thirdnode.Expanded = True
End If
End If
Next
End If
Next
Next
End If
Next
End If
Next
'Dim model As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
'For Each doc As _Document In model.AllReferencedDocuments
' If TypeOf doc Is PartDocument Then
' Dim pdoc As PartDocument = doc
' Dim pdef As PartComponentDefinition = pdoc.ComponentDefinition
' Dim threedsketch As Sketch3D
' For Each threedsketch In pdef.Sketches3D
' oView.SetIncludeStatus(threedsketch, True)
' Next
' threedsketch = Nothing
' pdoc = Nothing
' End If
' doc = Nothing
'Next
'model = Nothing
'oView = Nothing
End If
Next
obj = Nothing
End If
End Sub
Solved! Go to Solution.
