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.
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.
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?
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
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 ?