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!