I am trying to create a macro to perform repetitive bends in Solidworks.
Basically I have a large sheet metal part that will be split into your standard 48" x 120" 10 ga. sheets. To accomplish this (as the part contains lofted features) I have cut the part which is 100' long into 10' sections and then created dxf's of my flat pattern and imported the dxf's into new part drawings. At this point I have parts that are 10' long but still 4 sheets wide so i split it up again.
Long story short I have a flat part with bend lines that need the bends added in.
I record a macro which selects sketch 3 (which has one of the bend lines in it), selects the face and inserts the bend angle; problem being that when you select a face the side of the face that you click on relative to the bend is critical. I know a small amount about vb and from what I can tell when I select a face it is taking the coordinates of the location that I have clicked which will not be interchangable from part to part.
Here is a copy of the macro I recorded (there are five bends that are recorded):
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Sketch3", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.290347279004, -0.1772684433273, 0, True, 0, Nothing, 0)
Dim CBAObject As Object
Dim myFeature As Object
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(0.629144219109, True, 0.0037084, False, 0, CBAObject)
boolstatus = Part.Extension.SelectByID2("Sketch4", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.161032084972, 1.106646697417, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(0.9429138259244, True, 0.0037084, False, 0, CBAObject)
boolstatus = Part.Extension.SelectByID2("Sketch5", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.144363998393, 1.391540631547, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(1.570796326795, True, 0.0037084, True, 0, CBAObject)
boolstatus = Part.Extension.SelectByID2("Sketch6", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.117725433927, 1.789351811615, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(1.570184141564, True, 0.0037084, True, 0, CBAObject)
boolstatus = Part.Extension.SelectByID2("Sketch7", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.123873324948, 2.858837646762, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(1.570796326795, True, 0.0037084, False, 0, CBAObject)
End Sub
SolidworksApi macros
