-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannoScalesDelete.lsp
67 lines (63 loc) · 2.51 KB
/
annoScalesDelete.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(defun c:DelAnnoScales (/ ss n scLst OSC:GetScales)
(print "Select the objects you wish to modify: ")
(if (or (setq ss (ssget "I")) (setq ss (ssget)))
(progn
;; Define helper function to get scales attached to an entity
(defun OSC:GetScales (en / ed xn xd cdn cdd asn asd cn cd sn sd cannoscale)
(setq ed (entget en))
(if (and
;; Get the XDictionary attached to the object
(setq xn (vl-position '(102 . "{ACAD_XDICTIONARY") ed))
(setq xn (cdr (nth (1+ xn) ed)))
(setq xd (entget xn))
;; Get the Context Data Management dictionary attached to the XDictionary
(setq cdn (vl-position '(3 . "AcDbContextDataManager") xd))
(setq cdn (cdr (nth (1+ cdn) xd)))
(setq cdd (entget cdn))
;; Get the Annotation Scales dictionary attached to the CD
(setq asn (vl-position '(3 . "ACDB_ANNOTATIONSCALES") cdd))
(setq asn (cdr (nth (1+ asn) cdd)))
(setq asd (entget asn))
;; Get the 1st scale attached
(setq cn (assoc 3 asd))
(setq cn (member cn asd))
)
;; Step through all scales attached
(while cn
(if (and (= (caar cn) 350) ;It it's pointing to a scale record
;; Get the record's data
(setq cd (entget (cdar cn)))
;; Get the Context data class
(setq sn (assoc 340 cd))
(setq sd (entget (cdr sn)))
(setq sn (assoc 300 sd))
;; Check if the scale is already in the list
(not (vl-position (cdr sn) scLst))
)
;; Add it to the list
(setq scLst (cons (cdr sn) scLst))
)
(setq cn (cdr cn))
)
)
)
;; Find a list of scales used in selection
(setq n (sslength ss))
(while (>= (setq n (1- n)) 0)
(OSC:GetScales (ssname ss n))
)
;; Add the current scale to the selection
(setq cannoscale (getvar "CANNOSCALE"))
(command "._ObjectScale" ss "" "_Add" cannoscale "")
;; Remove all other scales attached
(command "._ObjectScale" ss "" "_Delete")
(foreach n scLst
(if (wcmatch (strcase n) (strcat "~" (strcase cannoscale)))
(command n)
)
)
(command "")
)
)
(princ)
)