Is there a better way to write this? I did not write this orginally but I am trying to modify it and being new at this the code seems confusing..... (command "dimstyle" "save" "standard" "y") (command "purge" "dimstyles" "" "n") (COMMAND "Lunits" "4" "LUPREC" "3" "BLIPMODE" "0") (COMMAND "-style" "romans" "romans.shx" "0" "" "" "" "" "") (command "dimldrblk" ".") (command "zoom" "e" "zoom" ".95x" "dimtxt" "0.09375" "dimasz" "0.09375" "dimse1" "off" "dimse2" "off" "dimgap" "0.03125" "DIMZIN" "3" "DIMTAD" "0" "dimassoc" "2" "dimfit" "4" "dimtih" "on" "dimtoh" "on" "dimtix" "on" "dimtofl" "off" "dimblk" "." "dimsah" "off" "dimtxsty" "romans" "dimunit" "4" "dimclrd" "256" "dimclre" "256" "dimclrt" "256" "dimdle" "0" "dimdli" "0.375" "dimexe" "3/32" "dimexo" "1/16" "dimjust" "0" "dimsho" "on" "dimupt" "1" "dimpost" "." "dimrnd" "0" "dimdec" "3" "dimtfac" "0.75" "DIMTVP" "0" "DIMALT" "OFF" ) (command "cmdecho" "1") (setq scale (getreal "Enter drawing scale factor:")) PAUSE (command "dimscale" scale) (command "ltscale" scale) (command "cmdecho" "0") (command "dimlfac" "1" "dimsd1" "0" "dimsd2" "0") (COMMAND "dimstyle" "s" "Feet" "Y") (command "dimlfac" "1" "dimsd1" "0" "dimsd2" "0") (command "dimunit" "5" (SETVAR "DIMPOST" (CHR 34)) "dimstyle" "s" "Inch" "Y" ) (command "dimlfac" "1" "dimsd1" "0" "dimsd2" "0") (command "dimtad" "0" (setvar "dimpost" (chr 46)) "dimasz" "1/8" "dimstyle" "s" "Arrow" "Y" ) (command "dimlfac" "1") (command "dimasz" "0.0625" "dimblk" "_dot" "dimLDRblk" "_dot" "dimstyle" "s" "Dot" "y" ) (command "dimstyle" "restore" "Feet" "dimscale" "1" "dimstyle" "s" "P-Feet" "y") (command "dimstyle" "restore" "Inch" "dimscale" "1" "dimstyle" "s" "P-Inch" "y") (command "dimstyle" "restore" "Arrow" "dimscale" "1" "dimstyle" "s" "P-Arrow" "y") (command "dimstyle" "restore" "Dot" "dimscale" "1" "dimstyle" "s" "P-Dot" "y") (command "mirrtext" "0") (command "textsize" (* (getvar "ltscale") 0.09375)) (command "attdia" "1") (Command "ucsicon" "on") (command "cmdecho" "1") (princ) )
A lot of those (command)'s are actually system variables and could be set like this: (setvar "dimdec" 3). Depending on how you view it, doing something like this may help simplify it also: (setq a (list "dimdec" "dimfit" "dimlunit" "dimtad" "dimasz")) (setq b (list 4 3 1 2 0.12)) (mapcar 'setvar a b) </snip>
R.K. McSwain, IMO, this is not a good idea. Two lists which have no direct association with each other is a potential maintenance headache. (setq a (list "dimdec" "dimfit" "dimlunit" "dimtad" "dimasz")) (setq b (list 4 3 1 2 0.12)) (mapcar 'setvar a b) Just my two cents... Joe Burke
right, seems easier to read llike (setq varlist (list (cons "dimdec" 4) (cons "dimfit" 3) (cons "dimlunit" 1) ...etc ) ) (mapcar (function (lambda(l) (setvar(car l)(cdr l)) ) ) varlist );map
Is this part of a "defun"-type routine? It doesn't have that at the beginning, but the right-parenthesis at the end (which I don't find a mate for) makes me wonder. Whether or not it is, it could be shorter by combining most of the (command) calls into one (the way some multiple entries are already). (It also has lots of extra spaces between entries within them.) Without changing the sequence at all: (command "dimstyle" "save" "standard" "y" "purge" "dimstyles" "" "n" "Lunits" "4" "LUPREC" "3" "BLIPMODE" "0" "-style" "romans" "romans.shx" "0" "" "" "" "" "" "dimldrblk" "." "zoom" "e" "zoom" ".95x" "dimtxt" "0.09375" "dimasz" "0.09375" "dimse1" "off" "dimse2" "off" "dimgap" "0.03125" "DIMZIN" "3" "DIMTAD" "0" "dimassoc" "2" "dimfit" "4" "dimtih" "on" "dimtoh" "on" "dimtix" "on" "dimtofl" "off" "dimblk" "." "dimsah" "off" "dimtxsty" "romans" "dimunit" "4" "dimclrd" "256" "dimclre" "256" "dimclrt" "256" "dimdle" "0" "dimdli" "0.375" "dimexe" "3/32" "dimexo" "1/16" "dimjust" "0" "dimsho" "on" "dimupt" "1" "dimpost" "." "dimrnd" "0" "dimdec" "3" "dimtfac" "0.75" "DIMTVP" "0" "DIMALT" "OFF" "cmdecho" "1" ) (setq scale (getreal "Enter drawing scale factor:")) PAUSE (command "dimscale" scale "ltscale" scale "cmdecho" "0" "dimlfac" "1" "dimsd1" "0" "dimsd2" "0" "dimstyle" "s" "Feet" "Y" "dimlfac" "1" "dimsd1" "0" "dimsd2" "0" "dimunit" "5" ) (SETVAR "DIMPOST" (CHR 34)) (command "dimstyle" "s" "Inch" "Y" "dimlfac" "1" "dimsd1" "0" "dimsd2" "0" "dimtad" "0" ) (setvar "dimpost" (chr 46)) (command "dimasz" "1/8" "dimstyle" "s" "Arrow" "Y" "dimlfac" "1" "dimasz" "0.0625" "dimblk" "_dot" "dimLDRblk" "_dot" "dimstyle" "s" "Dot" "y" "dimstyle" "restore" "Feet" "dimscale" "1" "dimstyle" "s" "P-Feet" "y" "dimstyle" "restore" "Inch" "dimscale" "1" "dimstyle" "s" "P-Inch" "y" "dimstyle" "restore" "Arrow" "dimscale" "1" "dimstyle" "s" "P-Arrow" "y" "dimstyle" "restore" "Dot" "dimscale" "1" "dimstyle" "s" "P-Dot" "y" "mirrtext" "0" "textsize" (* (getvar "ltscale") 0.09375)) "attdia" "1" "ucsicon" "on" "cmdecho" "1" ) (princ) ) And I'm not positive, but I think you could probably do the (setvar "dimpost" (chr xx)) things inside a (command) call, too: (command <whatever others> "dimpost" (chr xx) <whatever others>) in which case you could pull the (setq scale... thing out to the front and throw ALL the rest of it into one big (command) call. If it's NOT in a (defun) routine, you could shorten it a LOT by eliminating the (command) calls and nearly all the quotation marks, replacing the "" with ; and the PAUSE with \, adding some !'s and some plus signs: dimstyle save standard y -purge dimstyles ; n Lunits 4+ LUPREC 3 BLIPMODE 0 -style romans romans.shx + 0 ;;;;; dimldrblk . zoom e zoom .95x dimtxt 0.09375 + <...etc....> (setq scale (getreal "Enter drawing scale factor:")) \+ dimscale !scale ltscale !scale cmdecho 0 dimlfac 1 + <...etc....> OR, you could make a routine that would purge all dimstyles and insert a drawing that carries the new ones, with nothing drawn in it. Or you could bring them in via the Design Center. Or you could have a drawing template set up with them defined in it, and if you need to make them part of an existing drawing, make a new drawing from the template instead, and insert the existing drawing into it. [As of A2K4, you need to say "-purge" instead of "purge" (which is now a dialog-box command), and there might be other release-specific tweaking needed.] Kent Cooper, AIA am trying to modify it and being new at this the code seems confusing.....
I agree, the association list is more clear and a better way to do things. Since the values are fixed it could be quoted. (setq varlist '(("dimdec" . 4) ("dimfit" . 3) ("dimlunit" . 1) ...))
Yes this is part of a "defun"-type routine that was written by our previous cad-support guru. I'm learning lisp and want to make some changes and clean things up a bit. The entire lisp is too long to post, I figured it would be easier to post a small clip and go from there. What this is part of is a setup routine for our shop drawings, It sets layers, colors, linetypes, dims and scale (for text/dims size) in both imperial and metric. I'm getting the hang of it, but there is still alot of going right over my head..lol. I do thank everyone that is helping me with this.