In the image below, the active component is my component 1. It has a point (refer to the image). the point is used to create a hole on the part. The inactive component is my component 2. On one of its faces, It has a circular edge created because of a hole. so it is not a sketch, just a edge because of a hole. I am trying to create concentric relation between the edge and the point.
In GUI I can just select the two and click add relation. API seems to be unable to select the edge.
I was trying to do it this way based on the recommendation given in this page: http://www.cadsharp.com/videos/lesson-4-1-vba/
Update 2: 2/18/2014 3:45PM
Next I tried the same thing but without making the current sketch active with the editSketch call. This resulted in error - the selected sketch is not valid for the operation. I am assuming this was invalid because no sketch is in the edit mode.
In addition, I also added the following two commandsto see it it works in both the cases. It didn't add relation in both cases.
Update 3: 2/18/2014 4:34 PM
Next Once I am in edit sketch mode (image in second comment), I tried finding edges of component 2 while the component 2 is still in inactive mode (or component 1 is in edit mode). Looks like I was able to find all the faces, but when I start extracting edges from each face, (see the code below), I got a error "the object invoked has disconnected from its client"
swModDoc.EditSketch 'Edit Sketch
For j = 0 To UBound(AllTheFacesFromComponent2)
Set Face = AllTheFacesFromComponent2(j)
Dim Edges As Variant
Edges = Face.GetEdges' Got ERROR HERE
For Each edge In Edges:
I still haven't figured out how to add concentric relation between the point and the edge.
Answer : The selection was not working because I had the same part imported twice in my assembly, and the mate was between two instances of the same part file.
When I tried using two different parts, selecting with the select4 worked fine.
If you have the same part imported twice in an assembly, using select by id2 is the way to go.