When you used Entity.Select4, did you use a SelectData object to set the Mark?
I currently have this (shortened, C#)
SelectData swSelData = swSelMgr.CreateSelectData();
swSelData.Mark = 257;
Entity swEntity = (Entity)swEdge;
status = swEntity.Select4(true, swSelData);
And the Select4 returns false for some reason thus the status = false.
Afterwards I try to call the InsertFillSurface2 method with swSelData as an argument for the boundries, obviously not working because the selection was unsuccessful.
A specified in API help, edges MUST be selected using IModelDocExtension::SelectByID2 method. I don't think selecting edges using IEntity::Select4 method will work. Could you attach your part, so someone can have a look?
I think it should work with Select4, because the example it gives in the reference page for InsertFillSurface2 shows exactly that.
Look at "Get and Fill Gaps in Body Example (VBA)".
You are right, I just looked at the remarks which says 'MUST'. Whenever I get a change, I will play with both options.
The part is Attached now.
I agree with what Simon said, also in my case I need to select more than 1 Edge for the boundary.
I thought of making a new sketch with converting the entities but this probably will take much longer.
As this is only a minor sub routine in my whole macro I would want to avoid time consuming procedures.
By the way, the only reason I want to do that (select edges) is to find which contour is the most outer contour, by filling all contours and than check which has the greatest area.
So if you guys have any other idea of how to achieve this, it will be great.
Example1.SLDPRT.zip 77.9 KB
This VBA code selects the outer loop of any selected face:
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim selMgr As SelectionMgr
Dim selData As SelectData
Dim myFace As Face2
Dim myLoop As Loop2
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
If Part Is Nothing Then Exit Sub
Set selMgr = Part.SelectionManager
If selMgr.GetSelectedObjectCount2(-1) <> 1 Then Exit Sub
If selMgr.GetSelectedObjectType3(1, -1) <> swSelFACES Then Exit Sub
Set selData = selMgr.CreateSelectData
Set myFace = selMgr.GetSelectedObject6(1, -1)
Set myLoop = myFace.GetFirstLoop
While Not myLoop Is Nothing
If myLoop.IsOuter Then ProcessLoop myLoop
Set myLoop = myLoop.GetNext
Sub ProcessLoop(myLoop As Loop2)
Dim myCoEdges As Variant
Dim myCoEdge As CoEdge
Dim myEdge As Edge
Dim myEnt As Entity
Dim i As Integer
myCoEdges = myLoop.GetCoEdges
If IsEmpty(myCoEdges) Then Exit Sub
For i = 0 To UBound(myCoEdges)
Set myCoEdge = myCoEdges(i)
Set myEdge = myCoEdge.GetEdge
Set myEnt = myEdge
myEnt.Select4 True, Nothing
I am still on SW2015 and can't open your part. But I will play with both options.