Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save as DWG/DXF using API

Status
Not open for further replies.

JpPhysics

Mechanical
Mar 25, 2002
35
I am trying to save SW slddrw files as DWG and DXF files for use by our vendors. The problem is, it is nearly impossible to tell weather the export will be at the correct scale.

I am looking for a way to ensure that the output drawing is alway 1:1 to the model, not the drawing. Any help would be appreciated.
 
Replies continue below

Recommended for you

You can't save a "model" as a DXF or DWG only "drawings". Are you sure your not talking about the drawings?

Best way to test your DXF or DWG output is to bring the DXF or DWG back into SW and see.

Scott Baugh, CSWP [spin] [americanflag]
3DVision Technologies
faq731-376
When in doubt, always check the help
 
Yes, I am talking about the drawings.
"... SW slddrw ..." from my post above.
 
AutoCAD .dxf's and dwg's are exported as they appear in the drawing. If the view is 1:1, it will be 1:1 in the .dwg file. If the view is 4:1, it will be 4:1 in the .dwg file.

Also, translation of fonts can be a bit flaky between SW and AutoCAD. Fortunately for me, I have AutoCAD available to inspect the results. Sometimes text is lost or GDT symbols display extra characters. [bat]Gravity is a harsh mistress.[bat]
 
Jp,

I was looking for a way to control the scale too, so far I couldn't find it.

See if SW retains the last set for the scale. Save one drawing as DWG manually, with the check box checked, then run the program with two or three drawings then check the results. It worked for me but I haven't tested enough to make sure it works in any situation.

Andrew
 
Thanks for all the help. I figured it out.

1. First you have to grab the sheet and find out what the sheet scale is.

2. Then you can set a system property swDxfOutputScaleFactor (defined as 79 in swconst.bas) to the reciprocal of the sheet scale.

If anyone want's to see the code, let me known.
 
Great Jp!

I would be interested in seeing the code.

My email is andrew@netshop21.com.

Andrew
 
JpPhysics,

I'll take the code example too, if you don't mind.

webmaster@okswug.com

Mr. Pickles
 
JpPhisics [wavey]

Please include me on that growing list
LeeB34@Cox.net

I have a routine that saves DXFs but it doesn’t bother with the Scale Factor.
Question though, are you also checking each view for its scale as well? I've seen a lot of cases where the sheet was 1/1 but all the views were 1/2.

Random_Shapes_Pointed_shapes_prv.gif
Lee
Random_Shapes_Pointed_shapes_prv.gif


Consciousness: That annoying time between naps.
 
Ok...for those that asked.

This is a code snippet...
...
sSheet is an object set to the current drawings sheet
DwFile is an object set to the current drawing file
TF is a boolean
dDXFScaleFactor is a Double
ModelDoc is an Object, set to the current Active File - This probably could be the DwFile. I havn't looked.
...
Set sSheet = DwFile.GetCurrentSheet
Sheets = sSheet.GetProperties
dDXFScaleFactor = Sheets(3) / Sheets(2)
DwFile.ForceRebuild
TF = swApp.SetUserPreferenceDoubleValue(swDxfOutputScaleFactor, dDXFScaleFactor)
ModelDoc.SaveAsSilent Path & "\" & PartNo & "-" & Rev & ".dwg", True
ModelDoc.SaveAsSilent Path & "\" & PartNo & "-" & Rev & ".dxf", True

This is part of a much larger routine that allows the user to select multiple files then export all of them to a common directory, then zip them all up in a nice tidy Zip file.

This routine exports:
From the Model
.iges
.sat
.step
.x_b
.x_t
.eprt or .easm
.sldprt or .sldasm - Saves it out of the configuration file and deletes all other configurations.

From the Drawing
.dwg
.dxf
.slddrw - Linked to .sldprt or .sldasm from above.

Basically, I am generating a copy of everything and setting it aside so that the distributed file is relatively stable. *Note - For assemblies, we do not distribute the model or the drawing since you would then have to distribute all the associated parts with it.

Even after the modification above, we are still having scaling problems with the dwg/dxf file. If anyone could help me to figure out why, I would sure appreciate it.

Thanks and have fun,

John G.
 
We have trouble when exporting drawings to DXF. Even with "Hide All Types" selected, the dxf has bend lines as well as any construction sketches on the part.

How can we automatically hide these without right-clicking each sketch and bend line?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor