Choose snap setting during command for entire command?

Choose snap setting during command for entire command?

Anonymous
Not applicable
10,296 Views
22 Replies
Message 1 of 23

Choose snap setting during command for entire command?

Anonymous
Not applicable

I would like to know if it is possible during a command to select the snap point that I want to use for the duration of the command.

 

For example, if I'm drawing a polyline and want to snap only to midpoints I shift+right click and select midpoint, but that only lasts for that click. I would like to be able to shift+right click, select midpoint (or other desired snap setting) and then be able to draw my line using multiple clicks, snapping only to midpoints while that command is active.

 

Any thoughts? 

0 Likes
Accepted solutions (1)
10,297 Views
22 Replies
Replies (22)
Message 2 of 23

Anonymous
Not applicable

That sounds like a good idea. Curious to hear from others if this is already in AutoCAD.

0 Likes
Message 3 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

I would like to know if it is possible during a command to select the snap point that I want to use for the duration of the command.

 

For example, if I'm drawing a polyline and want to snap only to midpoints I shift+right click and select midpoint, but that only lasts for that click. I would like to be able to shift+right click, select midpoint (or other desired snap setting) and then be able to draw my line using multiple clicks, snapping only to midpoints while that command is active.

.... 


I haven't thought of a way to do exactly that, but you could come sort of close....  You could build commands for specific entity types with embedded selection of Osnap mode(s) to be used for only that one running of the command, but to remain in effect through to the end of it.  Here's a Polyline command that asks you first what mode(s) you want, uses only that/those during the command, and then when you're finished, restores the prior mode(s) setting:

 

(defun C:PLOS ; = Polyline with Osnap Setting
  (/ osm)
  (setq osm (getvar 'osmode))
  (initdia)
  (command "_.osnap")
  (command "_.pline")
  (while (> (getvar 'cmdactive) 0) (command pause))
  (setvar 'osmode osm)
  (princ)
)

It has what might be considered an advantage over what you describe, in that you can include more than one mode.

 

Kent Cooper, AIA
0 Likes
Message 4 of 23

GrantsPirate
Mentor
Mentor

Easiest way is to pick on the osnap icon and uncheck any of the snap and pick only midpoint.

 

From the command line you can use

'osmode 2

Which could be easily made into a macro and added to a Shortcut Menu in the CUI.


GrantsPirate
Piping and Mech. Designer
EXPERT ELITE MEMBER
Always save a copy of the drawing before trying anything suggested here.
----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.

Message 5 of 23

Anonymous
Not applicable

Kent1Cooper, I do like the option to include potentially more than one selection for the snap during a command. You'll have to help walk me through how to use your code though. I've never used anything like this before. Curious to see how easily it is executed in my workflow. 

0 Likes
Message 6 of 23

john.vellek
Alumni
Alumni

Jo @Anonymous,

 

Have you considered setting only Midpoint in your Object Snap settings?

 

Capture.PNG

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 7 of 23

RobDraw
Mentor
Mentor

Get familiar with OSMode, which can be used to set single and multiple running OSnaps, and set up a few buttons.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 8 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... You'll have to help walk me through how to use your code though. I've never used anything like this before. Curious to see how easily it is executed in my workflow. 


Copy that code into a plain-text editor such as Notepad.  Save it to a file with a .LSP filetype ending, in some known location -- you can call it whatever you want otherwise, like PlineOsnap.LSP or something -- preferably something that will be meaningful to you next year.  In AutoCAD, type AP [the alias for APPLOAD], navigate to where you saved that file, and Load it.  Then type PLOS [the command name is always the part following the C: near the beginning of such command definitions].

 

It could be made a lot more sophisticated, but try out the basic version.  There's a way to have it automatically loaded in every drawing you open or start, if you need it often enough for that, so you don't need to Load it yourself.  And a command call for it can be put into menu items of various kinds, if you would use it enough to justify that.

Kent Cooper, AIA
Message 9 of 23

GrantsPirate
Mentor
Mentor

See the link for adding a macro to your setup.

 

http://autode.sk/2tkq78T


GrantsPirate
Piping and Mech. Designer
EXPERT ELITE MEMBER
Always save a copy of the drawing before trying anything suggested here.
----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.

Message 10 of 23

Anonymous
Not applicable

You can fire the osnap dialog box in the middle of a command by selecting the little down-arrow next to the osnap button in the tool tray then selecting "Object Snap Settings".  Any changes made there will continue for the rest of the command and beyond.

 

osnap.PNG

0 Likes
Message 11 of 23

Anonymous
Not applicable

Kent1Cooper, thanks for the additional instruction. I was able to successfully create, load, and run your lisp. The only thing is that I have several osnaps selected as my default draft settings and to uncheck the majority of them to do what I'm looking for takes too much time unfortunately.

 

GrantsPirates, I will have to look into setting up a macro as you suggest. I would want to set it to a single keyboard command to make it efficient.

 

Rculp, I don't want to alter my osnap settings indefinitely, as I like the way they are normally. I've just found recent situations where it would be nice to select one particular snap in the middle of a drawing command. 

 

Thanks for all the input from everyone. 

0 Likes
Message 12 of 23

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Kent1Cooper, thanks for the additional instruction. I was able to successfully create, load, and run your lisp. The only thing is that I have several osnaps selected as my default draft settings and to uncheck the majority of them to do what I'm looking for takes too much time unfortunately.

..... 


Then have it start with a clean slate, and you can pick just one or a few, without needing to uncheck anything:

 

(defun C:PLOS ; = Polyline with Osnap Setting
  (/ osm)
  (setq osm (getvar 'osmode))
  (setvar 'osmode 0)
  (initdia)
  (command "_.osnap")
  (command "_.pline")
  (while (> (getvar 'cmdactive) 0) (command pause))
  (setvar 'osmode osm)
  (princ)
)
Kent Cooper, AIA
Message 13 of 23

Anonymous
Not applicable

@Kent1Cooper this is much better. Thanks!

0 Likes
Message 14 of 23

Anonymous
Not applicable

The number in OSMODE is the sum of these from HELP:

 

The setting is stored as a bitcode using the sum of the following values:

0        =     NONe

1        =     ENDpoint

2        =     MIDpoint

4        =     CENter

8        =     NODe

16       =     QUAdrant

32       =     INTersection

64       =     INSertion

128      =     PERpendicular

256      =     TANgent

512      =     NEArest

1024     =     Clears all object snaps

2048     =     APParent Intersection

4096     =     EXTension

8192     =     PARallel

 

Setting OSMODE = 7 makes OSNAP =  End,Mid,Cen

Setting OSMODE = 103 makes OSNAP =  End,Mid,Cen,Int,Ins

Setting OSMODE = 6399 makes OSNAP = End,Mid,Cen,Node,Quad,Int,Ins,Perp,App Int,Ext

If you know the number of our favorite OSMODE setting (like 6399), or maybe a cheat sheet of your favorites, they can be set using a transparent call to OSMODE by prefixing the command with an apostrophe as in ‘OSMODE.

 

Adding 16384 to the current OSMODE setting turns off running OSNAPS without resetting the selection of osnaps in the dialog box.  When I use a running OSNAP, which isn’t very often it is either a specific single OSNAP (like END) or OSMODE = 6399.  So, I have a little function that resets running osnaps to my favorite:

 

(defun c:oss () (setvar "osmode" 6399)(princ))

 

 

Message 15 of 23

RobDraw
Mentor
Mentor

Let me just reiterate that those OSMode values, that @Anonymous is suggesting, can be accessed easily by adding them to your CUI with a macro.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
Message 16 of 23

Anonymous
Not applicable

See the link for adding a macro to your setup.

 

http://autode.sk/2tkq78T

 

_________________________________________________________________________

 

@GrantsPirate this video is very helpful, thank you. I like having the option to access the command via a right-click or shift + right-click.

 

Two questions: When I added my custom command to the Snap Overrides menu, I cannot get it to show up on the right click menu as it does in your video. I have to either right click and then hover over the snap overrides to bring up an additional menu that I normally get when I shft+right click, and then I can see my custom setting. If I just shift+right click though, it does not show up in that menu. Thoughts on how to get that to work in either menu so it can be accessed via one click?

 

Second question: After using your method with my custom command my snap settings do not reset to the ones I had previously. I just have the midpoint snap available and then need to manually reset my OSMODE. Any way to make that reset automatically after overriding the snap setting?

 

Thanks.

0 Likes
Message 17 of 23

GrantsPirate
Mentor
Mentor

Make sure you drag and drop the new command to the place I show, don't let it get dragged into the osnap overrides in the menu, place it above or below that.   It won't show with Shift right click because that brings up a different shortcut menu.

 

I think many of us interpreted your request to have midpoint set to stay on, instead you want a one time toggle to midpoint only.  Is that accurate?  Shift+V is already set for a temp override for midpoint. While in a command, press and hold Shift+V and pick on the line, pline, etc., release and continue.

 

 


GrantsPirate
Piping and Mech. Designer
EXPERT ELITE MEMBER
Always save a copy of the drawing before trying anything suggested here.
----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.

0 Likes
Message 18 of 23

Anonymous
Not applicable

I think many of us interpreted your request to have midpoint set to stay on, instead you want a one time toggle to midpoint only.  Is that accurate?  Shift+V is already set for a temp override for midpoint. While in a command, press and hold Shift+V and pick on the line, pline, etc., release and continue.

________________________________________________________________________________________________

 

I would like midpoint to stay on for the duration of the command and then reset back to my chosen Osnap settings. I tried Shift+V while drawing a polyline, but only get a bunch of Vs in my command line.

0 Likes
Message 19 of 23

RobDraw
Mentor
Mentor

@Anonymous wrote:

I would like midpoint to stay on for the duration of the command and then reset back to my chosen Osnap settings. I tried Shift+V while drawing a polyline, but only get a bunch of Vs in my command line.


Set-up another command with your settings.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 20 of 23

Anonymous
Not applicable

Depending on your MBUTTONPAN setting, a mid-button (or shift+mid-button) will pop the osnap onscreen menu (pop0), touching the letter at the keyboard that is underlined in that menu will set a one-time osnap override.

osnap_letters.PNG

0 Likes