Deby Ferdian Posted March 19, 2016 Posted March 19, 2016 Assign combination keys of Toggle OSMODE & 3DOSMODE on/off. Is it Possible??? Assign them not just only for "F3" & "F4" but also to CTRL+F as OSMODE ON/OFF and CTRL+SHIFT+F as 3DOSMODE ON/OFF. Whould somebody help me ??? Quote
Grrr Posted March 20, 2016 Posted March 20, 2016 Hi, I know that with lisp you could assign those toggles as a commad definitions. But I don't know how to assign these same commands as the shortcuts you need (I'm talking about the key-combinations in your example). Quote
David Bethel Posted March 20, 2016 Posted March 20, 2016 Because some of the releases I use did not have a very good interface between windows and some keyboards, I use this as a sysvar toggle. [color=#8b4513];;;TOGGLE SYSVARS[/color] [b][color=BLACK]([/color][/b]defun c:tg [b][color=FUCHSIA]([/color][/b]/ v[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]initget [color=#2f4f4f]"Blipmode Cmddia Gridmode Highlight splFrame Orthomode Tilemode Snapmode"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq v [b][color=GREEN]([/color][/b]getkword [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"\nToggle - "[/color] [color=#2f4f4f]"Blipmode"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"BLIPMODE"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/Cmddia"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"CMDDIA"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/Gridmode"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"GRIDMODE"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/Highlight"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"HIGHLIGHT"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/splFrame"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"SPLFRAME"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/Orthomode"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"ORTHOMODE"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]"/Tilemode"[/color] [color=#2f4f4f]"/Snapmode"[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]= [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"SNAPMODE"[/color][b][color=TEAL])[/color][/b] 1[b][color=PURPLE])[/color][/b] [color=#2f4f4f]"^"[/color] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b] [color=#2f4f4f]": "[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setvar v [b][color=MAROON]([/color][/b]- 1 [b][color=GREEN]([/color][/b]getvar v[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ v[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] The crtl+ascii character usually worked, the function keys were hit and miss ie ^b toggles snapmode You could probably modify this to any sysvar that uses the 0/1 bit values -David Quote
Deby Ferdian Posted March 20, 2016 Author Posted March 20, 2016 AhrrrhgHgrk'K'... I can't try out arround at all as you are suggest you gave to me as along as my currently problem has currently running out way now and didn't still not resolved yet. That's an important problem that should be resolved first in priority situation right now in my post in another page at the same forum. Here it is, http://www.cadtutor.net/forum/showthread.php?96115-I-get-an-error-when-I-try-to-convert-the-solid-object-to-quot-NURB-quot Bye the way thanks for your suggestion and have give an answer get soon. I really very thanks to you all and sorry about my words it isn't good enough... Quote
Deby Ferdian Posted March 20, 2016 Author Posted March 20, 2016 Hi @David Bethel! It's nice LISP very nicely! but I had failed when insert the "osMode & 3Dosmode" code additional the under to your code the next of "Snapmode". Here it is of mine! (defun c:3SS (/ v) (while (or (initget "Blipmode Cmddia Gridmode Highlight splFrame Orthomode Tilemode Snapmode [b][color=red]osMode 3Dosmode[/color][/b]") (setq v (getkword (strcat "\nToggle - " "Blipmode" (if (= (getvar "BLIPMODE") 1) "^" "") "/Cmddia" (if (= (getvar "CMDDIA") 1) "^" "") "/Gridmode" (if (= (getvar "GRIDMODE") 1) "^" "") "/Highlight" (if (= (getvar "HIGHLIGHT") 1) "^" "") "/splFrame" (if (= (getvar "SPLFRAME") 1) "^" "") "/Orthomode" (if (= (getvar "ORTHOMODE") 1) "^" "") "/Tilemode" "/Snapmode" (if (= (getvar "SNAPMODE") 1) "^" "")[b][color=red] "/osMode" (if (= (getvar "OSMODE") 1) "^" "") "/3Dosmode" (if (= (getvar "3DOSMODE") 1) "^" "")[/color][/b] ": ")))) (setvar v (- 1 (getvar v))) (princ v)) (prin1)) Quote
Grrr Posted March 20, 2016 Posted March 20, 2016 Alright, try this: (defun c:test (/ ) (if (not *ans*) (setq *ans* "osmode")) (initget "osmode 3dosmode") (setq *ans* (cond ( (getkword (strcat "\nToggle [osmode/3dosmode] <" *ans* ">: "))) ( *ans* ))) (cond ((= *ans* "osmode") (if (= (getvar 'osmode ) 0) (progn (setvar "osmode" 15359) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "osmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "osmode" 0) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "osmode") 2 0) "\" (OFF)" )) );progn false );if ) ((= *ans* "3dosmode") (if (= (getvar '3dosmode ) 0) (progn (setvar "3dosmode" 1022) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "3dosmode" 0) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (OFF)" )) );progn false );if ) );cond (princ) );defun Adjust the 15359 value for osmode and 1022 value for 3dosmode to fit your needs. Quote
David Bethel Posted March 21, 2016 Posted March 21, 2016 As Grrr points out, these 2 sysvars are not 0/1 based values. So they cannot simply be toggled On/OFF. -David Quote
Deby Ferdian Posted March 21, 2016 Author Posted March 21, 2016 Wow..! @Grr... It's wonderful and nice code but when modify with my construction of code was failed would you help me @Grr.. ? (defun c:[color=red][b]TGG[/b][/color] (/ ) (if (not *ans*) (setq *ans* "osmode")) (initget "Osmode 3dosmode [b][color=red]Lwdisplay[/color][/b]") (setq *ans* (cond ( (getkword (strcat "\nToggle [Osmode/3dosmode[b][color=red]/Lwdisplay[/color][/b]] <" *ans* ">: "))) ( *ans* ))) (cond ((= *ans* "osmode") (if (= (getvar 'osmode ) 0) (progn (setvar "osmode" [color=red][b]8367[/b][/color]) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "osmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "osmode" [b][color=red]24751[/color][/b]) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "osmode") 2 0) "\" (OFF)" )) );progn false );if ) ((= *ans* "3dosmode") (if (= (getvar '3dosmode ) 0) (progn (setvar "3dosmode" [b][color=red]62[/color][/b]) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "3dosmode" [color=red][b]63[/b][/color]) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (OFF)" )) );progn false );if )[color=red][b] ((= *ans* "LWDISPLAY") (if (= (getvar 'LWDISPLAY ) 0) (progn (setvar "LWDISPLAY" ON) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar "LWDISPLAY") 2 0) "\" (ON)" )) );progn true (progn (setvar "LWDISPLAY" OFF) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar "LWDISPLAY") 2 0) "\" (OFF)" )) );progn false );if )[/b][/color] );cond (princ) );defun In red lines color are modified by me it doesn't work.. Thanks in advance again! Quote
marko_ribar Posted March 21, 2016 Posted March 21, 2016 As for your input in initget : Lwdisplay You must provide adequate string in cond statement : [Change : ((= *ans* "LWDISPLAY") ... ] [To this : ((= *ans* "Lwdisplay") ... ] [EDIT : The same is referenced and for "Osmode" - change ((= *ans* "osmode")...) to ((= *ans* "Osmode")...)] [EDIT 2 : Also this line : (if (not *ans*) (setq *ans* "osmode")), should be : (if (not *ans*) (setq *ans* "Osmode"))] Quote
Deby Ferdian Posted March 21, 2016 Author Posted March 21, 2016 (edited) It's still won't Work @marko_ribar! where is I get my faults ? and this is my try applying that what you had told... (defun c:TGG (/ ) (if (not *ans*) (setq *ans* "[color=red][b]Osmode[/b][/color]")) (initget "[b][color=red]Osmode 3dosmode Lwdisplay[/color][/b]") (setq *ans* (cond ( (getkword (strcat "\nToggle [[color=red][b]Osmode[/b][/color]/[color=red][b]3dosmode[/b][/color]/[color=red][b]Lwdisplay[/b][/color]] <" *ans* ">: "))) ( *ans* ))) (cond ((= *ans* "[color=red][b]Osmode[/b][/color]") (if (= (getvar '[color=red][b]Osmode [/b][/color]) 0) (progn (setvar "[color=red][b]Osmode[/b][/color]" [color=red][b]8367[/b][/color]) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "[color=red][b]Osmode[/b][/color]") 2 0) "\" (ON)" )) );progn true (progn (setvar "[color=red][b]Osmode[/b][/color]" [b][color=red]24751[/color][/b]) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "[color=red][b]Osmode[/b][/color]") 2 0) "\" (OFF)" )) );progn false );if ) ((= *ans* "[color=red][b]3dosmode[/b][/color]") (if (= (getvar '[b][color=red]3dosmode [/color][/b]) 0) (progn (setvar "[color=red][b]3dosmode[/b][/color]" [color=red][b]62[/b][/color]) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "[b][color=red]3dosmode[/color][/b]") 2 0) "\" (ON)" )) );progn true (progn (setvar "[b][color=red]3dosmode[/color][/b]" [color=red][b]63[/b][/color]) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "[b][color=red]3dosmode[/color][/b]") 2 0) "\" (OFF)" )) );progn false );if )[b][color=dimgray] ((= *ans* "[color=red]Lwdisplay[/color]") (if (= (getvar '[color=red]Lwdisplay [/color]) 0) (progn (setvar "[/color][/b][b][color=dimgray][b][color=dimgray][color=red]Lwdisplay[/color][/color][/b]" [color=red]ON[/color]) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar "[color=red]Lwdisplay[/color]") 2 0) "\" (ON)" )) );progn true (progn (setvar "[/color][/b][b][color=dimgray][b][color=dimgray][color=red]Lwdisplay[/color][/color][/b]" [color=red]OFF[/color]) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar "[color=red]Lwdisplay[/color]") 2 0) "\" (OFF)" )) );progn false );if ) );cond (princ) );defun[/color][/b] Edited March 21, 2016 by Deby Ferdian *applying* Quote
tombu Posted March 21, 2016 Posted March 21, 2016 Old Osmode toggle I used before they added the button flyout to the status bar: (defun c:tosnap ( / csnap) (setq csnap (getvar "osmode")) (cond ((= csnap 16384)(setvar "osmode" 0)) ((< csnap 16384)(setvar "osmode"(+ csnap 16384))) ((> csnap 16384)(setvar "osmode"(- csnap 16384))) ) (cond ((= csnap 0)(princ)) ; ((= csnap 0)(command "'_dsettings")) ((< csnap 16384)(princ "\n<Osnap off>")) ((>= csnap 16384)(princ "\n<Osnap on>")) ) (princ) ) Should help get you started. Quote
BKT Posted March 21, 2016 Posted March 21, 2016 I don't have the latest version of AutoCAD available to me, but previous versions (and BricsCAD) can use either "1" or "ON" and "0" or "OFF" to toggle LWDISPLAY at the command line, but in LISP you will need to use "1" or "0". See if that works for you: (setvar "LWDISPLAY" 1) (setvar "LWDISPLAY" 0) Quote
tombu Posted March 21, 2016 Posted March 21, 2016 For simple on/off toggles nothing is easier than using ai_onoff: (ai_onoff "LWDISPLAY") This ai utility has been around as long as I've been using AutoCAD 23 years. Quote
BKT Posted March 21, 2016 Posted March 21, 2016 Hey, I like that! I have an earlier version of intelliCAD and it's not available there, but it works fine in BricsCAD15. Thanks for the heads-up! One more tool in the toolbox... didn't do a lot of LISP while working full time but getting into it now. For simple on/off toggles nothing is easier than using ai_onoff: (ai_onoff "LWDISPLAY") This ai utility has been around as long as I've been using AutoCAD 23 years. Quote
tombu Posted March 21, 2016 Posted March 21, 2016 ai_utils.lsp came with early versions, now they're no longer in a simple file we can open. If anyone knows where to find a good reference for all these commands (like AI_MOLC) and lisp functions (like ai_onoff) please post it. Best I could find is http://www.cadforum.cz/cadforum_en/command.asp?ini=A Quote
broncos15 Posted March 21, 2016 Posted March 21, 2016 Assign combination keys of Toggle OSMODE & 3DOSMODE on/off. Is it Possible??? Assign them not just only for "F3" & "F4" but also to CTRL+F as OSMODE ON/OFF and CTRL+SHIFT+F as 3DOSMODE ON/OFF. Whould somebody help me ??? This is probably more easily done using the CUI Keyboard Shortcuts menu. Quote
Deby Ferdian Posted March 21, 2016 Author Posted March 21, 2016 (edited) I don't get it.. @tombu! sorry.. but I'll try I try to think it. How to make that and modify it to "3DOSMODE" I was and have no have good a review for now... Hi, @broncos15! I was but get nothing. I didn't know why? The act what I have done of all this time is try to assign 3DOSMODE to another combination keys not just for hotkey like; F4 but exception of it. I want to assign it to CTRL+SHIFT+F for 3DOSMODE but the resort won't appears a something like what I thought in normally what I've pressed on dialogue box of key.. Edited March 21, 2016 by Deby Ferdian Reply more to a peaople.. Quote
Grrr Posted March 21, 2016 Posted March 21, 2016 Hi, Heres another modification: (defun c:TGG (/ ) (if (not *ans*) (setq *ans* "Osmode")) (initget "Osmode 3dosmode Lwdisplay") (setq *ans* (cond ( (getkword (strcat "\nToggle [Osmode/3dosmode/Lwdisplay] <" *ans* ">: "))) ( *ans* ))) (cond ((= *ans* "Osmode") (if (= (getvar 'Osmode ) 24751) (progn (setvar "Osmode" 8367) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "Osmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "Osmode" 24751) (princ (strcat "\nOSMODE is set to \"" (rtos(getvar "Osmode") 2 0) "\" (OFF)" )) );progn false );if ) ((= *ans* "3dosmode") (if (= (getvar '3dosmode ) 63) (progn (setvar "3dosmode" 62) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (ON)" )) );progn true (progn (setvar "3dosmode" 63) (princ (strcat "\n3D-osmode is set to \"" (rtos(getvar "3dosmode") 2 0) "\" (OFF)" )) );progn false );if ) ((= *ans* "Lwdisplay") (if (= (getvar 'Lwdisplay ) 0) (progn (setvar 'LWDISPLAY 1 ) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar 'lwdisplay ) 2 0) "\" (ON)" )) );progn true (progn (setvar 'LWDISPLAY 0 ) (princ (strcat "\nLWDISPLAY is set to \"" (rtos(getvar 'lwdisplay ) 2 0) "\" (OFF)" )) );progn false );if ) );cond (princ) );defun I've modified your osmode and 3dosmode toggling, I mean: (if (= (getvar 'Osmode ) 24751) If osmode is on "24751" value it will change it to 8367 and if its not on 24751 it will change it to 24751, because in my previous post the check was on "0" value. Thank god I learn from the best (Lee Mac, Tharwat... hmsilva, Stefan BMR, Jef!...) otherwise I couldn't help you! Quote
tombu Posted March 21, 2016 Posted March 21, 2016 I don't get it.. @tombu! sorry.. but I'll try I try to think it. How to make that and modify it to "3DOSMODE" I was and have no have good a review for now... Hi, @broncos15! I was but get nothing. I didn't know why? The act what I have done of all this time is try to assign 3DOSMODE to another combination keys not just for hotkey like; F4 but exception of it. I want to assign it to CTRL+SHIFT+F for 3DOSMODE but the resort won't appears a something like what I thought in normally what I've pressed on dialogue box of key.. The test for "3DOSMODE" needs to be (if (logand 1 (getvar "3dosmode")) Quote
Lee Mac Posted March 21, 2016 Posted March 21, 2016 Old Osmode toggle I used before they added the button flyout to the status bar: (defun c:tosnap ( / csnap) (setq csnap (getvar "osmode")) (cond ((= csnap 16384)(setvar "osmode" 0)) ((< csnap 16384)(setvar "osmode"(+ csnap 16384))) ((> csnap 16384)(setvar "osmode"(- csnap 16384))) ) (cond ((= csnap 0)(princ)) ; ((= csnap 0)(command "'_dsettings")) ((< csnap 16384)(princ "\n<Osnap off>")) ((>= csnap 16384)(princ "\n<Osnap on>")) ) (princ) ) Should help get you started. FWIW, this could become: (defun c:tosnap nil (princ (if (zerop (logand 16384 (setvar 'osmode (boole 6 16384 (getvar 'osmode))))) "\n<Osnap on>" "\n<Osnap off>")) (princ) ) Quote
Recommended Posts
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.