barristann Posted December 29, 2022 Posted December 29, 2022 (edited) Hi all, is it possible to modify the below codes (from flyfox1047) to select Node as well, but unselect Insertion, Tangent, Nearest? (defun resetosmode (v1 v2 /) (if (/= (getvar "osmode") 1015) (setvar "osmode" 1015) ) (princ) ) (vlr-editor-reactor nil '((:vlr-lispEnded . ResetOsmode) (:vlr-lispCancelled . ResetOsmode) (:vlr-commandEnded . ResetOsmode) (:vlr-commandCancelled . ResetOsmode) (:vlr-commandFailed . ResetOsmode) ) ) https://www.cadtutor.net/forum/topic/50056-how-to-avoid-the-loss-of-osnap/ In other words, these are the Settings with the above codes: Is it possible to change to the below instead? (select Node, but unselect Insertion, Tangent, Nearest) Thank you Edited December 29, 2022 by barristann typo Quote
mhupp Posted December 29, 2022 Posted December 29, 2022 ;;----------------------------------------------------------------------------;; ;; Set Osnaps to Endpoint, Midpoint, Center, Node, Quadrant, Intersection, Perpendicular (defun C:OS () (setvar 'osmode 191) (prompt "Osnap Settings set") (princ) ) 2 Quote
Steven P Posted December 29, 2022 Posted December 29, 2022 Taking MHUPP and adding a bit more.... (meaning he beat me to it again) This is what I use - a longer version than above. Technical bit - each snap option has a value (0, 1, 2, 4, ....) and adding these together will give you the value you want to use in 'osmode variable. Looking at the list below to add up what you want. For a simple example a value of 3 means "End Point" + "Mid Point" which is the sum MHUPP did for you to get 191. I wouldn't have done the calculation, just given you this and let you work it out!! In mine below, change the (* 1 or (* 0 so that it is a 1 if you want to use the snap, 0 if you don't (so I have end point, mid point, centre but not node or quadrant). The first option "none" is just there for completion - has no effect (1 x 0 or 0 x 0 = 0), it will add it up for you and set the snaps. MHUPP: Borrowed your routine name and the princ at the end, ta! (defun c:os ( / snaps) (setq snaps 0) (setq snaps (+ snaps (* 1 0))) ;None (setq snaps (+ snaps (* 1 1))) ;End Point (setq snaps (+ snaps (* 1 2))) ;Mid Point (setq snaps (+ snaps (* 1 4))) ;Centre (setq snaps (+ snaps (* 0 8))) ;Node (setq snaps (+ snaps (* 0 16))) ;Quadrant (setq snaps (+ snaps (* 1 32))) ;Intersection (setq snaps (+ snaps (* 0 64))) ;Insertion (setq snaps (+ snaps (* 0 128))) ;Perpendicular (setq snaps (+ snaps (* 1 256))) ;Tangent (setq snaps (+ snaps (* 0 512))) ;Nearest (setq snaps (+ snaps (* 0 1024))) ;Geometric Centre (setq snaps (+ snaps (* 1 2048))) ;Apparent Intersection (setq snaps (+ snaps (* 0 4096))) ;Extrnsion (setq snaps (+ snaps (* 0 8192))) ;Parallel (setq snaps (+ snaps (* 0 16348))) ;Superess all running snaps (setvar 'osmode snaps) (prompt "Osnap Settings set") ) 3 Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 It works wonder! This helps a lot with my work. You guys have amazing skills. Thank you so much again Steven and mhupp! Quote
BIGAL Posted December 30, 2022 Posted December 30, 2022 (edited) My $0.05 in my autoload.lsp. (defun C:15 ()(setvar "osmode" 15359)) ; sets all snaps on (defun C:47 ()(setvar "osmode" 47)(setvar "AUNITS" 0)) (defun C:99 ()(setvar "osmode" 99)) (defun C:8 ()(setvar "osmode" 8)) (defun C:59 ()(setvar "osmode" 15359)) (defun C:9 ()(setvar "osmode" 9)) (defun C:0 ()(setvar "osmode" 0)) Edited December 30, 2022 by BIGAL Quote
tombu Posted December 30, 2022 Posted December 30, 2022 I added macros to CUI → Shortcut Menus → Object Snap Cursor Menu to quickly toggle my favorite groups of Osnaps. Here's an example of the one I use the most: Command Name ECGcNInsApp Description Set End, Cen, Gce, Node, Ins, and App Int Object Snaps. Macro 'setvar;osmode;$M=$(if,$(=,3149,$(getvar,osmode)),0,3149) Once the macro is added to the Object Snap Cursor Menu add Display Name $(if,$(=,3149,$(getvar,osmode)),!.)ECGcNInsApp and it will be highlighted whenever End, Cen, Gce, Node, Ins, and App Int are the current Object Snaps. 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.