Hi,
I run two pieces of code, of which returns two different values when UCS is not set to world.
I am obtaining a window via a user prompt, Which translates correctly to the UCS,.
When getting the Geometric Extents of a block I get the correct window, when UCS = World, However when it is not, it does not give me the correct result.
There is some thing simple that I am missing, Any help would be greatly appreciated.
UCS translate
Public Function Translate(ByVal Point As Point3d) As Point3d
' Transform from UCS to DCS
Dim rbFrom As New ResultBuffer(New TypedValue(5003, 1)), rbTo As New ResultBuffer(New TypedValue(5003, 3))
Dim firres As Double() = New Double() {0, 0, 0}
' Transform the first point...
acedTrans(Point.ToArray(), rbFrom.UnmanagedObject, rbTo.UnmanagedObject, 0, firres)
Dim result As New Point3d(firres)
Return result
End Function
Get Window
Public Function ActiveSpaceGetWindow() As Extents2d
Dim AcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim AcDB As Database = AcDoc.Database
Dim AcEd As Editor = AcDoc.Editor
Dim Result1 As PromptPointResult = Nothing
Dim Result2 As PromptPointResult = Nothing
Try
Dim PointOP1 As New PromptPointOptions(vbLf & "Select first corner : ")
PointOP1.AllowNone = False
Result1 = AcEd.GetPoint(PointOP1)
If Result1.Status <> PromptStatus.OK Or Result1.Value = Nothing Then
Return Nothing
End If
Dim Pt1 As Point3d = Result1.Value
Dim CornOP1 As New PromptCornerOptions(vbLf & "Select second corner : ", Result1.Value)
Result2 = AcEd.GetCorner(CornOP1)
If Result2.Status <> PromptStatus.OK Or Result2.Value = Nothing Then
Return Nothing
End If
'' Transform from UCS to DCS
Dim Point1 As Point3d = Translate(Result1.Value)
Dim Point2 As Point3d = Translate(Result2.Value)
Return New Extents2d(Point1.X, Point1.Y, Point2.X, Point2.Y)
Catch ex As System.Exception
If Result1 IsNot Nothing AndAlso Result2 IsNot Nothing Then
Return New Extents2d(Result1.Value.X, Result1.Value.Y, Result2.Value.X, Result2.Value.Y)
Else
Return Nothing
End If
End Try
Return Nothing
Get Block extents
dim Blk as blockreference
Dim Extents As Extents3d = Blk.GeometricExtents
Dim PointOne As Point3d = Translate(Extents.MinPoint)
Dim PointTwo As Point3d = Translate(Extents.MaxPoint)
Dim d2Extents As Extents2d = New Extents2d(PointOne.X, PointOne.Y, PointTwo.X, PointTwo.Y) 'Convert to 2d