I have a program that takes a selected drawing view and savesout a 1:1 drawing view as a dxf file that we send to the plasma. Ihaven't figured out how to get bend lines to save out so I can putthem on an etch layer.
If I manually save the drawing as a DXF, sometimes I have theoption to uncheck a box at the bottom of the SaveAs dialog to hidebend lines, so unchecking that box lets the bend lines comethrough. But that checkbox isn't always there - haven't figuredthat one out either. I even tried turning off the bend notes to seeif that made a difference - nope.
But anyway, I have instances where I can manually save out the maindrawing and the bend lines show up. And then if I run the programto create a new drawing with the selected flat pattern view, then Idon't get the bend lines.
Any thoughts?
SW2009 SP2
Macro is VB6
WTSolidworksApi macros



If I manually save the drawing as a DXF, sometimes I have theoption to uncheck a box at the bottom of the SaveAs dialog to hidebend lines, so unchecking that box lets the bend lines comethrough. But that checkbox isn't always there - haven't figuredthat one out either. I even tried turning off the bend notes to seeif that made a difference - nope.
But anyway, I have instances where I can manually save out the maindrawing and the bend lines show up. And then if I run the programto create a new drawing with the selected flat pattern view, then Idon't get the bend lines.
Any thoughts?
SW2009 SP2
Macro is VB6
WTSolidworksApi macros

Tim
So if the bend lines can show up with a direct save, why can't Iget them to show up with my program? I have searched for an APIcall that shows or hide sbend lines but i can't find one. Have Imissed it somewhere?
WT
I'm not sure that I understand you right but, are you saying thatwhen you do a dxf save through a drawing the bend lines don't showup ? and you want them to ?
WT
So when ever I ran my macro the bendlines were always hidden and inyour case you might want to do the opposite.
You can probably control that sketch button through the API aswell.
Ben Guenther wrote:
...by going to view and clicking the sketches button...
WT
WT
Set swFeat = swDoc.FirstFeature
Do While Not (swFeat Is Nothing)
If (swFeat.GetTypeName2 = "FlatPattern") Then
Set swSubFeat = swFeat.GetFirstSubFeature
Do While Not (swSubFeat Is Nothing)
If swSubFeat.GetTypeName2 = "ProfileFeature" Then
swSubFeat.Select2 True, 1
****Here the bend sketch would be selected and then you would putyour line that I gave you before******
End If
Set swSubFeat = swSubFeat.GetNextSubFeature
Loop
End If
Set swFeat = swFeat.GetNextFeature
Loop
I thought I could but I was wrong.
Dim swapp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
Dim swView As SldWorks.View
Dim swDraw As SldWorks.DrawingDoc
Dim swModel As SldWorks.ModelDoc2
Dim Retval As Boolean
Dim bendline As String
Sub main()
Set swapp = Application.SldWorks
Set swDoc = swapp.ActiveDoc
Set swDraw = swDoc
Set swView = swDraw.GetFirstView
Do While Not (swView Is Nothing)
Set swModel = swView.ReferencedDocument
If Not swModel Is Nothing Then
Set swFeat = swModel.FirstFeature
Do While Not (swFeat Is Nothing)
Debug.Print swFeat.Name
If (swFeat.GetTypeName2 = "FlatPattern") Then
Set swSubFeat = swFeat.GetFirstSubFeature
Do While Not (swSubFeat Is Nothing)
Debug.Print swSubFeat.Name
Debug.Print swSubFeat.GetTypeName2
If swSubFeat.GetTypeName2 = "ProfileFeature" Then
bendline = swSubFeat.Name
Retval = swDoc.Extension.SelectByID2(bendlines, "ProfileFeature",0#, 0#, 0#, True, 0, Nothing, swSelectOptionDefault)
swDoc.UnblankSketch
swDoc.BlankSketch
End If
Set swSubFeat = swSubFeat.GetNextSubFeature
Loop
End If
Set swFeat = swFeat.GetNextFeature
Loop
End If
Set swView = swView.GetNextView
Loop
End Sub
WT
Option Explicit
Dim swapp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
Dim swView As SldWorks.View
Dim swDraw As SldWorks.DrawingDoc
Dim swModel As SldWorks.ModelDoc2
Dim Retval As Boolean
Dim bendline As String
Sub main()
Set swapp = Application.SldWorks
Set swDoc = swapp.ActiveDoc
Set swDraw = swDoc
Set swView = swDraw.GetFirstView
Do While Not (swView Is Nothing)
Set swModel = swView.ReferencedDocument
If Not swModel Is Nothing Then
Set swFeat = swModel.FirstFeature
Do While Not (swFeat Is Nothing)
Debug.Print swFeat.Name
If (swFeat.GetTypeName2 = "FlatPattern") Then
Set swSubFeat = swFeat.GetFirstSubFeature
Do While Not (swSubFeat Is Nothing)
If swSubFeat.GetTypeName2 = "ProfileFeature" Then
bendline = swSubFeat.Name & "@" &GetFileName(swModel.GetPathName, False) & "@" & swView.Name
Retval = swDoc.Extension.SelectByID2(bendline, "SKETCH", 0#, 0#,0#, True, 0, Nothing, swSelectOptionDefault)
'swDoc.UnblankSketch
swDoc.BlankSketch
End If
Set swSubFeat = swSubFeat.GetNextSubFeature
Loop
End If
Set swFeat = swFeat.GetNextFeature
Loop
End If
Set swView = swView.GetNextView
Loop
End Sub
Public Function GetFileName(PathNameIn As String, IncludeExt AsBoolean) As String
If IncludeExt = False Then
PathNameIn = VBA.Left(PathNameIn, InStrRev(PathNameIn, ".", -1,vbTextCompare) - 1)
End If
PathNameIn = VBA.Right(PathNameIn, Len(PathNameIn) -InStrRev(PathNameIn, "\", -1, vbTextCompare))
GetFileName = PathNameIn
End Function
Let me know if it does not work or if you have any questions
Probably expect this to be in SP3-4 or 09, or at the latest in 2010SW.
Have you managed to get this request working yet or are you stillstruggling?
Yes, the code in my last post works to hide or show bendlines. It'skind of a lot of code to do a small little thing but that is theonly way I found it to work.
So, I'm not ignoring this, and very much appreciate the code, andam just itching to get back to it, but... you know how it is.Thanks.
WT
Hopefully after SWW I'll get a chance to review it. Thanks for theinterest, though.
WT
some times i would want the bend lines and some times i wouldnt,depends if our bender had a parrallel edge to zero from
i actually had a macro set up and i believe its in the "tools,options" world dialogue box to "see" the bend lines, that way anyold flat pattern will have all of the bend lines that go with it,BUT if i didnt want them i would have to hide the layer, so i wrotea macro in autocad to select that layer and either hide it orchange its color so then i could import it with a set map into ourother program to code it for the the laser or waterjet or plasmacutter
90% of the time i didnt need the bend lines so i mostly just keptthem off
the last thing i needed to do for my code was make a form with alist box together so i could have solidworks open all of the partsfor me and run the macro, save and close and then do the same thingfor autocad
my macro also saves the file as a ".dxf" of the same name in thesame folder on the network so if you want i can find it and post iton here
Ben Guenther wrote:
The code that I last posted does that do what you wanted ?
You seem the man to talk to about marcos.
what wayne is talking about is exactly what i required. could youpost it as a swp file. sorry i ant a code writer. .
will this marco. do (could)the following in one click?
save a pdf version of the drawing
save a profile drawing in 1:1 scale dxf format removing all linesand boarders.
save the profile (if it is a folded part)with etch lines where thefold lines are.
save the solidworks drawing.
can the location of each format dxf/pdf/solidwork drawing be saveda set location
i sorry it a long list. but life would be easiler if this waspossible.....
JOhn
http://forum.angelsix.com/viewtopic.php?f=26&t=17
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
swPart = swApp.NewPart()
Part.SheetPrevious
Part.SheetNext
boolstatus = Part.ExportFlatPatternView("C:\Flat pattern -MCQUICA2S00A03.DXF", 1)
longstatus = Part.SaveAs3("C:\Flat pattern - MCQUICA2S00A03.DXF",0, 0)
End Sub
We can see that nothing is changed on the macro code, but the linesDO disappear. Also they are using an obsolete function, becausethey suggest replacing SaveAs3 with ImodelDocExtension.SaveAs...
When I try to use the SaveAs function, I always get Error 256(invalid extension) even though the file is created.
I've been trying to save a dxf from a flatten part for some timeago, and I don't see in a near future a way to do it...
nigel bowen wrote:
I was lead to believe that there was an enhancement in 2008 todo this automatically?
The DXF file always end up with the bend lines.
My mistake, the bend lines never appear. I've tried with thefollowing test running from a addin:
IModelDoc2 doc = (ModelDoc2)SwApp.ActiveDoc;
var finalName = @"c:\teste.dxf";
try
{
var Part = (PartDoc)doc;
Part.ExportFlatPatternView(@finalName, 0);
}
catch (Exception e)
{
Console.WriteLine(e);
}
my macro
I've wrote code BatchProcess for generate dxf-files, but i've one problem. The macro not scanning sub-folders for selected folder.