Object Snap Shortcut

Anonymous

Object Snap Shortcut

Anonymous
Not applicable

Hello,

 I would like to set the object snap shortcut to my keys

F1: MidPoint

F2: EndPoint

F3: Center

...

so that if I draw a polyline and move the Cursor to place the second poin I can snap to the desired Point. After I clicked the Point I want the object snap to be turned off again. I tried to write this with a Lisp but I cannot enter a new command once i start drawing the polyline

This is the Code:

 

(defun c:F1()
(setq pt2 (osnap pt1 "_midp"))
)

 

Thank you very much:)

0 Likes
Reply
Accepted solutions (2)
4,909 Views
8 Replies
Replies (8)

ВeekeeCZ
Consultant
Consultant

I am using the similar setting you want for some years... so how much experienced user you are?

 

There are MANY pretty quick ways how to turn off/on OSNAPs without messing with F keys... did you try them first?

0 Likes

marko_ribar
Advisor
Advisor

Your posted example don't have (setq pt1 (getpoint)), and beside this I wouldn't approach like this... I'd write something like this :

 

(defun c:F1 ( / osm )

  (setq osm (getvar 'osmode))

  (if (/= osm 2)

    (setvar 'osmode 2) ;---> midp

  )

  (princ)

)

 

(defun c:F2 ( / osm )

  (setq osm (getvar 'osmode))

  (if (/= osm 1)

    (setvar 'osmode 1) ;---> endp

  )

  (princ)

)

 

(defun c:F3 ( / osm )

  (setq osm (getvar 'osmode))

  (if (/= osm 4)

    (setvar 'osmode 4) ;---> center

  )

  (princ)

)

 

But in fact I used to use ctrl(shift)+right click and after dialog pops up (osnap spec : "E"-end point; "M"-mod point; "C"-center) and just continue to draw with that specific osnap specified for that one task I started... After command is finished old osnaps are set like no intermediate setting happened...

 

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes

Anonymous
Not applicable

I am not suc h an experienced user but I worked Long time with this Settings and I got very used to it:)

0 Likes

Anonymous
Not applicable

Thank you very much, the script works only Problem I have is that I would like to

- activate the Code by my Keyboard Function keys and not by typing in "F1"

- I cannot start the Lisp once I start another procedure, like drawin a polyline. or can i (see screenshot)?

If not, the other procedure you state works fine too:)

 

Unbenannt.PNG

 

 

0 Likes

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ohh, so why you need any lisp? Simple macro _end or _mid assigned to the F key in CUI would work just fine!

0 Likes

Anonymous
Not applicable

Oh, I thought a Lisp is like a Macro

0 Likes

Anonymous
Not applicable
Accepted solution

Ok thanks I found how to do it now:

and even though for many ist obvious i thought i quickly screenshot how to do it:)

Thx

 

1.PNG2.PNG

Anonymous
Not applicable

But how can I avoid that switchin from e.g. mid to end snap, I have to press my assigned shortkey twice because if not I get the warning

"2-D point or Option title required"

can I add a Code to _mid like _cancel_mid to abort the last command

Thank you

 

2.PNG

 

 

 

 

0 Likes