×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Save as DWG/DXF using API

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.

RE: Save as DWG/DXF using API

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
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

(OP)
Yes, I am talking about the drawings.
  "... SW slddrw ..." from my post above.

RE: Save as DWG/DXF using API

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.

Gravity is a harsh mistress.

RE: Save as DWG/DXF using API

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  

RE: Save as DWG/DXF using API

(OP)
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.

RE: Save as DWG/DXF using API

Great Jp!

I would be interested in seeing the code.

My email is andrew@netshop21.com.

Andrew

RE: Save as DWG/DXF using API

JpPhisics

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.

Lee

Consciousness: That annoying time between naps.

RE: Save as DWG/DXF using API

(OP)
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.

RE: Save as DWG/DXF using API

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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources