Code Red > .NET
how select polyline and get current coordinates
(1/1)
franciscocsilva:
hello
who can help me?
I need select a polyline and read startpint ans end point in a current coordinate system.
I have this:
--- Code: ---Dim id1 As ObjectId = SelectSpecificObjectType(vbLf & "Select polyline: ", GetType(Polyline))
If id1.IsNull Then
Return
End If
--- End code ---
--- Code: ---Private Shared Function SelectSpecificObjectType(ByVal prompt As String, ByVal objectClass As System.Type) As ObjectId
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Using tr As Transaction = ed.Document.Database.TransactionManager.StartTransaction()
While True
Dim res As PromptEntityResult = ed.GetEntity(prompt)
If res.Status <> PromptStatus.OK Then
Return ObjectId.Null
End If
Dim ob As DBObject = tr.GetObject(res.ObjectId, OpenMode.ForRead)
If objectClass.IsAssignableFrom(ob.[GetType]()) Then
Return res.ObjectId
End If
ed.WriteMessage(vbLf & "Invalid selection, {0} entity expected", RXClass.GetClass(objectClass).DxfName)
End While
End Using
--- End code ---
--- Code: ---Dim lineA As Polyline = CType(acTrans.GetObject(id2, OpenMode.ForRead), Polyline)
IntersectionPointA = lineIntersectors(AuxMuroA.StartPoint, AuxMuroA.EndPoint, lineA.StartPoint, lineA.EndPoint)
--- End code ---
i need a current user coordinates system for lineA.
thank you
n.yuan:
Entity's coordinates in database are always World. If you need the coordinate in current UCS, simply transform the coordinate point with Editor.CurrentUserSystemCoordinate:, something like:
var ed=Application.DocumentManager.MdiDocument.Editor;
var startPt=LineA.StartPoint.TransformBy(ed.CurrentUserCoorinateSystem);
var endPt=LineA.EndPoint.TransformBy(ed.CurrentUserCoorinateSystem);
Similarly, if you picked point in current UCS that is different from World, before you use the point to do calculation with entity, you would translate the picked point into World coordinate system by transforming it with Editor.CurrentUserCooordinateSystem.Inverse().
franciscocsilva:
--- Quote from: n.yuan on June 09, 2020, 10:44:17 AM ---Entity's coordinates in database are always World. If you need the coordinate in current UCS, simply transform the coordinate point with Editor.CurrentUserSystemCoordinate:, something like:
var ed=Application.DocumentManager.MdiDocument.Editor;
var startPt=LineA.StartPoint.TransformBy(ed.CurrentUserCoorinateSystem);
var endPt=LineA.EndPoint.TransformBy(ed.CurrentUserCoorinateSystem);
Similarly, if you picked point in current UCS that is different from World, before you use the point to do calculation with entity, you would translate the picked point into World coordinate system by transforming it with Editor.CurrentUserCooordinateSystem.Inverse().
--- End quote ---
Thank you very much
emrahctrk:
do you have C# codes for this solution?
Atook:
--- Quote from: emrahctrk on October 15, 2020, 08:08:15 AM ---do you have C# codes for this solution?
--- End quote ---
https://codeconverter.icsharpcode.net/
Navigation
[0] Message Index
Go to full version