Public Sub SetEntCoincidentConstraint(ByVal curve1 As Curve, ByVal ent1 As Entity, ByVal curveEnd1 As CurvePoint, ByVal entType As SubentityType, ByVal trans As Transaction)
Using trans2 As Transaction = trans.TransactionManager.StartTransaction 'work with sub transactions in order to allow 1 undo that undoes it all.
Dim SubEntEdgePath1 As FullSubentityPath 'logical path to the edge (one edge object pretty simple)
Dim SubEntEdgePath2 As FullSubentityPath
Dim subEntPointPath1 As FullSubentityPath 'logical path to the user selected point (usually start, end, or mid)
Dim subEntPointPath2 As FullSubentityPath
'create a logical path from the object to its sub entities
CreateSubEntityPath(curve1, curveEnd1, SubEntEdgePath1, subEntPointPath1, trans2)
SubEntEdgePath2 = CreateSubEntityPath(ent1, entType) 'cutting point
subEntPointPath2 = CreateSubEntityPath(ent1, entType) 'point where
'get the constraint group that exists on the same plane as our points (in this case just wcs + elevation, but if you get more advanced, this may need to be modified big time)
Dim consGrpId As ObjectId = GetConstraintGroup(True, trans2)
'use the logical paths to create a constraint between 2 selected points(CurvePoint) of the 2 supplied edges(curves)
Dim consGeomEdge1 As ConstrainedGeometry = Nothing
Dim consGeomEdge2 As ConstrainedGeometry = Nothing
Using constGrp As Assoc2dConstraintGroup = DirectCast(trans2.GetObject(consGrpId, OpenMode.ForWrite, False), Assoc2dConstraintGroup)
Try
consGeomEdge1 = AddConstrainedGeometry(constGrp, SubEntEdgePath1)
Catch ex As Exception
'aready there move on
End Try
Try
consGeomEdge2 = AddConstrainedGeometry(constGrp, SubEntEdgePath2)
Catch ex As Exception
'aready there move on
End Try
Dim paths As FullSubentityPath() = {subEntPointPath1, subEntPointPath2}
Dim newConstraint As GeometricalConstraint = constGrp.AddGeometricalConstraint(GeometricalConstraint.ConstraintType.Coincident, paths)
End Using
trans2.Commit()
End Using
End Sub