- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been asked by my users to write an addin to selectively suppress derived parts in drawing views. Let me run a scenario by you and somebody please tell me if this is even possible or not. If it is possible, please help point me in the right direction.
SCENARIO: I have an assembly that contains multiple derived parts. I have several different drawings that have views that reference this assembly. I want to suppress all the derived parts contained in the assembly in all the views of Drawing #1. I do not want to suppress the derived parts contained in the assembly in the views of Drawing #2. Is this possible? It is my understanding that the suppression occurrs at the component definition level so I would not be able to have derived parts suppressed in one drawing and not the other if both drawings reference the same assembly.
Thoughts?
Thanks in advance!
Darren
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Darren,
I do not believe that you can suppress the items but you should be able to reach into the view and turn off the visibility.
Since you can manually perform this, I expect that iLogic would most likely allow you the same capability.
Thank you.

Bob Holland
Autodesk Product Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can add new LOD (Level of Detail) and in the LOD you can suppress all the derived part components, and use the LOD for views in the Drawing #1. This won't affect the views in Drawing #2.
Hope this helps.
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.

Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Actually, this is the solution I was looking for. It was provided by Xiaodong Liang at the ADN.
Sub hideCurveOfDerivePart()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oView1 As DrawingView
Set oView1 = oSheet.DrawingViews(1)
Dim oModelDoc As Document
Set oModelDoc = oView1.ReferencedDocumentDescriptor.ReferencedDocument
If oModelDoc.DocumentType = kAssemblyDocumentObject Then
Dim oEachOcc As ComponentOccurrence
For Each oEachOcc In oModelDoc.ComponentDefinition.Occurrences
'native part document (this part has derived part)
If oEachOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = kPartDocumentObject Then
Dim oNativePartDoc As PartDocument
Set oNativePartDoc = oEachOcc.ReferencedDocumentDescriptor.ReferencedDocument
'check if the document has derived part
If oNativePartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0 Then
'hide the occurrence in the context of the drawing view.
Call oView1.SetVisibility(oEachOcc, False)
End If
End If
Next
End If
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Well, I posted the solution I was provided by ADN but I need to clarify that this solution only works in limited instances.
If the assembly in the drawing view contains a derived part then the solution works for making that part visible or not.
If the assembly in the drawing view contains a sub-assembly that contains a derived part, the solution does not work. In fact, if you drill down to the derived part and try to make it visible or invisible, the following error is generated, "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
I have reopened my case with ADN to figure out what is going on but I have not heard back from them yet.
Darren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can try below updated VBA code if it works, it will iterate all the sub occurrences and hide the derived part components:
Sub hideCurveOfDerivePart()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oView1 As DrawingView
Set oView1 = oSheet.DrawingViews(1)
Dim oModelDoc As Document
Set oModelDoc = oView1.ReferencedDocumentDescriptor.ReferencedDocument
If oModelDoc.DocumentType = kAssemblyDocumentObject Then
Dim oEachOcc As ComponentOccurrence
For Each oEachOcc In oModelDoc.ComponentDefinition.Occurrences
'native part document (this part has derived part)
If oEachOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = kPartDocumentObject Then
Dim oNativePartDoc As PartDocument
Set oNativePartDoc = oEachOcc.ReferencedDocumentDescriptor.ReferencedDocument
'check if the document has derived part
If oNativePartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0 Then
'hide the occurrence in the context of the drawing view.
Call oView1.SetVisibility(oEachOcc, False)
End If
ElseIf oEachOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = kAssemblyDocumentObject Then
Dim oSubOccu As ComponentOccurrence
For Each oSubOccu In oEachOcc.SubOccurrences
HideDerivedComponent oSubOccu, oView1
Next
End If
Next
End If
End Sub
' Iterate all the sub occurrences and hide the derived part
Sub HideDerivedComponent(oOccu As ComponentOccurrence, oView As DrawingView)
Dim oEachOcc As ComponentOccurrence
If oOccu.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = kPartDocumentObject Then
Dim oNativePartDoc As PartDocument
Set oNativePartDoc = oOccu.ReferencedDocumentDescriptor.ReferencedDocument
'check if the document has derived part
If oNativePartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0 Then
'hide the occurrence in the context of the drawing view.
Call oView.SetVisibility(oOccu, False)
End If
ElseIf oOccu.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = kAssemblyDocumentObject Then
Dim oSubOccu As ComponentOccurrence
For Each oSubOccu In oOccu.SubOccurrences
HideDerivedComponent oSubOccu, oView
Next
End If
End Sub
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.

Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
yuhanzhang,
My code is basically the same as yours except that I also check the DerivedAssemblyComponents.Count. However, as soon as the SetVisibility method is called on an occurrence of a derived component that is in a sub-assembly, the following error is thrown.
"Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
Have you tried your code out to see if it works in that situation?
Darren
Private Function HideAllDerivedPartsInSelectedView(ByRef SelectedView As Inventor.DrawingView, ByVal ShowParts As Boolean, ByRef SubAssemblyDoc As Inventor.AssemblyDocument) As Boolean
Dim AssemblyInView As Inventor.AssemblyDocument = Nothing
Dim AssemblyComponentDefObject As Inventor.AssemblyComponentDefinition = Nothing
Dim ComponentDefObject As Inventor.PartComponentDefinition = Nothing
Dim DocumentInView As Inventor.Document = Nothing
Dim OccurrenceCollection As Inventor.ComponentOccurrences = Nothing
Dim OccurrenceObject As Inventor.ComponentOccurrence = Nothing
Dim PartDocumentObject As Inventor.PartDocument = Nothing
Dim ReferenceComponentCollection As Inventor.ReferenceComponents = Nothing
Dim ReferencedDocObject As Inventor._Document = Nothing
Dim ReturnBoolean As Boolean = False
Try
If SubAssemblyDoc Is Nothing Then 'This is the first time the routine has been called
DocumentInView = SelectedView.ReferencedDocumentDescriptor.ReferencedDocument
If Not TypeOf DocumentInView Is Inventor.AssemblyDocument Then
MsgBox("The Document In The View Needs To Be An Assembly!", MsgBoxStyle.Information, "WRONG DOCUMENT TYPE!!!")
Exit Try
End If
AssemblyInView = CType(DocumentInView, Inventor.AssemblyDocument)
Else
AssemblyInView = SubAssemblyDoc
End If
AssemblyComponentDefObject = AssemblyInView.ComponentDefinition
OccurrenceCollection = AssemblyComponentDefObject.Occurrences
For Each OccurrenceObject In OccurrenceCollection
If OccurrenceObject.ReferencedDocumentDescriptor Is Nothing Then Continue For
ReferencedDocObject = OccurrenceObject.ReferencedDocumentDescriptor.ReferencedDocument
If TypeOf ReferencedDocObject Is Inventor.PartDocument Then
PartDocumentObject = CType(ReferencedDocObject, Inventor.PartDocument)
ComponentDefObject = PartDocumentObject.ComponentDefinition
ReferenceComponentCollection = ComponentDefObject.ReferenceComponents
If ReferenceComponentCollection.DerivedPartComponents.Count = 0 And ReferenceComponentCollection.DerivedAssemblyComponents.Count = 0 Then Continue For
'show or hide the occurrence of the derived part or assembly
SelectedView.SetVisibility(OccurrenceObject, ShowParts)
ElseIf TypeOf ReferencedDocObject Is Inventor.AssemblyDocument Then
'recursively go through the sub assembly and look for derived parts
HideAllDerivedPartsInSelectedView(SelectedView, ShowParts, CType(ReferencedDocObject, Inventor.AssemblyDocument))
End If
Next
ReturnBoolean = True
Catch ex As Exception
MsgBox(ex.Message)
ReturnBoolean = False
Finally
ReleaseCOMObject(AssemblyInView)
ReleaseCOMObject(AssemblyComponentDefObject)
ReleaseCOMObject(DocumentInView)
ReleaseCOMObject(OccurrenceCollection)
ReleaseCOMObject(OccurrenceObject)
ReleaseCOMObject(PartDocumentObject)
ReleaseCOMObject(ReferencedDocObject)
GC.WaitForPendingFinalizers()
GC.Collect()
End Try
Return ReturnBoolean
End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Darren,
Can you try my VBA code there? You can add the logic for check the derived assembly in the code to make it work for both derived part and assembly.
I noticed that in your code, the last argument you use the AssemblyDocument but not ComponentOccurrence in the function HideAllDerivedPartsInSelectedView:
Function HideAllDerivedPartsInSelectedView(ByRef SelectedView As Inventor.DrawingView, ByVal ShowParts As Boolean, ByRef SubAssemblyDoc As Inventor.AssemblyDocument) As Boolean
Here I think what you should pass in is a ComponentOccurrence object for the sub assembly but not the AssemblyDocument object, and also in the code where you iterate the sub-occurrences you should also use the ComponentOccurrence.SubOccurrences to get the ComponentOccurrenceProxy objects and pass in the ComponentOccurrenceProxy for the SetVisibility method. You can refer to the logic in my VBA code how I iterate the SubOccurrences but not the AssemblyDocument.ComponentDefinition.Occurrences. If you still have problem to update your code please let me know.
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.

Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry for not reading Yuhanzhang's code closer. Once I checked the suboccurrences collection, my code worked fine.
Thanks for the help!
Darren