×
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

dxf export macro

dxf export macro

dxf export macro

(OP)
Hi all,
I've been struggling with this project all week, so hopefully I can figure this out and be done with it.

I'm trying to export dxf files from a sheet metal part. each part has 2-4 flat patterns and a bunch of configurations. Frankly, the dxf export utility in solidworks is awful, it names them so that they are all out of order when I look at them in windows and ProNest. I found a macro that is close to what I need on the solidworks forums, but it only exports one flat pattern from the drawing. Is there any way to make this macro output all the flats on seperate dxf files? Thanks in advance!


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 = PathNoExtension + sConfigName & ".DXF"

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

Next i

End Sub

RE: dxf export macro

Are you running this macro from the drawing file (.SLDDRW) or the part file (.SLDPRT)? I see code in there that is grabbing all of the config names and ehtn looping through it... so it appears it is intended to do multiple DXF flats from a single file. Try running it in the part file if you previously ran it in a drawing.

-Dustin
Professional Engineer
Pretty good with SolidWorks

RE: dxf export macro

I looked at your file.

I don't understand your statement of "only one flat per configuration". How can you have more than one flat pattern for a given configuration? The exported DXF... is it actually the flat pattern? One thing to try. Create a derived configuration for each parent configuration... call it for example #47_FLAT_PATTERN. Then go into that derived config and unsupress the flat pattern feature... resulting in the part being flattened. Re-Run your macro.

-Dustin
Professional Engineer
Pretty good with SolidWorks

RE: dxf export macro

Do you have a multi-body sheet metal part?

RE: dxf export macro

(OP)
Limey got what I was trying to say. I'll try unsupressing the flat pattern and see what happens.

RE: dxf export macro

(OP)
well it's a no-go unsupressing it. Trying to learn to macro on the fly and there doesn't seem to be a whole lot of documentation that I can find. Anyone know of a good resource for learning to make a macro for SW?

RE: dxf export macro

I still don't understand your statement of "only one flat per configuration". How can you have more than one flat pattern for a given configuration?

You don't have a multibody sheetmetal part. I just ran that macro on the sample file you uploaded... it worked like a champ. I got one DXF for each of the 3 configurations in your model... 3 DXF's. The macro automatically added in the SM-FLAT-PATTERN derived config.

I am not clear on what your intended output is...

-Dustin
Professional Engineer
Pretty good with SolidWorks

RE: dxf export macro

Ahhh... that part is multibody. You will have to manually create two derived configurations. In each of the derived configs, unsupress ONE of the flat pattern features. Then run the macro.

Alternatively, create a drawing and insert flatpattern views... select the body etc. That will create the derived configs for you. I just did and it got two DXF files for the one config.

-Dustin
Professional Engineer
Pretty good with SolidWorks

RE: dxf export macro

(OP)
Thank you Shaggy, that's a huge time saver

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