Convert IDW to DWF

Convert IDW to DWF

amitnkukanur
Collaborator Collaborator
627 Views
2 Replies
Message 1 of 3

Convert IDW to DWF

amitnkukanur
Collaborator
Collaborator

Hello,

 

I am doing a project which is about converting IDW files to DWF.

 

 

I problem i am facing is Inventor is getting crashed every non and then.

This is the below code which i am using to convert to DWF

 

Document oDoc = InvApp.Documents.Open(filenamepath, false);

DrawingDocument oDrwDoc = (DrawingDocument)oDoc;

DataIO aa;

 

oDrwDoc.Update(); // Here i am updating the drawing document

 

aa = oDrwDoc.Sheets[1].DataIO;

 

aa.WriteDataToFile("DWF", "C:\temp\test.dwf"); //Crash on this line

 

oDrwDoc.Close(true);

oDoc.Close(true);

 

If there is any other way which helps to do this, that would be helpful.

 

Cheers,

Amit

 

Senior Software Engineer
0 Likes
628 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Hi ,

 

This maybe useful for you .Sorry i have done it in VBA.Hope it helps

 

Public Sub saveAsDWF()
  Dim oDrawDoc As DrawingDocument
  Set oDrawDoc = ThisApplication.ActiveDocument

  Call oDrawDoc.SaveAs(""C:\temp\test.dwf", True)
  oDrawDoc.Close (True)


End Sub

0 Likes
Message 3 of 3

amitnkukanur
Collaborator
Collaborator

Hi Prakash,

 

Thanks for reply. I solved  the issue with some round work using Cross language Support Feature in .NET

 

PublicSub writeDWF()

Try

Dim oAApp AsApprenticeServerComponent = NewApprenticeServerComponent()

Dim oDoc AsApprenticeServerDrawingDocument = oAApp.Open(FileName)

Dim oSheet AsSheet = oDoc.Sheets(1)

Dim oDataIO AsDataIO = oSheet.DataIO

'oDataIO.WriteDataToFile("DWF", "c:\temp\1101-22247.dwf")

FileName = FileName.Replace(".idw", ".dwf")

oDataIO.WriteDataToFile("DWF", FileName)

oDoc.Close()

oAApp.Close()

Catch ex AsSystemException

EndTry

EndSub

 

This above code is working fine in VB.net, if i convert same to C#, its giving some problem.

 

Hence I created a DLL with COM Visibility in VB.NET and included the DLL in C#.

 

Then i called WriteDWF method by passing filepath it got converted fine.

 

Thanks for reply.

 

rgds

Amit

Senior Software Engineer
0 Likes