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
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
-Dustin
Professional Engineer
Pretty good with SolidWorks
RE: dxf export macro
RE: dxf export macro
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
RE: dxf export macro
RE: dxf export macro
RE: dxf export macro
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
RE: dxf export macro
RE: dxf export 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
-Dustin
Professional Engineer
Pretty good with SolidWorks
RE: dxf export macro