Jump to content

Help Please - Reset OSNAP


barristann

Recommended Posts

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:

image.thumb.png.fb1e5c0be394e97a66f60da3fcd0e270.png

 

Is it possible to change to the below instead? (select Node, but unselect Insertion, Tangent, Nearest)

image.png.0b57645ef923e59e2270c6e5bede19b5.png

 

Thank you

 

Edited by barristann
typo
Link to comment
Share on other sites

;;----------------------------------------------------------------------------;;
;; Set Osnaps to Endpoint, Midpoint, Center, Node, Quadrant, Intersection, Perpendicular
(defun C:OS ()
  (setvar 'osmode 191)
  (prompt "Osnap Settings set")
  (princ)
)

 

  • Like 2
Link to comment
Share on other sites

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")
)

 

 

  • Like 3
Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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.

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