Jump to content

Recommended Posts

Posted

I have my OSMODE system variable typically set to "9". I am writing a lisp that uses two getpoint functions. When running this routine, I don't always want to select an endpoint or a node. So I try to override the running object snaps for either getpoint location by using "Shift" + Right-click. The point that is actually returned is the endpoint (as long as my selection has an endpoint) because it is first in the list of osnaps. Without setting OSMODE TO "0" or setting it to "8191", is there a way to use the override with these functions?

Posted

If you look at the value actually stored with the getpoint, it should be correct. However, you will have issues when you use command calls that can use osnaps. You will want to either turn off osnaps before using the command call, or use "non" in your command. For example:

(vl-cmdf "_.break" ent "_f" "_non" pt "_non" pt)

Posted

Thank you. That helps! I was doing exactly what you said. I was using my points within the DIMLINEAR command. After I set OSMODE to "0" before issuing the command and then reset it to it's previous setting after running the command, my issue went away. Thanks again!

Posted
Thank you. That helps! I was doing exactly what you said. I was using my points within the DIMLINEAR command. After I set OSMODE to "0" before issuing the command and then reset it to it's previous setting after running the command, my issue went away. Thanks again!
Yeah no problem. I ran into this same problem actually working on dimension LISP routine, which is when I discovered the terrible things that osnaps do to LISP routines haha.
Posted

Setting OSMODE to 0 present the issue that if the program terminates before the original value of the OSMODE system variable is restored, the user's Object Snap settings are wiped unless the program implements a local error handler to reset the system variable on error.

 

As a cleaner alternative to the above, consider temporarily disabling Object Snaps without losing the Object Snap settings, such that if the program terminates unexpectedly the user can re-enable Object Snaps using F3 with nothing lost:

(defun c:test ( / osm pt1 pt2 )
   (if
       (and
           (setq pt1 (getpoint "\nSpecify 1st point: "))
           (setq pt2 (getpoint "\nSpecify 2nd point: " pt1))
       )
       (progn
           (setq osm (getvar 'osmode))
           (setvar 'osmode (logior 16384 (getvar 'osmode)))
           (command "_.line" pt1 pt2 "")
           (setvar 'osmode osm)
       )
   )
   (princ)
)

Posted

Thanks Lee. I had already intended on restoring the OSMODE variable to its original state through the error handler.

 

BTW - Not that I am an expert at lisp and know every function there is, but that is the first time I have seen the logior function. Interesting!

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