Dien nguyen Posted July 5, 2023 Share Posted July 5, 2023 I created a Lisp routine to generate a scale list, but when I tried to create a search to check if that scale list already exists in the drawing, I encountered an error. Where did I go wrong? Quote error: CS tỉ lệ đó:100 ; error: AutoCAD rejected function: invalid table function argument(s): "SCALES" "LA 1:100" (defun c:cs (/ usercmd userosm *error* mode dist tile tile-2 dm_redef txt) (progn (initget 1) (setq tile (getreal "\u+0074\u+1ec9 \u+006c\u+1ec7 \u+0111\u+00f3\u+003a") ) ) (setq tile-2 (if (< tile 1) (strcat "LA 1:"(rtos (* tile 1000))"m") (strcat "LA 1:" (rtos tile)))) (setq ten-tile (strcat "1:" (rtos tile))) (if (tblsearch "SCALES" tile-2) (prompt "\ntile-2 Exsiting Scale List.") (command "-SCALELISTEDIT" "ADD" tile-2 ten-tile "E") ) (princ)) Quote Link to comment Share on other sites More sharing options...
mhupp Posted July 5, 2023 Share Posted July 5, 2023 1 Quote Link to comment Share on other sites More sharing options...
Crank Posted July 18, 2023 Share Posted July 18, 2023 (edited) Scales are not tables, but they are stored in a dictionary: (defun GetScaleList (/ ScaleList ScaleListDict ScaleListEnts N MASSOC) (defun MASSOC (KEY ALIST / X NLIST) (foreach X ALIST (if (eq KEY (car X)) (setq NLIST (cons (cdr X) NLIST)) ) ) (reverse NLIST) ) (setq ScaleListDict (dictsearch (namedobjdict) "ACAD_SCALELIST") ScaleListEnts (MASSOC 350 ScaleListDict) ScaleList (list "") N 0 ) (repeat (length ScaleListEnts) (setq ScaleList (cons (cdr (assoc 300 (entget (nth N ScaleListEnts)))) ScaleList) N (1+ N) ) ) (setq ScaleList (cdr (reverse ScaleList))) ) But you don't have to check if the scale already exists. You can recreate the scale if needed. Here is what I use: (defun c:1:1 ()(MaakSchaal 1)) (defun c:1:2 ()(MaakSchaal 2)) (defun c:1:5 ()(MaakSchaal 5)) (defun c:1:10 ()(MaakSchaal 10)) (defun c:1:20 ()(MaakSchaal 20)) (defun c:1:50 ()(MaakSchaal 50)) (defun c:1:100 ()(MaakSchaal 100)) (defun c:1:200 ()(MaakSchaal 200)) (defun c:1:500 ()(MaakSchaal 500)) (defun c:1:1000 ()(MaakSchaal 1000)) (defun c:1:2000 ()(MaakSchaal 2000)) (defun c:1:5000 ()(MaakSchaal 5000)) (defun c:1:10000 ()(MaakSchaal 10000)) (defun MaakSchaal (waarde / e schaal) (command ".undo" "be") (setq schaal (strcat "1:" (itoa waarde))) (setq e (getvar "EXPERT"))(setvar "EXPERT" 5) (command ".-scalelistedit" "A" schaal schaal "Exit") (setvar "EXPERT" e) (if (inPspace) (princ (strcat "\n" schaal " is added to the scalelist.")) ; else (setvar "CANNOSCALE" schaal) ) (command ".undo" "end") (princ) ) (defun inPSPACE ()(and (zerop (getvar "TILEMODE"))(zerop (getvar "VPMAXIMIZEDSTATE"))(eq (getvar "CVPORT") 1))) Edited July 18, 2023 by Crank Code tags 1 Quote Link to comment Share on other sites More sharing options...
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.