I am checking to see if anyone has developed a macro that saves a flat pattern sheetmetal dxf file using the configuration name. I have sheet metal parts that have numerous configurations, all of the parts have unique configuration names.
Chad, Tobin on the http://eng-tips.com/ confirmed that code is working after adding .DXF instead of DXF. Strange didn't worked for me earlier but Its working now.
Option ExplicitSub 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 StringDim PathSize As LongDim PathNoExtension As StringDim NewFilePath As StringFilePath = swModel.GetPathNamePathSize = Strings.Len(FilePath)PathNoExtension = Strings.Left(FilePath, PathSize - 6)NewFilePath = PathNoExtension + sConfigName & ".DXF"'Export Flat Pattern bRet = swModel.ExportFlatPatternView(NewFilePath, 1) Next iEnd Sub
This might be of some use
DocExport : Assists user in exporting selected SolidWorks model configurations or SolidWorks drawing sheets to different file types. This is useful when you need to separate many configurations into individual files of another file type for a vendor to use/reference.
Let me see if I can modify it.
Check Lenny's site http://www.lennyworks.com/
Thanks for the updates. I'm still messing (as having little knowledge for the API) and trying to combine few macros to get the job done. Will update you once I have something useful.
What error message are you being given?
Have you checked that the correct libraries are being called in the Tools > References section of the VB editor?
I checked my referances and they all seem to be in order as your screen shot looks. When I run the macro, it seems to run ok except there are no files in the directory.
I do not get an error but nothing shows up in the Immediate window when I run the macro while VB is open. Here is a screen shot of what I have.
Retrieving data ...