Can you change selected window area without using ZOOM 'W' command?

Can you change selected window area without using ZOOM 'W' command?

Anonymous
Not applicable
526 Views
5 Replies
Message 1 of 6

Can you change selected window area without using ZOOM 'W' command?

Anonymous
Not applicable
I'd like to be able to zoom to a specific, pre-defined area using VBA WITHOUT using SendCommand "Zoom W ".

Can it be done and if so, could someone provide an example?

Thanks Jerry
0 Likes
527 Views
5 Replies
Replies (5)
Message 2 of 6

HJohn1
Advocate
Advocate
Have you tried Application.Zoom methods?
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi Jerry,

From the Help file:

object.ZoomWindow LowerLeft, UpperRight

Object

Application
The object this method applies to.

LowerLeft

Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the lower-left corner of the window to
display.

UpperRight

Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the upper-right corner of the window
to display.

Remarks

This method applies to the current active viewport (paper space viewport
or model space viewport).

See Also:

Methods and Properties:

ActivePViewport

ActiveViewport

Display

ZoomAll

ZoomCenter

ZoomExtents

ZoomPickWindow

ZoomPrevious

ZoomScaled

ActiveX and VBA Developer's Guide:

"Define a Zoom Window"

"Use Variants in Methods and Properties"

Code such as:

ZoomWindow PtLL, PtUR

requires less typing than SendCommand as well as working better.

Regards


Laurie Comerford


gmyroup wrote:
> I'd like to be able to zoom to a specific, pre-defined area using VBA
> WITHOUT using SendCommand "Zoom W ". Can it be done and if so, could
> someone provide an example? Thanks Jerry
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thanks... I'll give it a try!
0 Likes
Message 5 of 6

Anonymous
Not applicable
Hi Laurie

Thanks for your help... it does work better except when I'm trying to work in a view other than plan view.

I'm working on a project where the user picks to screen points in order to window and area. The points I'm using are pixels which I then translate into ACAD units using the following code. My problem is that this conversion only works in the plan view. Do you have any thoughts on how I can translate these points to UCS in views other than plan?

My current code:

Dim UpperLeft As POINTAPI
Dim ScreenSize As Variant
Dim ViewCenter As Variant
Dim ScreenCenter As POINTAPI
Dim ViewSize As Variant
Dim PixPerDu As Double
Dim Offset As Point2DDouble

ClientToScreen ThisDrawing.hwnd, UpperLeft
ScreenSize = ThisDrawing.GetVariable("SCREENSIZE")
ViewCenter = ThisDrawing.GetVariable("VIEWCTR")
ScreenCenter.X = UpperLeft.X + ScreenSize(0) / 2
ScreenCenter.Y = UpperLeft.Y + ScreenSize(1) / 2
PixPerDu = ScreenSize(1) / ThisDrawing.GetVariable("VIEWSIZE")
Offset.X = Abs(ScreenCenter.X - X)
Offset.Y = Abs(ScreenCenter.Y - Y)
If ScreenCenter.X < X Then
GetCoordinateFromScreen.X = ViewCenter(0) + (Offset.X / PixPerDu)
Else
GetCoordinateFromScreen.X = ViewCenter(0) - (Offset.X / PixPerDu)
End If
If ScreenCenter.Y > Y Then
GetCoordinateFromScreen.Y = ViewCenter(1) + (Offset.Y / PixPerDu)
Else
GetCoordinateFromScreen.Y = ViewCenter(1) - (Offset.Y / PixPerDu)
End If
GetCoordinateFromScreen.Z = 0
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Jerry,

Hope you have found solution for this issue.
If not Try with - object.ZoomCenter Center, Magnify

for Center, input the 3D point (x, y & z value)
for Magify, you can input current view size with your required proportion.

Regards,

SubuN
0 Likes