Hi,
first I get an exception as the polyline you used get's accessed outside the active transaction. That is not safe.
I then converted part of the code to create a transaction before I use the polyline.GetClosestPointTo and then polyline.GetParameterAtPoint and can't see any differences between the values I get reported from VisualStudio and the ones from AutoCAD directly.
So either the issue is that you close/dispose your transaction before you try to get properties from it (or calculations like polyline.Get...) or I'm doing anything in another way than you do. I see that I have to start command "11", but what points I should show or what entity I have to select then ... don't know that.
The code I created to get the point1 and point2 converted to parameter is that (in VB.NET, you can convert it using public converters in the www).
Dim tTrAct As Transaction = Nothing
Try
tTrAct = centerLineEntity.Database.TransactionManager.StartOpenCloseTransaction
Dim tCurve As Curve = TryCast(tTrAct.GetObject(centerLineEntity.ObjectId, OpenMode.ForRead), Curve)
If tCurve IsNot Nothing Then
'get param for first point
Dim pintNea As Point3d = tCurve.GetClosestPointTo(startPoint, False)
Dim paramStart As Double = tCurve.GetParameterAtPoint(pintNea)
'get param for second point
Dim pintNea2 As Point3d = tCurve.GetClosestPointTo(endPoint, False)
Dim paramEnd As Double = tCurve.GetParameterAtPoint(pintNea2)
End If
Catch generatedExceptionName As System.Exception
'TODO exception handling
Finally
If tTrAct IsNot Nothing Then tTrAct.Dispose() : tTrAct = Nothing
End Try
- alfred -
------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ...
blog.ish-solutions.at ...
LinkedIn ...
CDay 2026------------------------------------------------------------------------------------
(not an Autodesk consultant)