Question about DocumentDescriptorEnumeration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yesterday I tried to write some code that would control the suppression of flat pattern drawing views so that they would match the suppression states of their counterparts in the main assembly (which had things suppressed via LOD).
This led to several hoops and approaches (IE: Failures), with little hope of ever linking the list of occurrences, which contain the suppression state information, but can only be iterated through by way of browser occurrence name or number & the document files that the drawing views would resolve to that only gave me the document with nothing that could help in getting those occurrence names forthcoming.
Eventually I started looking for a means of iterating through a list of referenced documents by name, rather than long, and ended up seeing that the DocumentDescriptorEnumerator was just the thing. In fact, document descriptors seemed to hold the information that I needed to tell which suppression state the document was in! Setting up some code I quickly found that any time I would query the enumerator list with a name of a part that had been suppressed, it would result in an error.
This leads to the question I’m about to ask. The following code will do what I want it to. Because it causes an error, I am able to rely on that to be the flag that I need to suppress the drawing view, but that seems rather dangerous as that could lead to false positives. Is there a better way to go about doing what I’m trying to do?
Also, why can a document be clearly listed inside of the Descriptor Enumerator, but not be accessed?
Any answers would be keen! Thanks!
----------------
Option Explicit
Public Sub Main()
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then Return
Dim oDrawDoc As DrawingDocument
Dim oDrawingViews As DrawingViews
Dim oDrawingView As Inventor.DrawingView
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oAssDoc As AssemblyDocument
Dim oFullFileName As String
Dim AllRef As DocumentDescriptorsEnumerator
Dim oSupBool As Boolean
oDrawDoc = ThisApplication.ActiveDocument
oSheets = oDrawDoc.Sheets
oAssDoc = oDrawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
For Each oSheet In oSheets
If oSheet.ExcludeFromCount = False Then
oDrawingViews = oSheet.DrawingViews
For Each oDrawingView In oDrawingViews
If oDrawingView.IsFlatPatternView = True Then
AllRef = oAssDoc.ReferencedDocumentDescriptors
oFullFileName = oDrawingView.ReferencedFile.DocumentDescriptor.FullDocumentName
Try
oSupBool = AllRef.Item(oFullFileName).ReferenceSuppressed
oDrawingView.Suppressed = oSupBool
Catch
oSupBool = True
oDrawingView.Suppressed = oSupBool
End Try
End If
Next
End If
Next
End Sub
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

