×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to Select Base Flange Sketch

How to Select Base Flange Sketch

How to Select Base Flange Sketch

(OP)
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.

RE: How to Select Base Flange Sketch

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)

RE: How to Select Base Flange Sketch

(OP)
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.  

RE: How to Select Base Flange Sketch

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

RE: How to Select Base Flange Sketch

(OP)
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.

RE: How to Select Base Flange Sketch

Doesn't a loft require two sketches?  What do you want to do in that case?

-handleman, CSWP (The new, easy test)

RE: How to Select Base Flange Sketch

(OP)
How can i make sure that i will always pick the Base Flange sketch ?

RE: How to Select Base Flange Sketch

(OP)
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.

RE: How to Select Base Flange Sketch

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

RE: How to Select Base Flange 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

End Sub

-handleman, CSWP (The new, easy test)

RE: How to Select Base Flange Sketch

(OP)
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 ?

RE: How to Select Base Flange Sketch

(OP)
Ignore my last post. The code that you posted does exactly what I need, thanks alot.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources