API, DXF option

I would like getting the DXF option before "Save As" DXF. But, for each options I get the result of the DXF version. My Macro is:

Dim swApp As Object Dim DxfVersion As Integer Dim DxfOutputFonts As Integer Dim DxfMappingFileIndex As Integer Dim AutoSaveInterval As Integer Sub main() Set swApp = Application.SldWorks

' Get the version of DXF for exporting

DxfVersion = swApp.GetUserPreferenceIntegerValue(swDxfVersion) Version = Str(DxfVersion) ' Get whether TrueType fonts are exported (1) or only standard (0)

DxfOutputFonts = swApp.GetUserPreferenceIntegerValue(swDxfOutputFonts) Fonts = Str(DxfOutputFonts) ' Get the map file index the file used for custom DXF mapping

DxfMappingFileIndex = swApp.GetUserPreferenceIntegerValue(swDxfMappingFileIndex) Index = Str(DxfMappingFileIndex) ' Get the number of operations between auto-saves

AutoSaveInterval = swApp.GetUserPreferenceIntegerValue(swAutoSaveInterval) Interval = Str(AutoSaveInterval)

Text = Version + Chr(10) + Fonts + Chr(10) + Index + Chr(10) + Interval

Box = MsgBox(Text, vbOKOnly, DXF)

End Sub

Thomas W. Wilson

Reply to
Thomas W.Wilson
Loading thread data ...

Thomas,

I think your macro is not picking up the definitions for the constants swDxfVersion, swDxfOutputFonts, swDxfMappingFileIndex, swAutoSaveInterval.

If you are running SW2004, in the Reference dialog box on the Tools menu in the VB editor search for check box labelled Solidworks Constant type library and make sure it is checked. That will give your macro access to the definitions from swconst.tlb.

If you don't have SW2004 installed, there will be no swconst.tlb, so the above approach won't work. The constants are defined in a file called swconst.bas instead. You can import this file into VBA using import on the file menu - it is in C:\Program Files\SolidWorks\samples\appcom or similar.

Alternatively, you can just paste the minimal definitions into your macro:

Public Enum swUserPreferenceIntegerValue_e swDxfVersion = 0 swDxfOutputFonts = 1 swDxfMappingFileIndex = 2 swAutoSaveInterval = 3 End Enum

Reply to
Paul Delhanty

Thanks Paul,

Thomas W. Wilson

Reply to
Thomas W.Wilson

You probably already know this, but to have the fonts come thru in a DXF, you will need to export r13 or newer version DXF.

Reply to
rocheey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.