Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Batch DWG to IDW conversion

10 REPLIES 10
Reply
Message 1 of 11
aurelien.berthelot
1010 Views, 10 Replies

Batch DWG to IDW conversion

Hi

Today, It's possible to do bach IDW to DWG conversion, but autodesk doesn't provide a tool to do the opposite:

Inventor's DWG to IDW

 

Somebody have an idea or a script to do that ?

Smiley Happy

 

Regards,

Aurélien

10 REPLIES 10
Message 2 of 11

Hi,

 

It looks you can save as the Inventor DWG to idw directly. So you could just check if the document is Invenrtor DWG by 

DrawingDocument.IsInventorDWG, and call SaveAs. Is this fine to you?

Message 3 of 11

Hi,

 

I would like to know the same.

I have hundreds of .dwg drawings created out of Inventor and I would like to convert those drawings to .idw.

Is there any macro available for the same?

Please let me know.

Mahesh
Message 4 of 11
Owner2229
in reply to: MaheshwarMD

Hi, would you like to convert all drawings from a folder or from an assy?

 

This code will convert all DWG files from specifed folder. All you have to do is change the folder, run it and give it some time to do the work.

 

Dim oPath As String = "C:\Path\MorePath\DesiredFolder\"
Dim File As String
Dim Files As String()
Files = System.IO.Directory.GetFiles(oPath, "*.dwg")
For Each File In Files
    Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(File, False)
    If oDoc.IsInventorDWG Then
        oDoc.Update
        oDoc.SaveAs(Left(File, Len(File) - 3) & "idw", True)
    End If
    oDoc.Close(True)
Next 

 

BTW.: It's not a good thing to resurrect a 3 years old thread.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 11
MaheshwarMD
in reply to: Owner2229

Hi Mike,

 

Thanks for your quick support. 

I will run the code and let you know the status

Mahesh
Message 6 of 11
MaheshwarMD
in reply to: Owner2229

Hi Mike,

The code works great for specified folder option. I would like to know how about from an Assembly
Mahesh
Message 7 of 11
Owner2229
in reply to: MaheshwarMD

Hi, do the DWGs have the same filenames and paths as the IPTs / IAMs ?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 8 of 11
MaheshwarMD
in reply to: Owner2229

Hi Mike,

 

Yes, DWGs have the same filenames and paths as the IPTs / IAMs.

 

Mahesh
Message 9 of 11
Owner2229
in reply to: MaheshwarMD

Hi, this should do the trick:

 

Sub Main()
    Dim oDoc As Document = ThisApplication.ActiveDocument
    If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim aDoc As Document
        For Each aDoc In oDoc.AllReferencedDocuments
            ReSaveDWG(aDoc.FullFileName)
        Next
    End If
    ReSaveDWG(ThisDoc.Path & "\" & ThisDoc.FileName(True))
End Sub

Sub ReSaveDWG(File As String)
    File = Left(File, Len(File) - 3) & "dwg"
Try Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(File, False) If oDoc.IsInventorDWG Then oDoc.Update oDoc.SaveAs(Left(File, Len(File) - 3) & "idw", True) End If oDoc.Close(True)
Catch
' Catching documents without drawing
End Try End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 10 of 11
MaheshwarMD
in reply to: Owner2229

Hello Mike,

 

Thank you.

 

Mahesh
Message 11 of 11
atinderghara
in reply to: Owner2229

Hi Mike,

 

I was going through script do we need to paste it in specific folder in which files need to be converted or i can just paste a link for it.

 

Thanks

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report