10-30-2020
05:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-30-2020
05:15 AM
@WCrihfield wrote:Yes. Using the document's AllReferencedDocuments property like that is one of the most common ways to iterate through all documents within an assembly. It is often more efficient than when iterating through the assembly's ComponentOccurrences, because you can have multiple ComponentOccurrences that all represent the same source document.
Here is another way to iterate through each sheet, and each view within each sheet of a drawing, and getting the document being represented within those views. However, if the same document is being represented within multiple views, your Save() code may run on that document multiple times.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet
Dim oView As DrawingView
Dim oViewDoc As Document
For Each oSheet In oDDoc.Sheets
For Each oView In oSheet.DrawingViews
oViewDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
oViewDoc.Save()
Next
Next
This is so AWESOMMMEEE!! It fixes an issue i was ABOUT to try to address. The other issue is still an issue tho ![]()