3dwannab Posted August 25, 2022 Posted August 25, 2022 (edited) Hi all, See attached the drawing where there are two 1:1 scales. But one is named as 1:1 and the other is 1:1000. I don't know how this came about but it was a drawing I came across in the office this week. The named 1:1000 scale is greyed out in the Edit Scale GUI. Perhaps someone could shed some light on how to fix this. I'm www.lost.com. Thanks in advance. Here's the code I have ATM which works 60% of the time, every time. (vl-load-com) ; by Ian_Bryant, 2013-04-25 12:20 PM ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-to-sort-cannoscale-list/m-p/3887927#M310705 ; Reported bug for not sorting the scale in this reply also. ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-to-sort-cannoscale-list/m-p/11381844#M435522 (defun c:Reset_Cannoscale_List_Metric (/ var_cmdecho xpt as3 ndict dict sce sx sl dl xl) (setq var_cmdecho (getvar "cmdecho")) (setvar "cmdecho" 0) (setq xpt (getvar "expert")) (setvar "expert" 5) (command "-scalelistedit" "reset" "yes" "exit") (command "-scalelistedit" "delete" "*") ; List of standard ISO scales (from ISO 13567) below. ; "1:1" "1:2" "1:5" "1:10" "1:20" "1:25" "1:50" "1:75" "1:100" "1:200" "1:250" "1:500" "1:750" "1:1000" "1:2000" "1:2500" "1:5000" "1:10000" (foreach n '("1:1" "1:2" "1:5" "1:10" "1:20" "1:25" "1:50" "1:75" "1:100" "1:200" "1:250" "1:500" "1:750" "1:1000" "1:2000" "1:2500" "1:5000" "1:10000") (command "add") (command n) (command n) ) (command "exit") (setvar "expert" xpt) (setvar "cmdecho" var_cmdecho) (setq dict (dictsearch (namedobjdict) "acad_scalelist")) (setq as3 (assoc 3 dict) ndict (cdr (member as3 (reverse dict))) dict (member as3 dict) ) (while (setq as3 (assoc 3 dict)) (setq dict (member as3 dict) dl (cons (cdr as3) dl) sce (cdr (assoc 350 dict)) ) (if (> (setq sx (/ (cdr (assoc 140 (entget sce))) (cdr (assoc 141 (entget sce))))) 1.0) (setq xl (cons (cons sx sce) xl)) (setq sl (cons (cons sx sce) sl)) ) (setq dict (cdr dict)) ) (setq sl (vl-sort sl '(lambda (x y) (> (car x) (car y))))) (if xl (setq sl (append sl (vl-sort xl '(lambda (x y) (< (car x) (car y))))))) (setq dl (acad_strlsort dl)) (setq n 0) (repeat (length dl) (setq ndict (cons (cons 3 (nth n dl)) ndict) ndict (cons (cons 350 (cdr (nth n sl))) ndict) n (1+ n) ) ) (entmod (reverse ndict)) (princ) ) (c:Reset_Cannoscale_List_Metric) ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;; Cannoscale List Not Sorted (1).dwg Edited August 25, 2022 by 3dwannab Quote
elyosua Posted January 5, 2023 Posted January 5, 2023 Set 1:1000 scale as current. Eliminate the 1:1 scale. Rename the scale 1:1000 as 1:1. And run the command "Reset_Cannoscale_List_Metric". Quote
3dwannab Posted January 5, 2023 Author Posted January 5, 2023 11 minutes ago, elyosua said: Set 1:1000 scale as current. Eliminate the 1:1 scale. Rename the scale 1:1000 as 1:1. And run the command "Reset_Cannoscale_List_Metric". Thanks, not sure how I can do this programmatically though as I want to run this command in a batch file. Quote
elyosua Posted January 10, 2023 Posted January 10, 2023 Try this. (DEFUN checkScale (scaleName / item) (CAR (VL-REMOVE-IF-NOT (FUNCTION (LAMBDA (item) (EQ scaleName (CDR (ASSOC 300 item))))) (MAPCAR (FUNCTION (LAMBDA (item) (ENTGET (CDR item)))) (VL-REMOVE-IF-NOT (FUNCTION (LAMBDA (item) (= (CAR item) 350))) (DICTSEARCH (NAMEDOBJDICT) "ACAD_SCALELIST") ) ) ) ) ) (DEFUN rea (/ rae es ce xpt n dict ndict dict dl sce sl xl ndict) (SETQ es "1:1000") (SETQ ce (checkScale es)) ;; si existe (IF ce (PROGN ;; seleccionarla (COMMAND "_.cannoscale" es) (SETQ es "1:1") (SETQ ce (checkScale es)) ;; si existe (IF ce (PROGN ;; eliminarla (COMMAND "_.-scalelistedit" "_delete" es "_exit") ;; renombrarla (SETQ rae (rename_annotative_scale "1:1000" es)) (IF rae (PROMPT "\nRenamed annotative scale.") (PROMPT "\nThe annotative scale could not be renamed.") ) ) (PROMPT (STRCAT "\nThe scale " es " does not exist.")) ) ) (PROMPT (STRCAT "\nThe scale " es " does not exist.")) ) (SETQ xpt (GETVAR "EXPERT")) (SETVAR "EXPERT" 5) (COMMAND "_.-scalelistedit" "_Reset" "_Yes" "_Exit") (COMMAND "_.-scalelistedit" "_Delete" "*") (FOREACH n '("1:1" "1:2" "1:5" "1:10" "1:20" "1:50" "1:100" "1:250" "1:500" "1:1000" "1:2500") (COMMAND "_Add") (COMMAND n) (COMMAND n) ) (COMMAND "_Exit") (SETVAR "EXPERT" xpt) ;;; (SETVAR "CMDECHO" cmde) (SETQ dict (DICTSEARCH (NAMEDOBJDICT) "ACAD_SCALELIST")) (SETQ as3 (ASSOC 3 dict) ndict (CDR (MEMBER as3 (REVERSE dict))) dict (MEMBER as3 dict) ) (WHILE (SETQ as3 (ASSOC 3 dict)) (SETQ dict (MEMBER as3 dict) dl (CONS (CDR as3) dl) sce (CDR (ASSOC 350 dict)) ) (IF (> (SETQ sx (/ (CDR (ASSOC 140 (ENTGET sce))) (CDR (ASSOC 141 (ENTGET sce))))) 1.0) (SETQ xl (CONS (CONS sx sce) xl)) (SETQ sl (CONS (CONS sx sce) sl)) ) (SETQ dict (CDR dict)) ) (SETQ sl (VL-SORT sl '(LAMBDA (x y) (> (CAR x) (CAR y))))) (IF xl (SETQ sl (APPEND sl (VL-SORT xl '(LAMBDA (x y) (< (CAR x) (CAR y)))))) ) (SETQ dl (ACAD_STRLSORT dl)) (SETQ n 0) (REPEAT (LENGTH dl) (SETQ ndict (CONS (CONS 3 (NTH n dl)) ndict) ndict (CONS (CONS 350 (CDR (NTH n sl))) ndict) n (1+ n) ) ) (ENTMOD (REVERSE ndict)) (COMMAND "_.CANNOSCALE" "1:2500") (SETQ x 0) (SETQ x (1+ x)) ;;; (PRINC) ) ; return elist of the renamed annotation scale or nil if it fails (DEFUN rename_annotative_scale (oldsym newsym / isexist table) (DEFUN isexist () (VL-SOME (FUNCTION (LAMBDA (item) (AND (= (CAR item) 350) (EQ (STRCASE (CDR (ASSOC '300 (ENTGET (CDR item))))) (STRCASE newsym)) ) ) ; lambda ) ; function table ) ; vl-some ) ; isexist (COND ((NOT (SETQ table (ENTGET (CDADR (MEMBER '(3 . "ACAD_SCALELIST") (ENTGET (NAMEDOBJDICT)))))))) ((isexist) (PROMPT (STRCAT "\nThe annotative scale " newsym " already exists.")) ) ; case ((VL-SOME (FUNCTION (LAMBDA (item / elist) (IF (AND (= (CAR item) 350) (SETQ elist (ENTGET (CDR item))) (EQ (STRCASE (CDR (ASSOC '300 elist))) (STRCASE oldsym)) ) (ENTMOD (SUBST (CONS '300 newsym) (ASSOC '300 elist) elist)) ; rename ) ; if ) ; lambda ) ; function table ) ; vl-some ) ; case ) ; cond ) ; rename_annoscale (DEFUN errores_rea (men) (SETQ *error* error0) (IF (= men "quitar / salir abandonar") (PRIN1) (PRINC (STRCAT "\nError: " men " ")) ) (SETVAR "cmdecho" 1) (PRIN1) ) (DEFUN c:RenameAnnotativeScale (/ error0) (SETVAR "cmdecho" 0) (SETQ error0 *error* *error* errores_rea ) (IF (> x 0) (PROGN (PROMPT "\nThis command can only be executed once in the current drawing.") (EXIT) ) (rea) ) (SETQ *error* error0) (PROMPT "\nEnd.") (SETVAR "cmdecho" 1) (PRIN1) ) (PROMPT "\nCommand RENAMEANNOTATIVESCALE loaded." ) (PRIN1) 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.