Message 1 of 4

Not applicable
10-28-2015
01:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to know if it is possible to have ilogic code to rename a part/drawing to a totally new name? not prefix or suffix.. 123.ipt/idw becomes abc.ipt/idw.
I have the code below, but it creates a suffix of the user input number.
Can anyone help?
SyntaxEditor Code Snippet
' Start of iLogic code ------------------------------------------------------------------------------------- ' 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 part:" & 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 & "'", "Copy Part and Drawing") Return End If ' Prompt user for new part number PartNum = InputBox("You are creating a new copy of the model and drawing" & vbLf & vbLf & _ "Please input the new part number" & vbLf & vbLf & _ "Note the current model will be closed and the new one opened...." & vbLf & vbLf & _ "Proceed?", "Copy Part and Drawing",) If PartNum = "" Then ' Cancel was hit Return End If ' Get new filename (without extension) NewFileName = CurrentFilename & "_" & PartNum ' Perform Save As ThisDoc.Document.SaveAs(NewFileName & ".ipt", False) ' Open the current drawing Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(CurrentFilename & DWGType) ' Replace reference to part Dim oFD As FileDescriptor oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oFD.ReplaceReference(NewFileName & ".ipt") DrawingDoc.Update() ' Perform 'Save As' on the drawing DrawingDoc.SaveAs(NewFileName & ".idw", False) ' Make the assembly model active again... ThisDoc.Document.Activate ' End of iLogic code -------------------------------------------------------------------------------------
Solved! Go to Solution.