' Start of iLogic code ------------------------------------------------------------------------------------- ' Note this iLogic rule takes a copy of the active assembly and associated drawing file ' ...then associates the drawing with the newly copied assembly. ' Note it only copies and replaces the top level assembly file, and therefore is not ' suitable for copying assemblies that contain sub-assemblies (iLogic Copy Design, Vault ' Copy Design or Design Assistant should be used for this) ' Set drawing extension Dim DWGType As String = ".dwg" 'Dim DWGType As String = ".idw" ' Get current filename CurrentFilename = ThisDoc.PathAndFileName(False) ' Check that the drawing for this assembly can be found If Not System.IO.File.Exists(CurrentFilename & DWGType) Then MessageBox.Show("Unable to locate the drawing file below for this assembly:" & vbLf & vbLf & _ CurrentFilename & DWGType & vbLf & vbLf & _ "Please make sure it's in the same folder as this assembly, has the same name, and has the file extension '" & DWGType & "'", "Cadline - Copy Assembly and Drawing") Return End If ' Prompt user for job number JobNum = InputBox("You are creating a new copy of this assembly and its 2D drawing file" & vbLf & vbLf & _ "Please input a job number suffix to use for the filename" & vbLf & vbLf & _ "Note the current assembly will be closed and the new one opened...." & vbLf & vbLf & _ "Proceed?", "Cadline - Copy Assembly and Drawing", "0000") If JobNum = "" Then ' Cancel was hit Return End If ' Get new filename (without extension) NewFileName = CurrentFilename & "_" & JobNum ' Perform Save As of Assembly ThisDoc.Document.SaveAs(NewFileName & ".iam", False) ' Open the current drawing (in same folder location) Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(CurrentFilename & DWGType) ' Replace reference to assembly model Dim oFD As FileDescriptor oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oFD.ReplaceReference(NewFileName & ".iam") DrawingDoc.Update() ' Perform 'Save As' on the drawing DrawingDoc.SaveAs(NewFileName & ".dwg", False) ' Make the assembly model active again... ThisDoc.Document.Activate ' End of iLogic code -------------------------------------------------------------------------------------