Save as DWG/DXF using API
Save as DWG/DXF using API
(OP)
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.
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.






RE: Save as DWG/DXF using API
Best way to test your DXF or DWG output is to bring the DXF or DWG back into SW and see.
Scott Baugh, CSWP

3DVision Technologies
http://www.3dvisiontech.com
http://www.3dmca.com
FAQ731-376
When in doubt, always check the help
RE: Save as DWG/DXF using API
"... SW slddrw ..." from my post above.
RE: Save as DWG/DXF using API
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.
RE: Save as DWG/DXF using API
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
RE: Save as DWG/DXF using API
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.
RE: Save as DWG/DXF using API
I would be interested in seeing the code.
My email is andrew@netshop21.com.
Andrew
RE: Save as DWG/DXF using API
I'll take the code example too, if you don't mind.
webmaster@okswug.com
Mr. Pickles
RE: Save as DWG/DXF using API
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.
Consciousness: That annoying time between naps.
RE: Save as DWG/DXF using API
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.
RE: Save as DWG/DXF using API
How can we automatically hide these without right-clicking each sketch and bend line?