Save idw as dxf

Save idw as dxf

jmlip
Advocate Advocate
435 Views
4 Replies
Message 1 of 5

Save idw as dxf

jmlip
Advocate
Advocate
Hello,

I am very new to VB. I'm wondering if someone could explain what the invapp.CommandManager is or where I could find some help on it. The code is shown below. It works great but it saves the file as a zip file and I just need the dxf. Also, I don't understand how to tell it where the file should be saved.

Thanks you,

Joan

I downloaded an AutoSave program from one of the forums and I'm trying to customize it.

Sub AutoSave()
MsgBox "See you tomorrow", vbInformation


Dim invApp As Inventor.Application
Set invApp = ThisApplication
invApp.SilentOperation = True

Dim idwDoc As Inventor.DrawingDocument
Set idwDoc = invApp.ActiveDocument

Dim dxfFile As String
dxfFile = idwDoc.FullFileName
If dxfFile = "" Then
dxfFile = "c:\temp\" & idwDoc.DisplayName
End If
Mid(dxfFile, Len(dxfFile) - 3) = ".dxf"

With invApp.CommandManager
Call .PostPrivateEvent(kFileNameEvent, dxfFile)
Call .StartCommand(kFileSaveCopyAsCommand)
End With

Set idwDoc = Nothing
invApp.SilentOperation = False
Set invApp = Nothing



End Sub
0 Likes
436 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I am sure there is settings that can be made in VBA, but the easiest thing
to do might be to Open Inventor, and open a IDW. Click on File >>Save Copy
As and in that dialog select DXF then select Options. Uncheck Pack And go.

I believe it will remember that setting from then on.

A little less confusing method than using commandmanager IMO would be to
just use the idwDoc.Saveas command.

--
___________________
Kent Keller
www.kwikmcad.com


wrote in message news:5523259@discussion.autodesk.com...
Hello,

I am very new to VB. I'm wondering if someone could explain what the
invapp.CommandManager is or where I could find some help on it. The code is
shown below. It works great but it saves the file as a zip file and I just
need the dxf. Also, I don't understand how to tell it where the file should
be saved.

Thanks you,

Joan

I downloaded an AutoSave program from one of the forums and I'm trying to
customize it.

Sub AutoSave()
MsgBox "See you tomorrow", vbInformation


Dim invApp As Inventor.Application
Set invApp = ThisApplication
invApp.SilentOperation = True

Dim idwDoc As Inventor.DrawingDocument
Set idwDoc = invApp.ActiveDocument

Dim dxfFile As String
dxfFile = idwDoc.FullFileName
If dxfFile = "" Then
dxfFile = "c:\temp\" & idwDoc.DisplayName
End If
Mid(dxfFile, Len(dxfFile) - 3) = ".dxf"

With invApp.CommandManager
Call .PostPrivateEvent(kFileNameEvent, dxfFile)
Call .StartCommand(kFileSaveCopyAsCommand)
End With

Set idwDoc = Nothing
invApp.SilentOperation = False
Set invApp = Nothing



End Sub
0 Likes
Message 3 of 5

Anonymous
Not applicable
Kent's suggestion is a good one. Run the translator interactively and set
the settings the way you want. You can use the Document.SaveAs method to
create the dxf file. There was a previous limitation that forced people to
use the CommandManager, but that issue was resolved many realeases ago
(probably around Inventor 6 or 7). The thing that was changed is for the
SaveAs to use the extension of the filename to determine the type of file to
create. When you call the SaveAs method and supply a filename that has a
.dxf extension it will create a dxf file using the the settings saved in the
default .ini file for the dxf translator.
--
Brian Ekins
Autodesk Inventor API

"Kent Keller" wrote in message
news:5523303@discussion.autodesk.com...
I am sure there is settings that can be made in VBA, but the easiest thing
to do might be to Open Inventor, and open a IDW. Click on File >>Save Copy
As and in that dialog select DXF then select Options. Uncheck Pack And go.

I believe it will remember that setting from then on.

A little less confusing method than using commandmanager IMO would be to
just use the idwDoc.Saveas command.

--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 4 of 5

jmlip
Advocate
Advocate
Thank you Kent and Brian. I really appreciate the help. I will give that a try.

Joan
0 Likes
Message 5 of 5

jmlip
Advocate
Advocate
This is working well but I am still unclear on how to specify the folder where I want the dxf saved. I saved the ini file but the dxf is not saved in the folder I specified. How would I go about adding the path in the code?

Public Sub ExportToDXF()
Dim odoc As DrawingDocument
Set odoc = ThisApplication.ActiveDocument
Dim sFname As String
sFname = odoc.FullFileName
sFname = Left$(sFname, Len(sFname) - 3) & "dxf"

Call odoc.SaveAs(sFname, True)

End Sub

thank you very much!

Joan
0 Likes