Page 1 of 1
UTM to Cadviewx
Posted: 05 Apr 2006, 21:00
by chernandez
Hi,
I have this data in my applicattion
Center, Top-Left, Top-Right, Bottom-Left, Bottom-Right in UTM Coordinates. How to translate this view to CadViewX?
Thanks,
Carlos
Posted: 07 Apr 2006, 13:49
by support
Hello Carlos,
The following code is an example how to view a part of the drawing by CADViewX. The example is in Visual Basic:
Code: Select all
Public Sub ShowRect(ARect As tagFRectLong)
Dim FPoint As CADViewLib.tagFPoint
Dim vExt As CADViewLib.tagFRectLong
Dim vTopLeft As CADViewLib.tagFPoint
Dim vBottomRight As CADViewLib.tagFPoint
Dim vParentRect As CADViewLib.TxRectLong
Dim vPicRect As TxRectPoint
Dim vBoundsRect As TxRectPoint
Dim vLeft, vTop, PicW, PicH, BoundW, BoundH, ParentW, ParentH As Integer
Dim vScale, vScaleX, vScaleY As Double
With Form1.CADViewX1
If .IsVectGraphic Then
//Get global size points of the drawing
vExt = .DXFImage.Extents
vTopLeft = .MkFPoint(vExt.Left, vExt.Top, 0)
vBottomRight = .MkFPoint(vExt.Right, vExt.Bottom, 0)
//Convert global sizes points to image points
vBoundsRect.TopLeft = .DXFImage.GetPoint(vTopLeft)
vBoundsRect.BottomRight = .DXFImage.GetPoint(vBottomRight)
BoundW = vBoundsRect.BottomRight.X - vBoundsRect.TopLeft.X
BoundH = vBoundsRect.BottomRight.Y - vBoundsRect.TopLeft.Y
//Convert global sizes points of desired area of the drawing to image points
vTopLeft = .MkFPoint(ARect.Left, ARect.Top, 0)
vBottomRight = .MkFPoint(ARect.Right, ARect.Bottom, 0)
vPicRect.TopLeft = .DXFImage.GetPoint(vTopLeft)
vPicRect.BottomRight = .DXFImage.GetPoint(vBottomRight)
PicW = vPicRect.BottomRight.X - vPicRect.TopLeft.X
PicH = vPicRect.BottomRight.Y - vPicRect.TopLeft.Y
//Find scale factors for OX and OY axises of the image
vScaleX = vPicRect.TopLeft.X / BoundW
vScaleY = vPicRect.TopLeft.Y / BoundH
//Find sizes of the area on the image for drawing on the display
vParentRect = .ImageParentClientRect
ParentW = vParentRect.Right - vParentRect.Left
ParentH = vParentRect.Bottom - vParentRect.Top
//Determine longest size of the area on the image for drawing and
//correct scale factors for OX and OY axises of the image
If ParentW > ParentH Then
If PicW > PicH Then
vScale = PicW / ParentW
Else
vScale = PicH / ParentW
End If
Else
If PicW > PicH Then
vScale = PicW / ParentH
Else
vScale = PicH / ParentH
End If
End If
//Final scaling of the area on the image
If vScale <> 0 Then
BoundW = Round(BoundW / vScale)
BoundH = Round(BoundH / vScale)
End If
//Combining of area on the image and displaying area
vLeft = Round(-BoundW * vScaleX)
vTop = Round(-BoundH * vScaleY)
//Drawing
.ImageAlign = alxNone
.SetImageBounds vLeft, vTop, BoundW, BoundH
End If
End With
End Sub
Sergey.
please post questions to the forum or write to
support@cadsofttools.com