sketch11 Posted May 5, 2021 Posted May 5, 2021 To snap to objects when zooming in a viewport, I set OSNAPCOORD = 0. The issues is that this over-rides other setting/s. So far, it changes the following setting. Tools/Options/User Preferences/Prioroty for Coordinate Data Entry ... "Keyboard Entry" is changed to "Running Object Snap". I want to keep Keyboard Entry, but it changes the snap setting. Is there a way to keep both settings? Quote
Dadgad Posted May 5, 2021 Posted May 5, 2021 On the bus, or off the bus. You can't prioritize them BOTH. 1 Quote
sketch11 Posted May 5, 2021 Author Posted May 5, 2021 OK thanks for confirming. At least now I know. Quote
tombu Posted May 5, 2021 Posted May 5, 2021 Curious I've never changed mine from the default of 2. What purpose would there be in setting it to 0? Quote
sketch11 Posted May 6, 2021 Author Posted May 6, 2021 (edited) Actually, it was on 2 to begin with as a default. But I can't get "Zoom Window" in paper space to snap. The 0 is for snapping ... I know it may not be the correct method but it works for me. Edited May 6, 2021 by sketch11 Quote
sketch11 Posted May 6, 2021 Author Posted May 6, 2021 Would there be a simple macro to change this setting? Quote
tombu Posted May 6, 2021 Posted May 6, 2021 2 hours ago, sketch11 said: Actually, it was on 2 to begin with as a default. But I can't get "Zoom Window" in paper space to snap. The 0 is for snapping ... I know it may not be the correct method but it works for me. Setting OSNAPCOORD to 0 would allow osnap settings to override emtered coordinates when they're close enough to snap to something. Zoom Window ignores osnap settings by default but you can alway pick or enter an osnap if you want to use them. Quote
sketch11 Posted May 6, 2021 Author Posted May 6, 2021 Sorry I don't quite follow. Is it possible to snap for Zoom Window if OSNAPCOORD = 1 or OSNAPCOORD = 2? Quote
tombu Posted May 6, 2021 Posted May 6, 2021 (edited) 7 hours ago, sketch11 said: Sorry I don't quite follow. Is it possible to snap for Zoom Window if OSNAPCOORD = 1 or OSNAPCOORD = 2? I never knew that worked for Zoom before! Quick lisp that allows you to Zoom Window using your Osnap settings by setting and resetting the OSNAPCOORD value to preserve "Keyboard Entry". ; https://www.cadtutor.net/forum/topic/72916-snapping-to-objects-when-zooming-in-viewport/?tab=comments#comment-580609 ; Zoom Window using Osnap settings by Tom Beauford (defun c:ZSnap ( / *error* osnapcoord) (defun *Error* (msg) ; embedded defun (setvar 'osnapcoord osnapcoord) (if (/= s "Function cancelled") (princ (strcat "\nError: " msg)) ) (princ) ) (setvar "cmdecho" 0) (setq osnapcoord (getvar 'osnapcoord)) (setvar 'osnapcoord 0) (command-s "zoom" PAUSE) (while (= 1 (logand 1 (getvar "cmdactive"))) PAUSE ) ;null responce exits zoom (setvar 'osnapcoord osnapcoord) ;reset osnapcoord (princ) ) While command-s is needed for newer versions you will need to change (command-s "zoom" PAUSE) to (command "zoom" PAUSE) for older versions like 2013. Save it as "ZSnap.lsp" in a support folder. Load and run by entering (load "ZSnap.lsp") then ZSnap at the command line. You could alse add ^P(or C:ZSnap (load "Leader.lsp"));ZSnap as a command macro for easy access. Edited May 6, 2021 by tombu 1 1 Quote
Dana W Posted May 6, 2021 Posted May 6, 2021 The "O" in zoom options is for OBJECT. Use ZOOM then O then select the object to zoom to. The viewport will then zoom and window itself centered on the object selected. There is no need to change any setting or variable. You will then have to click the object again to get the grips to show if you want to snap somewhere on the object, but it is still easier than resetting a critical variable each time. 1 1 Quote
tombu Posted May 6, 2021 Posted May 6, 2021 18 hours ago, sketch11 said: Would there be a simple macro to change this setting? Create this macro: Command name Osnapcoord Description Toggle OSNAPCOORD overrides between "Keyboard entry except in scripts" & "Osnap settings". Macro ^P'setvar;osnapcoord;$M=$(if,$(and,2,$(getvar,osnapcoord)),0,2) ^P Element ID Osnapcoord Add the macro to your Object Snap Cursor Menu then add: Display Name $(if,$(and,2,$(getvar,osnapcoord)),"Zoom Osnap","Keyboard entry except scripts") which goes just above: Command name Osnapcoord I'd recommend resetting OSNAPCOORD to 2 in acaddoc.lsp to avoid issues should you forget to toggle it back: (if (/= (getvar 'osnapcoord) 2)(progn(setvar 'osnapcoord 2)(princ "\nKeyboard entry overrides object snap settings. OSNAPCOORD"))) 1 Quote
sketch11 Posted May 6, 2021 Author Posted May 6, 2021 Thanks tombu, I did try the macro, adding it to a command button: ^P'setvar;osnapcoord;$M=$(if,$(and,2,$(getvar,osnapcoord)),0,2) ^P And this worked quite well. I will look into the other parts at a later stage. Cheers. Quote
sketch11 Posted May 7, 2021 Author Posted May 7, 2021 tombu, your LISP for "ZSnap" is actually what I was looking for, as this does not override OSNAPCOORD. It worked perfectly in AutoCAD 2021. For older versions, I tried replacing (command-s "zoom" PAUSE) to (command "zoom" PAUSE) ... but I couldn't get it to work. There was no icon or prompts like in 2021. This worked with the older version: Click one corner of object, press Escape, click the other corner. Would it be possible to make it work like 2021? Quote
tombu Posted May 7, 2021 Posted May 7, 2021 1 hour ago, sketch11 said: tombu, your LISP for "ZSnap" is actually what I was looking for, as this does not override OSNAPCOORD. It worked perfectly in AutoCAD 2021. For older versions, I tried replacing (command-s "zoom" PAUSE) to (command "zoom" PAUSE) ... but I couldn't get it to work. There was no icon or prompts like in 2021. This worked with the older version: Click one corner of object, press Escape, click the other corner. Would it be possible to make it work like 2021? You may need help from someone with an older version as I don't have access to one for testing. Maybe (command "._zoom" "_Window" PAUSE)? CAB's routine at: https://www.cadtutor.net/forum/topic/3460-zoom-window/?tab=comments#comment-28218 may work better: 1 Quote
sketch11 Posted May 8, 2021 Author Posted May 8, 2021 Great thank you, this seems to offer prompts. (defun c:ZSnapOlderVersions( / *error* osnapcoord) (defun *Error* (msg) (setvar 'osnapcoord osnapcoord) (if (/= s "Function cancelled") (princ (strcat "\nError: " msg)) ) (princ) ) (setvar "cmdecho" 0) (setq osnapcoord (getvar 'osnapcoord)) (setvar 'osnapcoord 0) (if (and (setq pt1 (getpoint "\nSelect First Window Point: ")) (setq pt1 (osnap pt1 "_end")) (setq pt2 (getpoint "\nSelect Second Window Point: ")) (setq pt2 (osnap pt2 "_end")) ) (command "._zoom" "_w" "_non" pt1 "_non" pt2) ; end zoom ) (princ) (while (= 1 (logand 1 (getvar "cmdactive"))) PAUSE ) (setvar 'osnapcoord osnapcoord) (princ) ) Quote
tombu Posted May 8, 2021 Posted May 8, 2021 (edited) On 5/7/2021 at 8:12 PM, sketch11 said: Great thank you, this seems to offer prompts. If you change the both getpoint functions to getcorner functions it should work the same but display the rectangle for picking the second corner just like Zoom Window does. Edited May 9, 2021 by tombu Both getpoints needed to be changed Quote
sketch11 Posted May 8, 2021 Author Posted May 8, 2021 OK, I was trying to make the rectangle show for a while but had no luck. I tried the change you suggested but still got an error. (setq pt1 (getpoint "\nSelect First Window Point: ")) (setq pt1 (osnap pt1 "_end")) (setq pt2 (getcorner "\nSelect Second Window Point: ")) (setq pt2 (osnap pt2 "_end")) The error in AutoCAD is: Select First Window Point: Error: base point is required Quote
tombu Posted May 9, 2021 Posted May 9, 2021 On 5/8/2021 at 1:45 AM, sketch11 said: OK, I was trying to make the rectangle show for a while but had no luck. I tried the change you suggested but still got an error. (setq pt1 (getpoint "\nSelect First Window Point: ")) (setq pt1 (osnap pt1 "_end")) (setq pt2 (getcorner "\nSelect Second Window Point: ")) (setq pt2 (osnap pt2 "_end")) The error in AutoCAD is: Select First Window Point: Error: base point is required Sorry, you needed to change both getpoints to getcorner. Help for getcorner (AutoLISP) https://help.autodesk.com/view/ACD/2021/ENU/?guid=GUID-21BE8290-7F11-400B-AC39-62A110F07545 Examples (getcorner '(7.64935 6.02964 0.0)) (17.2066 1.47628 0.0) (getcorner '(7.64935 6.02964 0.0) "\nPick a corner") Pick a corner (15.9584 2.40119 0.0) Quote
sketch11 Posted May 10, 2021 Author Posted May 10, 2021 (edited) OK thanks, I wasn't quite able to get it to work but will try again. This is what I had. (setq pt1 (getcorner "\nSelect First Window Point: ")) (setq pt1 (osnap pt1 "_end")) (setq pt2 (getcorner "\nSelect Second Window Point: ")) (setq pt2 (osnap pt2 "_end")) EDIT: Actually I have to test this on older versions. Edited May 10, 2021 by sketch11 Quote
sketch11 Posted May 10, 2021 Author Posted May 10, 2021 I still get an error with the older version with code above. Error message: Error: base point is required 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.