Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello i'am having a minor problem. This code fails at the last line where it's supposed to save the drawing. What could be the issue?
Dim DWGType As String = ".idw" Dim oDoc As PartDocument = Nothing oDoc = ThisApplication.ActiveEditDocument Dim CurrentFilename As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName) Dim Path As String = System.IO.Path.GetDirectoryName(oDoc.FullDocumentName) If Not System.IO.File.Exists(System.IO.Path.ChangeExtension(oDoc.FullDocumentName, DWGType)) Then Return End If oDoc = ThisDoc.Document Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.Filter = "Autodesk Inventor Part Files (*.*)|*.*" oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() oFileDlg.FileName = CurrentFilename Try oFileDlg.CancelError = True oFileDlg.ShowSave() Catch Return End Try If Err.Number <> 0 Then ElseIf oFileDlg.FileName <> "" Then NFile = oFileDlg.FileName oDoc.SaveAs(NFile & ".ipt", False) End If Dim PNew As String = ThisDoc.WorkspacePath() ThisApplication.Documents.Open(NFile & ".ipt") Dim NFilename As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName) Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(Path & "\" & CurrentFilename & ".idw") DrawingDoc = ThisApplication.ActiveEditDocument Dim oFD As FileDescriptor = Nothing oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oFD.ReplaceReference(NFile & ".ipt") DrawingDoc.Update() DrawingDoc.SaveAs(PNew & "\" & NFilename & ".idw", False) oDoc.Activate()
Solved! Go to Solution.