I have a macro from Artem Taturevich and it works very well. However, I would like to turn off bend line export on some flat patterns. Is there a way to prompt the user to select which flat patterns to include bend lines and which to leave out?
I have a macro from Artem Taturevich and it works very well. However, I would like to turn off bend line export on some flat patterns. Is there a way to prompt the user to select which flat patterns to include bend lines and which to leave out?
The line that actually creates the export is:
If False = part.ExportToDWG2(outFilePath, modelPath, swExportToDWG_e.swExportToDWG_ExportSheetMetal, True, Empty, False, False, opts, Empty) Then
It has an argument called opts which holds the export options.
Completely at the top, there is a list (an enum actually) of options and just below that, the options that are being used:
Const FLAT_PATTERN_OPTIONS As Integer = SheetMetalOptions_e.ExportBendLines + SheetMetalOptions_e.ExportFlatPatternGeometry
The options are a sum of the enum values, so you can change this sum to change the export options. If you want to change its value in code, remove the Const and replace it with
Dim FLAT_PATTERN_OPTIONS As SheetMetalOptions_e
You could then, for example, add:
Sub main()
Dim result As Integer
result = MsgBox("Show bend lines?", vbYesNo)
If result = vbYes Then
FLAT_PATTERN_OPTIONS = SheetMetalOptions_e.ExportBendLines + SheetMetalOptions_e.ExportFlatPatternGeometry
Else
FLAT_PATTERN_OPTIONS = SheetMetalOptions_e.ExportFlatPatternGeometry
End If
More info: 2017 SOLIDWORKS API Help - ExportToDWG2 Method (IPartDoc)
Peter Brinkhuis wrote:
The line that actually creates the export is:
If False = part.ExportToDWG2(outFilePath, modelPath, swExportToDWG_e.swExportToDWG_ExportSheetMetal, True, Empty, False, False, opts, Empty) Then
It has an argument called opts which holds the export options.
Completely at the top, there is a list (an enum actually) of options and just below that, the options that are being used:
Const FLAT_PATTERN_OPTIONS As Integer = SheetMetalOptions_e.ExportBendLines + SheetMetalOptions_e.ExportFlatPatternGeometry
The options are a sum of the enum values, so you can change this sum to change the export options. If you want to change its value in code, remove the Const and replace it with
Dim FLAT_PATTERN_OPTIONS As SheetMetalOptions_e <<Not quite sure what you mean by this. Should I edit the enum values and the Const statement? Or replace the Const with "Dim FLAT_PATTERN_OPTIONS As SheetMetalOptions_e"..??
You could then, for example, add:
Sub main()
Dim result As Integer
result = MsgBox("Show bend lines?", vbYesNo)
If result = vbYes Then
FLAT_PATTERN_OPTIONS = SheetMetalOptions_e.ExportBendLines + SheetMetalOptions_e.ExportFlatPatternGeometry
Else
FLAT_PATTERN_OPTIONS = SheetMetalOptions_e.ExportFlatPatternGeometry
End If
More info: 2017 SOLIDWORKS API Help - ExportToDWG2 Method (IPartDoc)
See my note above in the quote. I *think* I understand the rest, but I'm not quite sure what I'm supposed to edit.
Thanks a lot for your help!
I believe Michael is looking for selective options for different flat patterns in a single run, i.e. something like a list of all patterns about to be exported in the first column and the check box in the second column so the bend line can be turned off and one for specific patterns only (not for the whole job) - although I might get it wrong.
Artem Taturevych wrote:
I believe Michael is looking for selective options for different flat patterns in a single run, i.e. something like a list of all patterns about to be exported in the first column and the check box in the second column so the bend line can be turned off and one for specific patterns only (not for the whole job) - although I might get it wrong.
Initially, yes. However after some discussion here, we decided that turning it on or off per job will serve our purposes.
Peter Brinkhuis, I started experimenting and it works! I removed the entire "Const" statement and replaced it with "Dim FLAT_PATTERN_OPTIONS As SheetMetalOptions_e" (not just the Const word). Then I copied the code for the VB message box into Sub main.
It all makes sense now. Instead of defining sheet metal options in the main program, it is defined by the Yes/No results in the sub.
I'm still pretty green at API but I'm starting to catch on!
The line that actually creates the export is:
It has an argument called opts which holds the export options.
Completely at the top, there is a list (an enum actually) of options and just below that, the options that are being used:
The options are a sum of the enum values, so you can change this sum to change the export options. If you want to change its value in code, remove the Const and replace it with
Dim FLAT_PATTERN_OPTIONS As SheetMetalOptions_e
You could then, for example, add:
More info: 2017 SOLIDWORKS API Help - ExportToDWG2 Method (IPartDoc)