muck Posted May 19, 2009 Posted May 19, 2009 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, Quote
muck Posted May 19, 2009 Author Posted May 19, 2009 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 Quote
Lee Mac Posted May 19, 2009 Posted May 19, 2009 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) Quote
John1951 Posted July 6, 2011 Posted July 6, 2011 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 Quote
dbroada Posted July 6, 2011 Posted July 6, 2011 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 Quote
John1951 Posted July 6, 2011 Posted July 6, 2011 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 Quote
Recommended Posts
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.