Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Face selection using the record macro feature

Status
Not open for further replies.

JMesz

Mechanical
Jun 16, 2010
7
Hi all, I have a number of parts that need the same five bends added to them. I want to create a macro to accomplish this. To simplify this, this is what I need to do:

1. Take my flat sheet metal part that has five sketches each containing a bend line and select Sketch3 (my first bend).
2. Select the Sketched Bend feature.
3. Select a face that the bend occurs on. This is what I am having troubles with.
4. Enter the angle of bend.
5. Repeat.

Should be pretty simple but when recording this macro clicking on this face comes up with merely a coordinate of where I clicked as far as I know. I am not very proficient with VB so I do not know what to input as code to select this face rather than a coordinate as my parts get bigger and bigger as I go along. Also the side of the face that you click on relative to the bend will determine what face will be fixed in space when this bend is performed and which will be folded (this is critical, as - if the face with my other sketches moves my sketches will not serve as bend lines any more).

Heres the code:

Sub main()

Set swApp = Application.SldWorks
Dim CBAObject As Object
Dim myFeature As Object
Dim myModelView As Object
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Sketch3", "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.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.117725433927, 1.789351811615, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSheetMetal3dBend(1.570184141564, True, 0.0037084, False, 0, CBAObject)

End Sub


Here's the Files:

Unbent Part:


Bent Part:


Macro:

 
Replies continue below

Recommended for you

Can anyone confirm whether or not they have looked into this?
 
I posted on the SW forums last week and still have no responses unfortunately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor