Message 1 of 10
Open All Drawings Related To Top Level, Parts & Sub-Assemblies Given Assembly File
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I'm looking for some help with an iLogic code I have as shown below.
The code below opens all related drawing files from the within the assembly file but only if the files have the exact same name and file path.
Sub Main() '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 'Work with 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 dwgPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "dwg" 'Check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(dwgPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(dwgPathName, True) End If Next End Sub
Preferred folder search path:
R:\1. Projects\1. Tool Connection\
Is there a way to expand this code and make iLogic search the preferred path, say by using some sort of wildcard etc?
I'm looking for a similar function to Open Drawing as shown in the attached image but which opens all associated part and sub-assembly drawings of a given assembly, not just the drawing for the top level assembly.
Any help greatly appreciated! 😀
Many thanks,
Gareth