jbohrer
Industrial
- Aug 22, 2012
- 11
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