Author Topic: how select polyline and get current coordinates  (Read 437 times)

0 Members and 1 Guest are viewing this topic.

franciscocsilva

  • Mosquito
  • Posts: 13
how select polyline and get current coordinates
« 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:

Code: [Select]
Dim id1 As ObjectId = SelectSpecificObjectType(vbLf & "Select polyline: ", GetType(Polyline))

        If id1.IsNull Then
            Return
        End If

Code: [Select]
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

Code: [Select]
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

n.yuan

  • Bull Frog
  • Posts: 292
Re: how select polyline and get current coordinates
« Reply #1 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().

franciscocsilva

  • Mosquito
  • Posts: 13
Re: how select polyline and get current coordinates
« Reply #2 on: July 20, 2020, 07:19:14 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().

Thank you very much