selecting face of feature in api

Discussion in 'SolidWorks' started by nils.toenissen, Aug 29, 2007.

  1. Hi there,

    I am quite new in API for solidworks, therefore I started with
    recording makros instead of writing it directly.

    In the recorded makros the typical selection method is SelectByID2.
    But when you are programming things you normally do not know the name
    or the click position of an entity.

    Is there a better way for selecting in a programm? I found the method
    FeatureByPositionReverse(0) to get the latest created feature. This
    seems to works okay. Is this the recommended way to select the the
    just created feature?

    In my particular case I want to select the face of a surface body,
    which i have just created plus an existing sketch to use the
    InsertWrapFeature. But I haven't get it to work...

    Selecting the Sketch and Face looks like this

    ...
    Dim swFeat As SldWorks.Feature
    Dim swAxis As SldWorks.Feature
    Dim swSketch As SldWorks.Feature
    Dim swFace As SldWorks.Face2
    Dim swEntity As SldWorks.entity
    Dim vFace As Variant
    Dim vFaceArr As Variant
    ....

    'sketch is just created
    Set swSketch = Part.FeatureByPositionReverse(0) 'sketch in
    swskecth

    'put the face in a selectable variable
    Set swFeat = Part.FeatureByPositionReverse(0)
    vFaceArr = swFeat.GetFaces: If IsEmpty(vFaceArr) Then Exit Sub
    Set vFace = vFaceArr(0)
    Set swFace = vFace
    Set swEntity = swFace

    'select
    boolstatus = swSketch.Select2(False, 0)
    boolstatus = swEntity.Select2(True, 0)

    'wrap sketch on face
    Part.FeatureManager.InsertWrapFeature 2, 0.008, 0


    Unfortunately the wrapping does not work. So i ask this forum. Maybe
    someone can help?

    Thanks!
     
    nils.toenissen, Aug 29, 2007
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.