×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

Export DXF macro

Export DXF macro

Export DXF macro

(OP)
I am using the macro from this thread:

https://www.eng-tips.com/viewthread.cfm?qid=328477...

Changed a little bit into this:

Option Explicit

Sub main()

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim nStart As Single
Dim i As Long
Dim bShowConfig As Boolean
Dim bRebuild As Boolean
Dim bRet As Boolean


Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc

vConfNameArr = swModel.GetConfigurationNames

For i = 0 To UBound(vConfNameArr)

sConfigName = vConfNameArr(i)


bShowConfig = swModel.ShowConfiguration2(sConfigName)

bRebuild = swModel.ForceRebuild3(False)

Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String

FilePath = swModel.GetPathName
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)

NewFilePath = sConfigName & ".DXF"

'Export Flat Pattern
bRet = swModel.ExportFlatPatternView(NewFilePath, 1)

Next i

End Sub

Now the problem I have with this is:
When before running the macro (in Solidworks 2020) I save a random drawing, my export macro uses the scale of that drawing to export the dxf.
So I save a drawing with scale 1:2
I run the macro in part environment
The part is for example 100x100mm
The exported dxf has dimensions 200x200.

Ofcourse I want to export only 1:1, independend of the non related drawings I save.

Thanks for any help.

RE: Export DXF macro

There is an option to export drawings at 1:1.

Either set that option before running the macro, or add that option into your code.

RE: Export DXF macro

Create a new drawing (blank without any sheet format or any tables/notes) and set the scale to 1:1 in that drawing. Now save that drawing as default template undet Tools > Options > Default Template and your parts should export to correct scale.

Deepak Gupta
SOLIDWORKS Champion and Expert
SW 2022 SP0.0, 2021 SP5.1 and 2020 SP5.0
Boxer's SOLIDWORKS Blog


RE: Export DXF macro

(OP)
Hi,

@TheTick I know I can select scale options when exporting drawings as DXF. This function is disabled when exporting from a part. I really wouldnt know how to add this into my code.
If someone could help me with that, would be apreciated.

@Gupta65: I tried that, but this doesn't work.

The workaround we do now is simply saving a drawing scale 1:1 everytime before exporting, but Im looking for an option to just add this in the macro.

Thanks,

RE: Export DXF macro

Exporting from part is automatically 1:1.

I prefer exporting from part, as it gives control over the origin. I can export multiple DXFs that cam be overlaid with the same origin.

RE: Export DXF macro

(OP)
@TheTick,

The point is that I would expect my part to export 1:1, but it doesn`t when I use the macro. It does when I use the Export to dxf / dwg command.

RE: Export DXF macro

@Hermen, in that case either you drawing template scale or units are not correct. Can you share one file and your drawing template to check?

Deepak Gupta
SOLIDWORKS Champion and Expert
SW 2022 SP0.0, 2021 SP5.1 and 2020 SP5.0
Boxer's SOLIDWORKS Blog


RE: Export DXF macro

@Hermen, sorry for delayed response. I've checked your files using the codes posted above and result is correct i.e. files are exporting at correct scale. So there seem to be some setting issue in your DXF reader. To check this, open the exported files in edrawings OR back in SW and check the values.

Deepak Gupta
SOLIDWORKS Champion and Expert
SW 2022 SP0.0, 2021 SP5.1 and 2020 SP5.0
Boxer's SOLIDWORKS Blog


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! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close