Selected Osnaps turn off when running a script in Autocad 2021

Selected Osnaps turn off when running a script in Autocad 2021

meghan.morton
Contributor Contributor
637 Views
6 Replies
Message 1 of 7

Selected Osnaps turn off when running a script in Autocad 2021

meghan.morton
Contributor
Contributor

Every time I run a script in a new drawing, the osnap selections completely disable. In the Object snap tab of Drafting Settings, it shows that Object Snap and Object Snap Tracking are both on, yet all of my individual selections have turned off. We have a third party plugin and I uninstalled it, tested and the issue is still happening so I don't believe it's the plug-in. Does anyone else experience this and know of a long term fix(lisp routine or system variable)? Thank you!

0 Likes
638 Views
6 Replies
Replies (6)
Message 2 of 7

RobDraw
Mentor
Mentor

It would be helpful to share this script.


Rob

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

jayhar
Advisor
Advisor

(defun set-osnaps ()
(setq osnaps '(end mid))
(foreach osnap osnaps
(command "_osnap" osnap "_on"))
)

(set-osnaps)

Please Subscribe YouTube Channel
https://www.youtube.com/channel/UCclj8v9vHQiFa8_DriuAk3w

Please Mark the Post or Posts as Solution(s) to help others find the answer quickly.
0 Likes
Message 4 of 7

apjones
Collaborator
Collaborator
Why not just use (setvar "OSMODE" 3) ?
Pete

>Please Accept as Solution and give Kudos as appropriate to further enhance these forums. Thank you!
Message 5 of 7

meghan.morton
Contributor
Contributor

Thank you. I've tried that and my selections won't stick. The script I'm running is proprietary as it's from a customer but it is essentially an exhibition layout from a third party application and is a series of polylines and text. As soon as they generate in my drawing, all of my selected osnaps turn off so I keep turning them back on manually. 

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@meghan.morton wrote:

... my selections won't stick. The script I'm running is proprietary .... As soon as they generate in my drawing, all of my selected osnaps turn off so I keep turning them back on manually. 


Then it's pretty clear that the proprietary script is what's turning them off, and it should be edited to remember the OSMODE value and restore it when it's done.  If it's actually a Script, or if it's an .lsp file, you should find a (setvar 'osmode ...) entry in there somewhere, or an OSNAP command, or something.  If it's in some compiled format that you can't edit, ask the source to make it work as it should.

Kent Cooper, AIA
Message 7 of 7

pendean
Community Legend
Community Legend
@meghan.morton Are you aware scripts (and LISP) and other customization's can and often do turn off or reset Osnaps to avoid possible conflicts with hat they might do (or make it work even better)?

And a handful of commands in AutoCAD can also turn off running osnaps.

SO... Ask the script creator all about it since you cannot share here: there is nothing unusual about that, it's done more often than not, unless you can prove otherwise by sharing it here (which you state that's not possible).

Now you know.