brawleyman Posted July 15, 2009 Posted July 15, 2009 I have this LISP code below that works just fine, except that when it is done running, it comes up with: "Command: ; error: no function definition: nil" (defun c:crun () (setvar "cmdecho" 1) (setq crunsearch (tblsearch "dimstyle" "crun")) (if (not crunsearch) (;do this (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );end progn );end do this (;otherwise, do this (progn (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );end progn );end otherwise );end if (princ) (setvar "cmdecho" 1) ) I don't know if it is ending that part of the routine correctly or not. The routine searches for a dimstyle and if it is there, it goes ahead and continues with the routine, otherwise, it has to create the dimstyle, then go on with the rest of the routine. Any help is greatly appreciated. Quote
The Buzzard Posted July 15, 2009 Posted July 15, 2009 I have this LISP code below that works just fine, except that when it is done running, it comes up with: "Command: ; error: no function definition: nil" (defun c:crun () (setvar "cmdecho" 1) (setq crunsearch (tblsearch "dimstyle" "crun")) (if (not crunsearch) (;do this (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );end progn );end do this (;otherwise, do this (progn (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );end progn );end otherwise );end if (princ) (setvar "cmdecho" 1) ) I don't know if it is ending that part of the routine correctly or not. The routine searches for a dimstyle and if it is there, it goes ahead and continues with the routine, otherwise, it has to create the dimstyle, then go on with the rest of the routine. Any help is greatly appreciated. For one thing you have a bracket backwards (if (not crunsearch) [color=red](;do this[/color] Maybe something like this instead: (if (null (tblsearch "dimstyle" "crun") ) (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") Another bracket backwards: [color=red](;otherwise, do this[/color] I did not test the code. You may have more problems as well. Quote
brawleyman Posted July 15, 2009 Author Posted July 15, 2009 For one thing you have a bracket backwards (if (not crunsearch) [color=red](;do this[/color] I did not test the code. You may have more problems as well. I think that it is facing the right way. It is just that at the end of either part of the "then" and "else" parts, it comes up with the error. I don't know if there is a better way to end both parts of the routine. Also, off topic, is there a way to make linear dimensions match your snapang? Quote
The Buzzard Posted July 15, 2009 Posted July 15, 2009 I think that it is facing the right way. It is just that at the end of either part of the "then" and "else" parts, it comes up with the error. I don't know if there is a better way to end both parts of the routine. Also, off topic, is there a way to make linear dimensions match your snapang? Good Luck! Quote
The Buzzard Posted July 15, 2009 Posted July 15, 2009 Good Luck! If you get a moment review this code. It is a dimension style manager. You will find everything you need in here. DSM.zip Quote
brawleyman Posted July 15, 2009 Author Posted July 15, 2009 Okay. Now I have it so that it doesn't come up with the error. However, now it says "1" at the command line. What is causing that? Is there something that I am missing? (defun c:crun () (setvar "cmdecho" 0) (if (null (tblsearch "dimstyle" "crun") ) (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn (or (progn (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn );end or );end if (setvar "cmdecho" 1) (princ) ) ) Just got it figured out. I revised the above code. Thanks The Buzzard for your help! Back to my earlier question, can you make linear dimensions align with SNAPANG or does it only work with the UCS? I want to try to make my routine above work with snapang if possible without changing the UCS. Quote
The Buzzard Posted July 15, 2009 Posted July 15, 2009 Okay. Now I have it so that it doesn't come up with the error. However, now it says "1" at the command line. What is causing that? Is there something that I am missing? (defun c:crun () (setvar "cmdecho" 0) (if (null (tblsearch "dimstyle" "crun") ) (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn (or (progn (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn );end or );end if (setvar "cmdecho" 1) ) First of all, What are you trying to do? Is this some kind of dimstyle setter or something else. I see you are try to explode a dimension after it is created. Also you are setting command echo to on at the start of your program. Why? Then you are setting it on again at the end of your program. I am not sure what is suppose to happen or what you are trying to accomplish. Can you please explain? Quote
brawleyman Posted July 15, 2009 Author Posted July 15, 2009 First of all, What are you trying to do?Is this some kind of dimstyle setter or something else. I see you are try to explode a dimension after it is created. Also you are setting command echo to on at the start of your program. Why? Then you are setting it on again at the end of your program. I am not sure what is suppose to happen or what you are trying to accomplish. Can you please explain? This routine is a kind of crude way to create conduit runs that have only x and y coordinates. I have a separate tool that I can quickly set the fillet radius so that after I set it, I click my 2 points that I need to connect then point the cursor in the direction I need the conduit to run and Voila! I have beautiful conduit runs. It is also handy for making "Z" or "U" shaped conduit runs between devices. I could probably eventually just make enough LISP code to accomplish the same thing, but I figured that a linear dimension worked right for what I wanted, so I just created a custom dim style with no text or spacing and edit it to make my conduit. It is pretty nifty and works well. It is hard to explain exactly how it works, but if you load it into CAD and play around a bit with it, you will see what I needed and how it works for me. Thanks for your help in tweaking it! Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 Brawleyman, an IF statement does not need those "extra" brackets for the "else" statements: For example: (if (<this is true>) (progn (<do this>) (<and this>) ) ; End Progn (<else do this> ) ; end if Quote
The Buzzard Posted July 15, 2009 Posted July 15, 2009 Okay. Now I have it so that it doesn't come up with the error. However, now it says "1" at the command line. What is causing that? Is there something that I am missing? (defun c:crun () (setvar "cmdecho" 0) (if (null (tblsearch "dimstyle" "crun") ) (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn (or (progn (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") );progn );end or );end if (setvar "cmdecho" 1) (princ) ) ) Just got it figured out. I revised the above code. Thanks The Buzzard for your help! Back to my earlier question, can you make linear dimensions align with SNAPANG or does it only work with the UCS? I want to try to make my routine above work with snapang if possible without changing the UCS. You have an extra right paren at the end of the code. I am still not sure about what it is you are doing, But I wait for the next version. Good Luck Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 Why not reduce the code to something like this: (defun c:crun () (if (not (tblsearch "DIMSTYLE" "crun")) (progn (mapcar 'setvar '("DIMTOL" "DIMLIM" "DIMTIH"... etc ) '( 0 0 0 ... etc ) ) ; End Mapcar (command "-dimstyle" "_s" "crun") ) ; end progn ) ; end IF (mapcar 'setvar '("CMDECHO" "PEDITACCEPT") '(0 1)) (command "-dimstyle" "r" "crun") (command "_.dimlinear" pause pause "t" " " pause) (command "_.explode" "last") (command "_.pedit" "m" "previous" "" "j" "0" "") (command "_.fillet" "p" "last") (mapcar 'setvar '("CMDECHO" "PEDITACCEPT") '(1 0)) (princ)) Take the actual drafting side out of the IF statement altogether, and set the correct variable values, using mapcar. Quote
Se7en Posted July 15, 2009 Posted July 15, 2009 ... (mapcar 'setvar '("DIMTOL" "DIMLIM" "DIMTIH"... etc ) '( 0 0 0 ... etc ) ) ; End Mapcar ... ... I would recommend building a list of two items the first being the variable and the next being the value (because of potentenial maintence issues). Like: ( ... ("DIMTOL" 0) ("DIMLIM" 0) ...) and just add a lambda in your mapcar statement and your rocking. Quote
Lee Mac Posted July 16, 2009 Posted July 16, 2009 Are you recommending something like this Se7en? (mapcar (function (lambda (x) (setvar (car x) (cdr x)))) '(("DIMTOL" . 0) (... Or maybe this: (mapcar (function (lambda (x) (apply 'setvar x))) '(("DIMTOL" 0) ("DIMLIM" 0))) Quote
Se7en Posted July 16, 2009 Posted July 16, 2009 yep. as long as you pair them i think it would offer a better solution. Only for later maintenance, not performance; that way in the future when [you] wish to revise a variable [you] can quickly see what variable and what value to alter. [you] can also keep them in a separate text file as well. I do that for my layers. Quote
brawleyman Posted July 16, 2009 Author Posted July 16, 2009 Thanks guys, but that stuff is way over my head. I am just dealing with simple commands and values, nothing too hard. Okay, here is my latest version that works just fine for me and does just what I want: (defun c:crun () (setvar "cmdecho" 0) (if (not (tblsearch "DIMSTYLE" "crun")) (progn (command "DIMTOL" "0") (command "DIMLIM" "0") (command "DIMTIH" "0") (command "DIMTOH" "0") (command "DIMSE1" "0") (command "DIMSE2" "0") (command "DIMALT" "0") (command "DIMTOFL" "1") (command "DIMSAH" "0") (command "DIMTIX" "1") (command "DIMSOXD" "0") (command "DIMSD1" "0") (command "DIMSD2" "0") (command "DIMUPT" "0") (command "DIMDSEP" ".") (command "DIMALTD" "2") (command "DIMZIN" "1") (command "DIMJUST" "0") (command "DIMFIT" "1") (command "DIMTZIN" "0") (command "DIMALTZ" "0") (command "DIMALTTZ" "0") (command "DIMTAD" "3") (command "DIMUNIT" "2") (command "DIMAUNIT" "0") (command "DIMDEC" "1") (command "DIMTDEC" "1") (command "DIMALTU" "2") (command "DIMALTTD" "2") (command "DIMADEC" "4") (command "DIMAZIN" "0") (command "DIMATFIT" "3") (command "DIMFRAC" "0") (command "DIMLUNIT" "2") (command "DIMTMOVE" "2") (command "DIMTXSTY" "standard") (command "DIMASZ" "0") (command "DIMEXO" "0") (command "DIMDLI" "0") (command "DIMEXE" "0") (command "DIMRND" "0") (command "DIMDLE" "0") (command "DIMTP" "0") (command "DIMTM" "0") (command "DIMTXT" "9") (command "DIMCEN" "0") (command "DIMTSZ" "0") (command "DIMALTF" "1") (command "DIMLFAC" "1") (command "DIMTVP" "0") (command "DIMTFAC" "1") (command "DIMGAP" "0") (command "DIMALTRND" "0") (command "DIMPOST" "'") (command "DIMAPOST" ".") (command "DIMBLK" "_none") (command "DIMBLK1" "_none") (command "DIMBLK2" "_none") (command "DIMLDRBLK" "_none") (command "DIMCLRD" "0") (command "DIMCLRE" "0") (command "DIMCLRT" "0") (command "DIMLWD" "-2") (command "DIMLWE" "-2") (command "-dimstyle" "s" "crun") );end progn );end if (command "-dimstyle" "r" "crun") (command "_dimlinear" pause pause "t" " " pause) (command "explode" "last") (command "peditaccept" "1") (command "pedit" "m" "previous" "" "j" "0" "") (command "fillet" "p" "last") (command "peditaccept" "0") (setvar "cmdecho" 1) (princ) ) The only other thing that I need to do is that right now, when it creates the dimstyle to make my conduit, it stays on that dimstyle. What would be the best way or simplest code to revert back to the previous dimstyle used before creating crun? ********EDIT******** LeeMac: I took your advice and revised it a little above to reduce the redundancy of the ending result. I personally like having the "DIMxxx" variable in a column with the value next to it. It saves from having an ultra wide txt screen. I tested the latest code and it works the same, just with less code. Now, I just need to figure out how to go back to the previous dimstyle... Quote
Freerefill Posted July 16, 2009 Posted July 16, 2009 Interesting topic. Very awesome ways to set variables. My two cents, I played around with the mapcar thing a bit and came up with this: (defun c:command() ; Create list (setq listy '(("cmdecho" 0)("osmode" 6791)("regenmode" 1))) ; Get current settings (setq listyGet (mapcar '(lambda (x) (list (car x) (getvar (car x)))) listy)) ; Set new settings (mapcar '(lambda (x) (setvar (car x) (cadr x))) listy) ; Do stuff ; Reset to old settings (mapcar '(lambda (x) (setvar (car x) (cadr x))) listyGet) ) Basically, create a list (as suggested) of the system variables you want and what to set them to. Before setting them, perform a similar operation to get the current value of each of those command variables, and set it equal to a variable for later use (listyGet). Then, again as suggested, use a mapcar to set everything. Since you've got the old settings, when you're done, you can just use the same method to reset everything back to what it was. *Edit* Looking at it now, you could probably use an "apply" or something better than "mapcars".. oh well. I never said I was the best, or any good for that matter. Again, just my two cents. ^^ Quote
Se7en Posted July 16, 2009 Posted July 16, 2009 Interesting topic. Very awesome ways to set variables. My two cents, I played around with the mapcar thing a bit and came up with this: you mean like this? [ http://www.cadtutor.net/forum/showpost.php?p=222647&postcount=3 ] Quote
Lee Mac Posted July 16, 2009 Posted July 16, 2009 you mean like this?[ http://www.cadtutor.net/forum/showpost.php?p=222647&postcount=3 ] I was thinking of that example too... Quote
Freerefill Posted July 16, 2009 Posted July 16, 2009 This is why I don't frequent this forum anymore.. everything I can think of has already been done Quote
Lee Mac Posted July 16, 2009 Posted July 16, 2009 You wanna visit theSwamp.org, I always get that feeling over there... 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.