Sub ff()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Dim WPlans As WorkPlanes: Set WorkPlans = doc.ComponentDefinition.WorkPlanes
Dim p As Point: Set p = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)
Dim vec1 As UnitVector: Set vec1 = ThisApplication.TransientGeometry.CreateUnitVector(1, 0, 0)
Dim vec2 As UnitVector: Set vec2 = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
Dim oWorkPlane As WorkPlane
Set oWorkPlane = doc.ComponentDefinition.WorkPlanes. _
AddFixed(p, vec1, vec2)
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Item(1)
Dim oPartFace As Face
Set oPartFace = oOcc1.Definition.SurfaceBodies.Item(1).Faces(1)
Dim oPartFaceProxy As FaceProxy
Call oOcc1.CreateGeometryProxy(oPartFace, oPartFaceProxy)
' Create the constraint using the work plane proxies.
Call oAsmCompDef.Constraints.AddMateConstraint(oWorkPlane, oPartFaceProxy, 2)
End Sub