我确信这可以做得更好,但这是我使用的:
- (defun c:OnlyCScale (/ l3 l4 l5 l6 l7 SS CS n waarden ent lijst)
- (setq SS (ssget "I"))
- (command ".undo" "begin")
- (while (not SS)(setq SS (ssget)))
- (command ".chprop" ss "" "Annotative" "y" "")
- (setq CS (getvar "CANNOSCALE"))
- (command "-OBJECTSCALE" SS "" "Add" CS "")
- (setq n 0 lijst '())
- (repeat (sslength SS)
- (setq ent (ssname SS n))
- (setq waarden (get_ent_scales (entget ent)))
- (if waarden (setq lijst (append waarden lijst)))
- (setq n (1+ n))
- )
-
- (setq lijst (remove_doubles lijst))
-
- (foreach n lijst
- (if (/= n CS)(progn
- (if (= (strlen n) 3)(setq l3 (vl-sort (cons n l3)'<)))
- (if (= (strlen n) 4)(setq l4 (vl-sort (cons n l4)'<)))
- (if (= (strlen n) 5)(setq l5 (vl-sort (cons n l5)'<)))
- (if (= (strlen n) 6)(setq l6 (vl-sort (cons n l6)'<)))
- (if (= (strlen n) 7)(setq l7 (vl-sort (cons n l7)'<)))
- (command "-OBJECTSCALE" SS "" "Del" n "")
- ))
- )
- (setq lijst (append l3 l4 l5 l6 l7))
- (princ (strcat "\n\nThis scale was added " CS))
- (if lijst (progn
- (princ "\nand these have been removed:")
- (foreach n lijst (princ (strcat " " n)))
- ))
- (command ".undo" "end")
- (princ)
- )
- (defun remove_doubles (lst); by Gile
- (if lst (cons (car lst) (remove_doubles (vl-remove (car lst) lst))))
- )
- (defun get_ent_scales (ent / annotative lijst n schalen collect)
- ; zie ook: http://www.theswamp.org/index.php?topic=24171.0
- (defun collect (key lijst / n return)
- (foreach n lijst
- (if (= key (car n))
- (setq return (cons (cdr n) return))
- )
- )
- return
- )
- (setq annotative (cdr (assoc 360 ent)))
- (if annotative (progn
- (setq lijst
- (entget (cdr (assoc 350
- (entget (cdr (assoc 360
- (member '(3 . "AcDbContextDataManager"); Get the right 360-code
- (entget annotative)
- )
- )))
- )))
- )
- (foreach n (collect 350 lijst)
- (setq schalen (cons
- (cdr (assoc 300 (entget (cdr (assoc 340 (entget n))))))
- schalen
- )
- )
- )
- schalen
- ))
- )
|