Hey guys,
I'm having an issue with a LISP routine that is made for updating titleblocks.
Code:
(defun C:attedit2 ()
(setvar "cmdecho" 0)
(setq I 0)
(setq blkname (getstring "\nEnter the name of block to update: "))
(setq newatt (strcase(getstring "\nEnter new atrribute value: ")))
(setq att1 (strcase(getstring "\nEnter the name of the attribute to change: ")))
(setq sset (ssget "x" (list (cons 2 blkname))))
(if (= sset nil)(setq l 0)
(setq l (sslength sset)))
(repeat l
(setq stop 1)
(setq name (ssname sset I))
(while (= stop 1)
(setq name1 (entget (entnext name)))
(setq ATT (cdr (assoc 2 name1)))
(if (= att att1)(setq go 1))
(setq name (cdr (assoc -1 name1)))
(while (= go 1)
(setq d (assoc 1 name1))
(setq d2 (cons 1 newatt))
(setq d1 (subst d2 d name1))
(entmod d1)
(setq go nil)
(setq stop nil)
)
)
(setq i (1+ i))
)
(princ)
(princ)
)
;---------------------------------------------------------------------------
(defun c:RevUp ()
(AttReturn)
;---------------------------------------------------------------------------------------------------------
;Block name, Date variables and Revision date
(setq BlockName "BW-TITLE") ;;; Block name goes here
(setq AttBlock (ssget "x" '((0 . "insert")(2 . "BW-TITLE"))))
(setq DateBlockInfo(attreturn (entget (ssname AttBlock 0)) (list "DATE01" "DATE02" "DATE03" "DATE04" "DATE05" "DATE06") 1 nil nil)) ;;; If need more dates add tag here/If tags are different change here
(setq Date01(nth 0 DateBlockInfo))
(setq Date02(nth 1 DateBlockInfo))
(setq Date03(nth 2 DateBlockInfo))
(setq Date04(nth 3 DateBlockInfo))
(setq Date05(nth 4 DateBlockInfo))
(setq Date06(nth 5 DateBlockInfo)) ;;; Then add extra variable here
(setq Date (rtos (getvar "CDATE") 2 6))
(setq Yr (substr date 3 2))
(setq Mo (substr date 5 2))
(setq Day (substr date 7 2))
(setq Today (strcat Day "." Mo "." Yr))
;(setq Today "01.02.10") ;;; To set date rev date manually blank out above 5 lines using ;
;---------------------------------------------------------------------------------------------------------
;If statements to set revision and revision line
(if
(wcmatch Date01 "##?##?##")
(if
(wcmatch Date02 "##?##?##")
(if
(wcmatch Date03 "##?##?##")
(if
(wcmatch Date04 "##?##?##")
(if
(wcmatch Date05 "##?##?##")
(if
(wcmatch Date06 "##?##?##")
(ERROR) ;;; If new line needed copy from "(if" to ")" below it and replace "(ERROR)"
(progn (setq LineNo "06")
(setq Rev "F")
)
)
(progn (setq LineNo "05")
(setq Rev "E")
)
)
(progn (setq LineNo "04")
(setq Rev "D")
)
)
(progn (setq LineNo "03")
(setq Rev "C")
)
)
(progn (setq LineNo "02")
(setq Rev "B")
)
)
(progn (setq LineNo "01")
(setq Rev "A")
)
) ;;; For IFC change all Rev's to 0
;---------------------------------------------------------------------------------------------------------
;Setting tags for line that needs updating
(setq RevLine (strcat "REV" LineNo))
(setq DateLine (strcat "DATE" LineNo))
(setq CheckPMLine (strcat "CHECKPM" LineNo))
(setq CheckPDLine (strcat "CHECKPD" LineNo))
(setq DescLine (strcat "DESCRIPTION" LineNo))
;---------------------------------------------------------------------------------------------------------
;Entering results into attribute block
;(COMMAND "GATTE" "B" BlockName RevLine Rev "Y")
;(COMMAND "GATTE" "B" BlockName DateLine Today "Y")
;(COMMAND "GATTE" "B" BlockName DescLine "ISSUED FOR TENDER" "Y")
(COMMAND "AttEdit2" BlockName Rev RevLine)
(COMMAND "AttEdit2" BlockName Today DateLine)
(COMMAND "AttEdit2" BlockName "ISSUED FOR TENDER" DescLine)
(princ)
)
If this will be irneb replying the attreturn function is the same one used in the thread "Automatic PDFing"
The problem is that when I run it it says AttEdit2 is an unknown command, however if I run it straight from the command line i.e. type attedit2 into autocad the command runs fine. I've tried it with GATTE aswell and i get the same issue. This is the output of the LISP:
Code:
Command: ATTEDIT2 Unknown command "ATTEDIT2". Press F1 for help.
Command: BW-TITLE Unknown command "BW-TITLE". Press F1 for help.
Command: D Unknown command "D". Press F1 for help.
Command: REV04 Unknown command "REV04". Press F1 for help.
Command: AttEdit2 Unknown command "ATTEDIT2". Press F1 for help.
Command: BW-TITLE Unknown command "BW-TITLE". Press F1 for help.
Command: 01.02.10 Unknown command "01.02.10". Press F1 for help.
Command: DATE04 Unknown command "DATE04". Press F1 for help.
Command: AttEdit2 Unknown command "ATTEDIT2". Press F1 for help.
Command: BW-TITLE Unknown command "BW-TITLE". Press F1 for help.
Command: ISSUED FOR TENDER Unknown command "ISSUED FOR TENDER". Press F1 for
help.
Command: DESCRIPTION04 Unknown command "DESCRIPTION04". Press F1 for help.
From AutoCAD command line:
Command: attedit2
Enter the name of block to update: bw-title
Enter new atrribute value: 01.02.10
Enter the name of the attribute to change: date04
I'm really stuck with this one so I hope you can help!
Cheers,
James.
Edit:I have since found out that you cannot call a LISP from a LISP and that you can remove the c: from c:AttEdit2 then call it using (AttEdit2). The only problem is that it leaves RevUP and goes into AttEdit2 and doesn't run the rest of RevUp.