Jump to content

Snapping to objects when zooming in Viewport


Recommended Posts

Try:

(defun c:ZSnapOld ( / pt1 pt2)
    (setq pt1 (getpoint "\nSelect First Window Point: "))
    (setq pt2 (getcorner pt1 "\nSelect Second Window Point: "))
    (command "._zoom" "_w" pt1 pt2) ; end zoom
)

It should snap to whatever osnap settings you're alteady using.

Sometimes simple is best.

  • Thanks 1
Link to comment
Share on other sites

This more complicated version will also temporarily toggle Osnaps on while Zooming if needed for newer versions.

; Zoom Window using Osnap settings by Tom Beauford
; Macro: ^P(or C:ZSnap (load "ZSnap.lsp"));ZSnap
; Command line: (load "ZSnap.lsp") ZSnap
(defun c:ZSnap ( / *error* osmode pt1 pt2)
 (defun *Error* (msg) ; embedded defun
   (setvar 'osmode osmode)
   (if (/= s "Function cancelled")
     (princ (strcat "\nError: " msg))
   )
   (princ)
 )

 (setq osmode (getvar 'osmode))
 (if (> (getvar 'osmode) 16384)
  (setvar 'osmode (- osmode 16384))
 )
 (setq pt1 (getpoint "\nSelect First Window Point: "))
 (setq pt2 (getcorner pt1 "\nSelect Second Window Point: "))
 (command "._zoom" "_w" pt1 pt2) ; end zoom
 (setvar 'osmode osmode)
)

Osnap bitcodes changed when Geometric CEnter osnap was added so you will need to find the old bitcode setting to Suppress the current running object snaps in older versions.

  • Thanks 1
Link to comment
Share on other sites

Thanks for assisting again tombu.

I tried both of the above code snippets on AutoCAD 2021 and both work. I'll try on a previous version at a later stage.

Cheers.

Link to comment
Share on other sites

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...