Thilak,
You have my admiration and respect. I'm still confused about why some
drawings worked and some did not but using the displayDCS instead of UCS
seems to work under all circumstances so I guess it doesn't matter so much.
Thank you very much.
-mjm
"Thilak" wrote in message
news:ef06b16.0@WebX.SaUCah8kaAW...
> Hi Michael,
>
> Check this out.
>
> While using GetPoint method of AcadUtility object to obtain the points,
you
> must translate the coordinates to DCS (Display Coordinate System) before
you
> can use them in SetWindowToPlot method of Layout object.
>
> GetPoint method (which allows you to pick a point on the screen) returns
you
> the picked point's 3D coordinates in WCS (i.e. World Coordinate System).
So
> you must translate the points from WCS to DCS before passing them to
> SetWindowToPlot method. Please find below a sample code which highlights
how
> to achieve this.
>
> For more details please refer the online help of AutoCAD VBA ActiveX and
VBA
> Developer's Guide->Chapter 8 -- Working in Three-Dimensional Space->
> Converting Coordinates
>
>
> Option Explicit
> Sub f_plotWindow()
> 'paste this code in VBA of AutoCAD2000
> 'declare the required variables
> Dim po_lay As AcadLayout
> Dim p1 As Variant
> Dim p2 As Variant
>
> Set po_lay = ThisDrawing.ActiveLayout
>
> 'get two points
> p1 = ThisDrawing.Utility.GetPoint(, "first point")
> p2 = ThisDrawing.Utility.GetCorner(p1, "second point")
>
> 'translate the points which are in World UCS to Display coordinates
> p1 = ThisDrawing.Utility.TranslateCoordinates(p1, acWorld,
acDisplayDCS,
> False)
> p2 = ThisDrawing.Utility.TranslateCoordinates(p2, acWorld,
acDisplayDCS,
> False)
>
> 'change the variables from 3 element array to 2 element array
> ReDim Preserve p1(0 To 1)
> ReDim Preserve p2(0 To 1)
>
> 'reorder the points to lower left and upper right corner irrespective
of
> the way user selects the points
> Call f_setCoord(p1, p2)
> po_lay.SetWindowToPlot p1, p2
> po_lay.PlotType = acWindow
>
> ThisDrawing.Plot.DisplayPlotPreview acFullPreview
> End Sub
>
> Sub f_setCoord(p1 As Variant, p2 As Variant)
> Dim pd_xMin As Double
> Dim pd_yMax As Double
>
> If p1(0) > p2(0) Then
> pd_xMin = p2(0)
> p2(0) = p1(0)
> p1(0) = pd_xMin
> End If
> If p1(1) > p2(1) Then
> pd_yMax = p2(1)
> p2(1) = p1(1)
> p1(1) = pd_yMax
> End If
> End Sub
>
>
> Cheers,
> Thilak
>
> michael montagne wrote in message
> news:ef06b16.-1@WebX.SaUCah8kaAW...
> > I have posted a drawing to the customer files that illustrates a
peculiar
> > problem I'm having. There is an embedded sub called
> > "getthedarnplotwindowright". It attempts to allow the user to specify a
> > plot window. Then it displays the preview. It also draws a line as a
> check
> > that the coordinates are correct. On certain drawings, the preview will
> not
> > calculate correctly, this is one. If you insert this drawing into a
fresh
> > drawing, it will work correctly. My question is: What is it about this
> > drawing (and others) that is causing this malfunction?
> >
> > thanks for your help,
> >
> > -mjm
> >
>