Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
You can copy an assembly via ilogic design copy, but then the IDW files will not be included. Now I have written a macro so that those IDW files are copied to a location. I can then place it in the appropriate folder. I then open the IAM, run ilogic and that's it. However, the Ilogic does not work properly yet, I think something is wrong with the saveas. Perhaps the code could be a bit simpler.
Sub Main() Dim oDoc As Document oDoc = ThisDoc.Document oDocName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) If Not (oDoc.DocumentType = kAssemblyDocumentObject Or oDoc.DocumentType = kDrawingDocumentObject) Then MessageBox.Show("Please run this rule from the assembly or drawing files.", "iLogic") Exit Sub End If 'get user input If MessageBox.Show ( _ "This will create a IDW file for all of the files referenced by this document that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create IDW Drawings for all of the referenced documents?" _ & vbLf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo) = vbNo Then Exit Sub End If Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium 'oFolder = oDocName & " PDF Files" oFolder = "D:\IDW" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - Dim oRefDoc As Document Dim oDrawDoc As DrawingDocument For Each oRefDoc In oDoc.AllReferencedDocuments oBaseName = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName) oPathAndName = System.IO.Path.GetDirectoryName(oRefDoc.FullFileName) & "\" & oBaseName If (System.IO.File.Exists(oPathAndName & ".idw")) Then oDrawDoc = ThisApplication.Documents.Open(oPathAndName & ".idw", True) On Error Resume Next 'define the folder where you want to save the files oFolder = "D:\IDW\" 'create the folder if it doesn't exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'grab the filename oFileName = ThisDoc.FileName(False) 'without extension 'save as a idw ThisDoc.Document.SaveAs(oFolder & oFileName & ".idw", True) oDrawDoc.Close Else oNoDwgString = oNoDwgString & vbLf & idwPathName End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oBaseName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) oPathAndName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & oBaseName oDataMedium.FileName = oFolder & "\" & oBaseName & ".idw" If oDoc.DocumentType = kAssemblyDocumentObject Then oDrawDoc = ThisApplication.Documents.Open(oPathAndName & ".idw", True) On Error Resume Next 'define the folder where you want to save the files oFolder = "D:\IDW\" 'grab the filename oFileName = ThisDoc.FileName(False) 'without extension 'save as a idw ThisDoc.Document.SaveAs(oFolder & oFileName & ".idw", True) oDrawDoc.Close ElseIf oDoc.DocumentType = kDrawingDocumentObject Then oFileName = ThisDoc.FileName(False) 'without extension On Error Resume Next 'define the folder where you want to save the files oFolder = "D:\IDW\" 'grab the filename oFileName = ThisDoc.FileName(False) 'without extension 'save as a idw ThisDoc.Document.SaveAs(oFolder & oFileName & ".idw", True) oDrawDoc.Close End If '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") MsgBox("Files found without drawings: " & vbLf & oNoDwgString) Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub
Solved! Go to Solution.