By Adam Nagy
I'm trying to create a mate constraint between a work plane and the mid point of an edge, but I do not see how I could get back the middle vertex from the edge.
Solution
If you don't know how to do something through the API then a good starting point is to create the object through the user interface and then examine it through the API.
If you do that in this particular case then you'd see that EntityTwo of the MateConstraint is EdgeProxy and EntityTwoInferredType is kInferredPoint. If you create your mate constraint with that in mind then all should be fine:
Sub test()
Dim asm As AssemblyDocument
Set asm = ThisApplication.ActiveDocument
' Workplane from 1st occurrence
Dim wp As WorkPlaneProxy
Set wp = asm.SelectSet(1)
' Edge from 2nd occurrence
Dim e As EdgeProxy
Set e = asm.SelectSet(2)
Dim acs As AssemblyConstraints
Set acs = asm.ComponentDefinition.Constraints
Dim mate As MateConstraint
Set mate = acs.AddMateConstraint( _
wp, e, 0, kNoInference, kInferredPoint)
End Sub