Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sysvar OSNAPCOORD

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
715 Views, 11 Replies

sysvar OSNAPCOORD

From the sytems variable editor express tool, regarding OSNAPCOORD: Controls whether coordinates entered on the command line override running object snaps. 0 Running object snap settings override keyboard coordinate entry 1 Keyboard entry overrides object snap settings 2 Keyboard entry overrides object snap settings except in scripts Does the OSNAPCOORD setting apply to lisp? I was tweaking a command to find the midpoint between two points, to be used transparently... works just fine UNLESS osnaps are on, then the osmode can override the resulting midpoint. If I (setvar "osmode" 0) all is good. But I was trying the osnapcoord setting, to see if it would effect the outcome, and apparently not. I wanted the lisp command to be well behaved, and reset whatever osnap might have been set, but can't seem to do that and deliver a midpoint value transparently at the same time. -- Mark McDonough Sasaki Associates http://www.sasaki.com
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

I'm not sure I understand your question, but I'll give it a shot. I've never messed with the OSNAPCOORD var, but for a transparent point routine I use something like the following: (setq oldos (getvar "osmode")) (setvar "osmode" 0) (setq pt ) (setvar "osmode" oldos) (command pt) And don't end with (princ)... Hope this helps James
Message 3 of 12
Anonymous
in reply to: Anonymous

Thanks for offering up a suggestion. But it still doesn't work, because the lisp command's last line must evaluate to the point, and if there is an osnap set, the (setvar "osmode" oldos) BEFORE delivering the last point, ends up with osnap modes potentially interfering with the actual point. To explain a bit more, I have a lisp command named MIP (MId Point) that finds the point between any 2 selected points. So I can be in the LINE command, then enter 'MIP to start a line between two endpoint or intersection points on some other geometry. Works great most of the time. What if the user has an ENDP osnap mode set, then snaps to two opposite ends of the same line, and the lisp properly finds the midpoint, but the ENDP osnap will override that specified midpoint and will find an endpoint on the line instead. Why doesn't the person just use the MID osnap you ask (for that last scenario)... well, if you give people a command that finds the midpoint between any two points, then that's what it should do, even if they do something dumb like use the command to show two opposite endpoints on the same line. That's why I'm asking about the OSNAPCOORD system variable, because it's supposed to control the behavior of specific point input regardless of osmode setting, designed for keyboard input and scripts.... help says nothing about whether that setvar helps out when used from lisp. -- Mark McDonough Sasaki Associates http://www.sasaki.com "JamesA" wrote in message news:403ba574$1_3@newsprd01... > I'm not sure I understand your question, but I'll give it a shot. I've > never messed with the OSNAPCOORD var, but for a transparent point routine I > use something like the following: > > (setq oldos (getvar "osmode")) > (setvar "osmode" 0) > (setq pt ) > (setvar "osmode" oldos) > (command pt) > > And don't end with (princ)... Hope this helps > > James > >
Message 4 of 12
Anonymous
in reply to: Anonymous

Mark, I understand that in AC2005 there will FINALLY be a new OSMODE for this! But for now - why don't you provide this ability in your POP0 button menu, using 'cal - something like so?: ***POP0 **SNAPCURSOR [&Object Snap Cursor Menu] ID_Tracking [Temporary trac&k point]_tt ID_From [&From]_from [--] ID_CalMEE [MEE (Midpt. Between Endpts. P1 and P2)]_non '_.CAL MEE; ID_CalMPP [MPP (Midpt. Between any Two Pts. P1 and P2)]_non '_.CAL (cur+cur)/2; ID_CalOther [->Other Cal Functions] ID_Cal [Cal (3D Calculator Utility)]_non '_.CAL ID_CalILLE [ILLE (Int. of Lines defined by Endpts. P1 thru P4)]_non '_.CAL ILLE; ID_CalPLT [PLT (Point T* from Endpt. P1 toward Endpt. P2)]_non '_.CAL PLT(end,end,T); ID_CalPLD [PLD (Point T Units from Endpt. P1 toward Endpt. P2)]_non '_.CAL PLD(end,end,T); ID_CalT [T (Set T variable)]'_.CAL T=\ [--] ID_CalCVUnit [<-cvunit (Convert Quantity,From,To)]'_.CAL cvunit(\ "Mark McDonough" wrote in message news:403ce2f5$1_3@newsprd01... > Thanks for offering up a suggestion. But it still doesn't work, because the > lisp command's last line must evaluate to the point, and if there is an > osnap set, the (setvar "osmode" oldos) BEFORE delivering the last point, > ends up with osnap modes potentially interfering with the actual point. > > To explain a bit more, I have a lisp command named MIP (MId Point) that > finds the point between any 2 selected points. So I can be in the LINE > command, then enter 'MIP to start a line between two endpoint or > intersection points on some other geometry. Works great most of the time. > What if the user has an ENDP osnap mode set, then snaps to two opposite ends > of the same line, and the lisp properly finds the midpoint, but the ENDP > osnap will override that specified midpoint and will find an endpoint on the > line instead. > > Why doesn't the person just use the MID osnap you ask (for that last > scenario)... well, if you give people a command that finds the midpoint > between any two points, then that's what it should do, even if they do > something dumb like use the command to show two opposite endpoints on the > same line. > > That's why I'm asking about the OSNAPCOORD system variable, because it's > supposed to control the behavior of specific point input regardless of > osmode setting, designed for keyboard input and scripts.... help says > nothing about whether that setvar helps out when used from lisp. > > -- > Mark McDonough > Sasaki Associates > http://www.sasaki.com > > "JamesA" wrote in message > news:403ba574$1_3@newsprd01... > > I'm not sure I understand your question, but I'll give it a shot. I've > > never messed with the OSNAPCOORD var, but for a transparent point routine > I > > use something like the following: > > > > (setq oldos (getvar "osmode")) > > (setvar "osmode" 0) > > (setq pt ) > > (setvar "osmode" oldos) > > (command pt) > > > > And don't end with (princ)... Hope this helps > > > > James > > > > > >
Message 5 of 12
EC-CAD
in reply to: Anonymous

Mark,
In your routine, do:
(setq old_osmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
...
... do stuff
...
(setvar "OSMODE" old_osmode); reset old values on exit.

Bob
Message 6 of 12
Anonymous
in reply to: Anonymous

You're right. My bad. Try putting the second setvar *after* (command pt). Will check back later to see if that worked for you. I think it will. Of course the return value to a calling lisp function has to be the last line evaluated. But because we are 'returning' the point using "command", it doesn't have to be the last line of the routine. I don't remember how I first came stumbled onto that revelation (well it was for me anyway... :), but it works here. James
Message 7 of 12
Anonymous
in reply to: Anonymous

I tried what you suggest, putting the osmode setvar at the end, and was hoping that it would work like you suggest in your 2nd paragraph, but couldn't get it to work to transparent deliver the point value. Will try again in earnest tomorrow. -- Mark McDonough Sasaki Associates http://www.sasaki.com "JamesA" wrote in message news:403cf38d$1_3@newsprd01... > You're right. My bad. Try putting the second setvar *after* (command pt). > Will check back later to see if that worked for you. I think it will. > > Of course the return value to a calling lisp function has to be the last > line evaluated. But because we are 'returning' the point using "command", > it doesn't have to be the last line of the routine. I don't remember how I > first came stumbled onto that revelation (well it was for me anyway... :), > but it works here. > > James > >
Message 8 of 12
Anonymous
in reply to: Anonymous

Good morning Mark. I believe this works how you want it to... (defun c:MIP (/ p1 p2 oldos) (setq p1 (getpoint "\nPick first point: ") p2 (getpoint p1 "\nPick second point: ") p1 (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2) oldos (getvar "osmode") ) (setvar "osmode" 0) (command p1) (setvar "osmode" oldos) ) If not, does it: 1. Run but still return the wrong point? Check other point mod. modes maybe? (orthomode, autosnap, snapmode, ...) 2. Not run at all? You do have "defun c:<...>" right? And it looks like you are calling with the ' in 'MIP. Doesn't this work? Stay posted. James
Message 9 of 12
Anonymous
in reply to: Anonymous

Excellent! That works. I guess it was the COMMAND function that does the trick. However, in my version I still have an odd problem. When asked for the 2nd point, if I hit ESC, I'd like the command to exit cleanly, but for some reason it's not working and mysteriously the P2 point is still getting a value: (defun c:MIP (/ p1 p2 p3 os) (setq os (getvar "osmode") p1 (getpoint "\nShow 1st point: ") ) (princ "\nCalculate midpoint...") (if p1 (setq p2 (getpoint "\nShow 2nd point: "))) (setvar "osmode" 0) (if (and p1 p2) (setq p3 (mapcar '(lambda(a b)(*(+ a b 0.0) 0.5)) p1 p2)) (princ "\n2 points not picked.") ) (if p3 (command p3) (princ)) (setvar "osmode" os) (setq os nil) (princ) ) When I hit ESC on the 2nd point (e.g. the user changes his/her mind) then I get: Show 2nd point: *Cancel* ; error: Function cancelled Specify first point: Specify first point: -- Mark McDonough Sasaki Associates http://www.sasaki.com "JamesA" wrote in message news:403e14df$1_3@newsprd01... > Good morning Mark. I believe this works how you want it to... > > (defun c:MIP (/ p1 p2 oldos) > (setq p1 (getpoint "\nPick first point: ") > p2 (getpoint p1 "\nPick second point: ") > p1 (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2) > oldos (getvar "osmode") > ) > (setvar "osmode" 0) > (command p1) > (setvar "osmode" oldos) > ) > > If not, does it: > > 1. Run but still return the wrong point? Check other point mod. modes > maybe? (orthomode, autosnap, snapmode, ...) > 2. Not run at all? You do have "defun c:<...>" right? And it looks like > you are calling with the ' in 'MIP. > > Doesn't this work? Stay posted. > > James > >
Message 10 of 12
Anonymous
in reply to: Anonymous

It sounds like you want a custom error handler. Look in your AutoCAD Help files: Developer Documentation->AutoLISP Developer's Guide->Using the AutoLISP Language->AutoLISP Basics->Error Handling->Using the *error Function. I also use *error* to reset any system variables I use in a routine (e.g. osmode). This way even when a user cancels the routine their settings are left how they had them when it started. James
Message 11 of 12
Anonymous
in reply to: Anonymous

Thanks James, I didn't report back in here, but I did exactly as you suggest. Typically I include error-handler swappping code in my larger routines but didn't plan to on this smaller one. But I did get the behavior I wanted when adding the error handler. -- Mark McDonough Sasaki Associates http://www.sasaki.com "JamesA" wrote in message news:403e5c46$1_2@newsprd01... > It sounds like you want a custom error handler. Look in your AutoCAD Help > files: Developer Documentation->AutoLISP Developer's Guide->Using the > AutoLISP Language->AutoLISP Basics->Error Handling->Using the *error > Function. > > I also use *error* to reset any system variables I use in a routine (e.g. > osmode). This way even when a user cancels the routine their settings are > left how they had them when it started. > > James > >
Message 12 of 12
Anonymous
in reply to: Anonymous

Try this... (command "_non" P3) I've been using my own custom Between.lsp routine for years, and the above line always works where other lines have failed. "Mark McDonough" wrote in message news:403e2549_3@newsprd01... > Excellent! That works. I guess it was the COMMAND function that does the > trick. > > However, in my version I still have an odd problem. When asked for the 2nd > point, if I hit ESC, I'd like the command to exit cleanly, but for some > reason it's not working and mysteriously the P2 point is still getting a > value: > > (defun c:MIP (/ p1 p2 p3 os) > (setq os (getvar "osmode") > p1 (getpoint "\nShow 1st point: ") > ) > (princ "\nCalculate midpoint...") > (if p1 (setq p2 (getpoint "\nShow 2nd point: "))) > (setvar "osmode" 0) > (if (and p1 p2) > (setq p3 (mapcar '(lambda(a b)(*(+ a b 0.0) 0.5)) p1 p2)) > (princ "\n2 points not picked.") > ) > (if p3 (command p3) (princ)) > (setvar "osmode" os) > (setq os nil) > (princ) > ) > > When I hit ESC on the 2nd point (e.g. the user changes his/her mind) then I > get: > > Show 2nd point: *Cancel* > ; error: Function cancelled > Specify first point: Specify first point: > > > -- > Mark McDonough > Sasaki Associates > http://www.sasaki.com > > "JamesA" wrote in message > news:403e14df$1_3@newsprd01... > > Good morning Mark. I believe this works how you want it to... > > > > (defun c:MIP (/ p1 p2 oldos) > > (setq p1 (getpoint "\nPick first point: ") > > p2 (getpoint p1 "\nPick second point: ") > > p1 (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2) > > oldos (getvar "osmode") > > ) > > (setvar "osmode" 0) > > (command p1) > > (setvar "osmode" oldos) > > ) > > > > If not, does it: > > > > 1. Run but still return the wrong point? Check other point mod. modes > > maybe? (orthomode, autosnap, snapmode, ...) > > 2. Not run at all? You do have "defun c:<...>" right? And it looks like > > you are calling with the ' in 'MIP. > > > > Doesn't this work? Stay posted. > > > > James > > > > > >

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost