Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to Select Base Flange Sketch 1

Status
Not open for further replies.

bguenther

Mechanical
Nov 3, 2008
37
Hi,
I am in a situation where I need to select the base flange sketch. I have code to select "Sketch 1" but I don't know if the base flange will always be sketch 1.

Part.SelectByID "Sketch1", "SKETCH", 0, 0, 0

Could somebody help with this ? Thanks.
 
Replies continue below

Recommended for you

I'm not sure what you mean by the "base flange". When you look at a part on your screen, how can you tell which is the base flange?

-handleman, CSWP (The new, easy test)
 
Sorry for not being clear. The feature that I referring to creates the part as a sheetmetal and in my solidworks by default it is always called base-flange1 but just thinking about it now it could be a sheetmetal loft as well. I would like to select the sketch that creates the body of the part and only on sheetmetals parts so they will only have 1 body.
 
The Base Flange for a sheet metal part will always be the first feature in the tree, and therefor will always contain the first sketch.

[cheers]
 
But somebody could make a sketch to place a plane on or for reference then that would be sketch 1 and the Base Flange sketch would be number 2.
 
Doesn't a loft require two sketches? What do you want to do in that case?

-handleman, CSWP (The new, easy test)
 
How can i make sure that i will always pick the Base Flange sketch ?
 
I guess that a loft might almost be too complicated then. Maybe I will just put an if statement if it is a loft then it does not work.
 
I have no idea what you are trying to achieve, but if you can determine whether a Base Flange or a Lofted Bend has been used, could you not use an IF statement to force the selection of a second sketch?

[cheers]
 
Dim swapp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature

Sub main()

Set swapp = Application.SldWorks
Set swDoc = swapp.ActiveDoc
Set swFeat = swDoc.FirstFeature
Do While Not (swFeat Is Nothing)
If (swFeat.GetTypeName2 = "SMBaseFlange") Or (swFeat.GetTypeName2 = "LoftedBend") Then
Set swSubFeat = swFeat.GetFirstSubFeature
Do While Not (swSubFeat Is Nothing)
If swSubFeat.GetTypeName2 = "ProfileFeature" Then
swSubFeat.Select2 True, 1
End If
Set swSubFeat = swSubFeat.GetNextSubFeature
Loop
End If
Set swFeat = swFeat.GetNextFeature
Loop

End Sub

-handleman, CSWP (The new, easy test)
 
ok lets give this one more try. Forget about lofted bends lets just focus on Base Flange.

I want to select the sketch that was used to create the Base Flange.

Example: The user makes a sketch and uses the sketch to make a plane. Now the user selects that plane and makes a sketch on it and uses that sketch to create the base flange so in the feature manager tree you have 2 sketches. How will the macro know which sketch is the sketch used to create the base flange ?
 
Ignore my last post. The code that you posted does exactly what I need, thanks alot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor