Hi all
i'm relatively new to lisp routines. I've been trying to create a routine that will create a custom block with attribute with an option to select which drawing border size is being used. This is what i've got so far;
(defun c:NEW_REV_NOTE ()
(PRINC "\nDrawing Size:")
(SETQ Paper_Size (GETSTRING "\n[A1/A3] <A1>: "))
(IF (= Paper_Size "A1")
(SETQ REV_LE "@85,0")
(SETQ REV_HE "@0,7.5")
(command "line" "2000,2000" (strcat (princ REV_LE)) "")
(command "line" "2000,2000" (strcat (princ REV_HE)) (strcat (princ REV_LE))"")
(command "line" "2049,2000" "@0,7.5" "")
(command "line" "2049,2000" "2063,2007.5" "")
(command "line" "2063,2000" "@0,7.5" "")
(command "line" "2076,2000" "@0,7.5" "")
(command "_-attdef" "" (strcat (princ REV_NO) "_DESC") "Revision Description" "" "j" "tl" "2000.5,2007" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_BY") "Revision By" "" "j" "tl" "2049.5,2007" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_CHK") "Revision Checked By" "" "j" "br" "2062.5,2000.5" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_DATE") "Revision Date" "" "j" "mc" "2069.5,2003.75" "2.5" "0")
(command "_-text" "j" "mc" "2080.5,2003.75" "5" "0" (princ REV_NO))
(command "_-block" (strcat "REV_" (princ REV_NO)) "2000,2000" "w" "1990,1990" "2090,2020" "")
)
(IF (= Paper_Size "A3")
(SETQ REV_LE "@47.81,0")
(SETQ REV_HE "@0,7.5")
(command "line" "2000,2000" (strcat (princ REV_LE)) "")
(command "line" "2000,2000" (strcat (princ REV_HE)) (strcat (princ REV_LE))"")
(command "line" "2027.56,2000" "@0,7.5" "")
(command "line" "2027.56,2000" "2035.44,2007.5" "")
(command "line" "2035.44,2000" "@0,7.5" "")
(command "line" "2042.75,2000" "@0,7.5" "")
(command "_-attdef" "" (strcat (princ REV_NO) "_DESC") "Revision Description" "" "j" "tl" "2000.5,2007" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_BY") "Revision By" "" "j" "tl" "2028.06,2007" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_CHK") "Revision Checked By" "" "j" "br" "2034.94,2000.5" "2.5" "0")
(command "_-attdef" "" (strcat (princ REV_NO) "_DATE") "Revision Date" "" "j" "mc" "2039.095,2003.75" "2.5" "0")
(command "_-text" "j" "mc" "2045.28,2003.75" "3.5" "0" (princ REV_NO))
(command "_-block" (strcat "REV_" (princ REV_NO)) "2000,2000" "w" "1990,1990" "2090,2020" "")
)
(COMMAND "_-INSERT" (strcat "REV_" (princ REV_NO)) "S" "1" "R" "0" PAUSE)
);
Can someone please have a look where I'm going wrong at the moment I get an error message when I try to load the file "; error: syntax error"
Thankyou in advance for your help.
Regards
Chris
There is a feature in VLIDE that allows you to check the syntax before loadeing. The button looks like a white sheet of paper with a checkmark. Pushing that button with your file loaded yields this message:
[CHECKING TEXT <Untitled-0> loading...]
.
; error: too many arguments: (IF (= PAPER_SIZE "A1") (SETQ REV_LE "@85,0") (SETQ REV_HE "@0,7.5") ... )
; Check done.
Looking at the file itself after that message, it is clear that you must wrap all of the arguments to each IF statement (except the test) in a (PROGN ....) expression.
I checked no further.
@Anonymous wrote:....
i'm relatively new to lisp routines. I've been trying to create a routine that will create a custom block with attribute with an option to select which drawing border size is being used. This is what i've got so far;
(defun c:NEW_REV_NOTE ()
(PRINC "\nDrawing Size:")
(SETQ Paper_Size (GETSTRING "\n[A1/A3] <A1>: "))
(IF (= Paper_Size "A1")
(SETQ REV_LE "@85,0")
....(COMMAND "_-INSERT" (strcat "REV_" (princ REV_NO)) "S" "1" "R" "0" PAUSE)
);
The (if) function allows only two or three arguments: a test or check of some kind; a 'then' argument [if what it checks doesn't return nil]; and an optional 'else' argument [if it returns nil]. If any of those needs to contain more than one function within it, it must be "wrapped" in a (progn) function so that from (if)'s point of view it's only one argument:
(IF (= Paper_Size "A1")
(progn
(SETQ REV_LE "@85,0")
....
(command "_-block" (strcat "REV_" (princ REV_NO)) "2000,2000" "w" "1990,1990" "2090,2020" "")
); end progn
)
Without studying it deeply, I can't help but wonder why you don't just have those Blocks as external drawing files, with, I would assume, the REV_NO part being another Attribute, and possibly some other elements. Than you could just do something like this [incorporating some other formatting suggestions, too], and not need to construct the Block from scratch every time:
(defun c:NEW_REV_NOTE ()
(initget "A1 A3"); limit User's options for input
(setq Paper_Size (getkword "\nDrawing Size [A1/A3] <A1>: "))
(command "_.insert"
(if (= Paper_Size "A3")
"YourA3DwgName" ; then [User typed "A3"]
"YourA1DwgName" ; else [whether User typed "A1" or Enter for default]
); end if
"" "" "" ; [you don't need to specify Scale of 1 or Rotation of 0 -- they're always the defaults]
pause[s] ; or specific values, for any Attributes
....
); end command
); end defun
You also have some things more complicated than they need to be, though they may work. This:
(command "line" "2000,2000" (strcat (princ REV_LE)) "")
can be simply this, since REV_LE is already a text string:
(command "line" "2000,2000" REV_LE "")
Also, if REV_NO is an integer, this:
(strcat (princ REV_NO) "_DESC")
would more typically be done this way:
(strcat (itoa REV_NO) "_DESC")
and similarly for the other Attribute definitions.
Can't find what you're looking for? Ask the community or share your knowledge.