Create mate constraint with bias points

By Xiaodong Liang

With the arguments BiasPointOne and BiasPointTwo in AddMateConstraint , the occurrences should be repositioned to make the two bias points coincident. The BiasPoint used by method AddMateConstraint should be from model space. So you need to use the native object of the point to add this constraint. The code below assumes that two faces and two vetex of different occurrences in an assembly context are selected.

Sub constraintWithBiasPoints()          ' assume we have had the inventor application        Dim oDoc As Document        oDoc = _InvApplication.ActiveDocument             Dim oDef As AssemblyComponentDefinition        oDef = oDoc.ComponentDefinition             Dim oFaceProxy1 As FaceProxy        Dim oFaceProxy2 As FaceProxy             Dim oPointProxy1 As VertexProxy        Dim oPointProxy2 As VertexProxy             oFaceProxy1 = oDoc.SelectSet(1)        oFaceProxy2 = oDoc.SelectSet(2)        oPointProxy1 = oDoc.SelectSet(3)        oPointProxy2 = oDoc.SelectSet(4)             oDef.Constraints.AddMateConstraint(oFaceProxy1, _                                            oFaceProxy2, _                                            0, _                     InferredTypeEnum.kNoInference, _                     InferredTypeEnum.kNoInference, _                     oPointProxy1.NativeObject.Point, _                     oPointProxy2.NativeObject.Point)     End Sub

Comments

One response to “Create mate constraint with bias points”

  1. Hannes Juppes Avatar
    Hannes Juppes

    Yeah, maybe someone should mention, that if the subject to the added constraint is a workfeature instead of a face or edge, the biaspoint-coordinates are relative to the rootpoint of that particular workfeature , and not the origin of the definition of the occurrence that contains this workfeature, as otherwise. Took me half an afternoon to figure out, why my experiments here delivered results, that seemed to be completely random!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading