TheSwamp
Code Red => .NET => Topic started by: franciscocsilva on June 08, 2020, 07:35:36 AM
-
hello
who can help me?
I need select a polyline and read startpint ans end point in a current coordinate system.
I have this:
Dim id1 As ObjectId = SelectSpecificObjectType(vbLf & "Select polyline: ", GetType(Polyline))
If id1.IsNull Then
Return
End If
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
Dim lineA As Polyline = CType(acTrans.GetObject(id2, OpenMode.ForRead), Polyline)
IntersectionPointA = lineIntersectors(AuxMuroA.StartPoint, AuxMuroA.EndPoint, lineA.StartPoint, lineA.EndPoint)
i need a current user coordinates system for lineA.
thank you
-
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().
-
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().
Thank you very much
-
do you have C# codes for this solution?
-
do you have C# codes for this solution?
https://codeconverter.icsharpcode.net/