NoelStalker Posted December 18, 2008 Posted December 18, 2008 Hello everyone, I am trying to make a lisp file that will make commands "0" through "9" to change the dimdec variable to the respective number and then ask me to select a dimension (as when I type "dim" and then "up") and update the precision accordingly. I started with this that someone helped me on for an array for dimscale but I was not sure how to edit it since I want the numbers to be the commands themselves... (defun c:setdimdec(/ i) (setq i 1) (repeat 9 (eval(read(strcat "(defun c:d" (itoa i) "()(setvar \"DIMSCALE\" " (itoa i) ")(princ))"))) (setq i(1+ i)) ); end repeat (princ) ); end of test(c:test)[\code] Quote
Lee Mac Posted December 18, 2008 Posted December 18, 2008 Try this: (defun c:dd (/ *error* dim ss ssl) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ "\nFunction Complete.") (princ "\nError or Esc Pressed...") ) ;_ end if (princ) ) ;_ end defun (setvar "cmdecho" 0) (if (>= (setq dim (getint "\nSpecify Number of Decimal Places: ")) 0) (progn (setvar "DIMDEC" dim) (setq ss (ssget)) (if (/= (setq ssl (sslength ss)) 0) (command "-dimstyle" "a" ss "") (alert "No Dimensions Selected.") ) ;_ end if ) ;_ end progn (alert "Number of Decimal Places must be Positive.") ) ;_ end if (*error* "") (princ (strcat "\n" (itoa ssl) " Dimensions Updated.")) (princ) ) ;_ end defun Quote
NoelStalker Posted December 18, 2008 Author Posted December 18, 2008 Thanks LeeMac! That works very well. Is there any way to assign the command "0" to be "dd" and then "0", "1" to be "1" and etc? This will just make it so that I have to type one less input. Quote
Lee Mac Posted December 18, 2008 Posted December 18, 2008 An example for "0": (defun c:[color=Red][b]0[/b][/color] (/ *error* ss ssl) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ "\nFunction Complete.") (princ "\nError or Esc Pressed...") ) ;_ end if (princ) ) ;_ end defun (setvar "cmdecho" 0) (setvar "DIMDEC" [b][color=Red]0[/color][/b]) (setq ss (ssget)) (if (/= (setq ssl (sslength ss)) 0) (command "-dimstyle" "a" ss "") (alert "No Dimensions Selected.") ) ;_ end if (*error* "") (princ (strcat "\n" (itoa ssl) " Dimensions Updated.")) (princ) ) ;_ end defun Change the highlighted zeros to different numbers to suit your needs. Quote
Lee Mac Posted December 19, 2008 Posted December 19, 2008 Or, maybe this to update all dimensions in drawing all at once. (defun c:0 (/ *error* ss ssl) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ "\nFunction Complete.") (princ "\nError or Esc Pressed...") ) ;_ end if (princ) ) ;_ end defun (setvar "cmdecho" 0) (setvar "DIMDEC" 0) (setq ss (ssget "X" (list (cons 0 "DIMENSION")))) (if (/= (setq ssl (sslength ss)) 0) (command "-dimstyle" "a" ss "") (alert "No Dimensions Exist.") ) ;_ end if (*error* "") (princ (strcat "\n" (itoa ssl) " Dimensions Updated.")) (princ) ) ;_ end defun Quote
NoelStalker Posted December 29, 2008 Author Posted December 29, 2008 thanks LeeMac. You rule. Have a nice day. Quote
Lee Mac Posted January 1, 2009 Posted January 1, 2009 thanks LeeMac. You rule. Have a nice day. Cheers Noel, (Happy New Year to you also) 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.