04-21-2021
04:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-21-2021
04:28 AM
Hello vaida
please see code below I added a loop to count the drawings haven't tested it.
May not be the most efficient way but hope this helps
' Check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If ' Define the active document As an Assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oAsmName As String oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - ' Look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document '==================================================================== Dim i As Integer i = 0 For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" ' Check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then i = i+1 End If Next If i = 0 Then MessageBox.Show("No drawings found", "iLogic") Exit Sub ElseIf i > 0 Then MessageBox.Show( i + "drawings found", "iLogic") End If '==================================================================== ' Work the the drawing files for the referenced models ' This expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" ' Check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oDrawDoc.Update oDrawDoc.Save oDrawDoc.Close End If Next