idw file to Inventor dwg

idw file to Inventor dwg

mikejones
Collaborator Collaborator
413 Views
1 Reply
Message 1 of 2

idw file to Inventor dwg

mikejones
Collaborator
Collaborator

I hope someone can help me out. I have a need to open up all Inventor dwg files and save then as Inventor idw files. I then have to open the new idw file and save back to inventor dwg. The current dwg files contain a reference to an external image file that needs removing from the dwg file and the simplest way to achieve it it to export to idw as that will remove the reference. So far I have the code below which does the export but the resulting dwg is an Autocad dwg and not the Inventor dwg file needed. Any idea how to specify the Inventor dwg file type?

 

Dim oPath As String = "C:\Temp" '
Dim oIDW_Filename As String' IDW File name

 

' Get the files in the specified directory and subdirectories.
Dim oDrawingNumbers() As String = System.IO.Directory.GetFiles(oPath, "*.dwg", System.IO.SearchOption.AllDirectories)


'Dim oCurrentDrawings As String() 'array list of all dwg files found

 

For Each Drawing As String In oDrawingNumbers

If Drawing.Contains("OldVersion") = False Then 'Don't need dwg files in oldversion folders


ThisDoc.Launch(Drawing)
InventorVb.DocumentUpdate()


oIDW_Filename=Left(Drawing,Len(Drawing)-4)' Filename and path without extension

ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".idw"), True)
ThisApplication.ActiveDocument.Close

ThisDoc.Launch(oIDW_Filename & "idw")
InventorVb.DocumentUpdate()
ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".dwg"), True)
ThisApplication.ActiveDocument.Close


End If

Next

 

Many thanks 

Mike

Autodesk Certified Professional
0 Likes
Accepted solutions (1)
414 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor
Accepted solution

See API help under DrawingDocument Object save as inventor drawing .dwg

 

Syntax

DrawingDocument.SaveAsInventorDWG( FullFileName As String, SaveCopyAs As Boolean )

 

Also have you tried the code method to remove the ReferencedOLEFileDescriptor

? The link below shows manual method of swapping to idw and back to dwg and via code.

 

Linked OLE file not able to delete in Inventor

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes