Jump to content

Recommended Posts

Posted

How can a person make a zoom window in VBA. In this case I would like to pick

two points on the screen to zoom window to. I would like for may vba program

to store the picked points for future use.

Thank you,

Posted

I have tryed this code but I am having problems with command send

Me.hide

pt1 = ThisDrawing.Utility.GetPoint(, vbCr & "Select Point 1: ")

pt2 = ThisDrawing.Utility.GetPoint(, vbCr & "Select Point 2: ")

'ThisDrawing.WindowState

ThisDrawing.SendCommand ("zoom" & vbCr & "w" & pt1 & pt2)

Me.Show

Posted

I know nothing of VBA, but I know there is a method ZoomWindow in LISP - may apply to VBA...

 

Here's my guess... and I have never written a thing in VBA...

 

ThisDrawing.ZoomWindow(pt1,pt2)

 

:lol:

  • 2 years later...
Posted

This code works with AutoCad 2007

 

pt1 = ThisDrawing.Utility.GetPoint(, vbCr & "Select Point 1: ")

pt2 = ThisDrawing.Utility.GetPoint(, vbCr & "Select Point 2: ")

y1$ = pt1(0): x1$ = pt1(1)

y2$ = pt2(0): x2$ = pt2(1)

ThisDrawing.SendCommand "zoom" & vbCr & "window" & vbCr & y1$ & "," & x1$ & vbCr & y2$ & "," & x2$ & vbCr

 

John

Posted

cor, an old thead!

 

To put Lee's mind at rest, this works.....

 

Public Sub aTest()
Dim myPoint1 As Variant
Dim myPoint2 As Variant
myPoint1 = ThisDrawing.Utility.GetPoint(, "BL Corner")
myPoint2 = ThisDrawing.Utility.GetPoint(, "TR Corner")
ZoomWindow myPoint1, myPoint2
End Sub

Posted

Hello

I found this thread while trying to write code for the zoom command event in Autocad. I want to redraw the labels on a graph, with the text size and placement dependent on the display extents as compared to the drawing extents. Here is the event driven code (not finished yet)

 

#

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)

'ZOOMED

If StrComp(CommandName, "Zoom", vbTextCompare) = 0 Then

'get display extents

'view center in WCS

ctr = ThisDrawing.GetVariable("VIEWCTR")

'convert in to DCS

ctr = ThisDrawing.Utility.TranslateCoordinates(ctr, acWorld, acDisplayDCS, 0)

'height of the viewport in DCS

h = ThisDrawing.GetVariable("VIEWSIZE")

minp = ctr: maxp = ctr

'calculate the width of the viewport in DCS

vph = ThisDrawing.ActiveViewport.Height

vpw = ThisDrawing.ActiveViewport.Width

w = vpw * h / vph

'calculate bounding view boundary in DCS

minp(0) = ctr(0) - w / 2

maxp(0) = ctr(0) + w / 2

minp(1) = ctr(1) - h / 2

maxp(1) = ctr(1) + h / 2

'show that the points are indeed the ones we are looking for

minp = ThisDrawing.Utility.TranslateCoordinates(minp, acDisplayDCS, acWorld, 0)

maxp = ThisDrawing.Utility.TranslateCoordinates(maxp, acDisplayDCS, acWorld, 0)

ThisDrawing.ModelSpace.AddLine minp, maxp

MsgBox ("Zoom command finished")

End If

End Sub

#

 

When SendCommand is used to zoom, the event routine works, when ZoomWindow is used, the event routine is not called, although the zoom window happens. I'd like to get rid of SendCommand.

 

Thank you

John

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...