forked from xplan001/AutoCad-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path块属性编辑程序 _chattdef.lsp
283 lines (283 loc) · 27 KB
/
块属性编辑程序 _chattdef.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
;;;块属性编辑程序
;;;编写:HQD9639
;;;2003/6/9
(DEFUN DTR (DEG / )
(* PI (/ DEG 180.0)))
;---------------------------------
(DEFUN RTD (RAD / )
(/ (* 180.0 RAD) PI))
;-------------------------------
(defun c:chattdef ()
(vl-load-com)
(setq k T)
(while k
(setq entbatt (entsel "\n选取带属性图块: <退出>: "))
(if entbatt
(progn
(setq entbatt (car entbatt))
(setq wattvla (vlax-ename->vla-object entbatt))
(setq name1 (vla-get-objectname wattvla))
(if (= name1 "AcDbBlockReference")
(progn
(if (= (vla-get-HasAttributes wattvla) :vlax-true)
(progn
(setq attlst (vlax-safearray->list (vlax-variant-value (vla-getattributes wattvla))))
(initget "Value Height Width Rotation Font Layer Color Exit")
(setq x0 (getkword "\n[Value//Height/Width/Rotation/Font/Layer/Color/Exit] <Exit>: "))
(cond ((eq x0 "Value")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq newstr (getstring (strcat "\n请输入新属性值<" enttxt ">:")))
(if (eq "" newstr) (setq newstr enttxt))
(vla-put-TextString ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(setq newstr (getstring "\n请输入新属性值:"))
(foreach n attlst (vla-put-TextString n newstr ))
)
);cond
)
(progn
(setq newstr (getstring "\n请输入新属性值:"))
(foreach n attlst (vla-put-TextString n newstr ))
)
);if
)
((eq x0 "Height")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq enthei (vla-get-Height ent))
(initget 4)
(setq newstr (getreal (strcat "\n请输入属性{ " enttxt " }新高度<" (rtos enthei) ">:")))
(if (not newstr) (setq newstr enthei))
(vla-put-Height ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(initget 5)
(setq newstr (getreal (strcat "\n请输入属性新高度: ")))
(foreach n attlst (vla-put-Height n newstr ))
)
);cond
)
(progn
(initget 5)
(setq newstr (getreal (strcat "\n请输入属性新高度: ")))
(foreach n attlst (vla-put-Height n newstr ))
)
);if
)
((eq x0 "Width")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq entwei (vla-get-ScaleFactor ent))
(initget 4)
(setq newstr (getreal (strcat "\n请输入属性{ " enttxt " }新宽度<" (rtos entwei) ">:")))
(if (not newstr) (setq newstr entwei))
(vla-put-ScaleFactor ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(initget 7)
(setq newstr (getreal "\n请输入属性新宽度: "))
(foreach n attlst (vla-put-ScaleFactor n newstr ))
)
);cond
)
(progn
(initget 7)
(setq newstr (getreal "\n请输入属性新宽度: "))
(foreach n attlst (vla-put-ScaleFactor n newstr ))
)
);if
)
((eq x0 "Rotation")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq entrot (vla-get-Rotation ent))
(setq entrot0 (rtd (vla-get-Rotation ent)))
(setq newstr (getangle (strcat "\n请输入属性{ " enttxt " }新旋转角度<" (rtos entrot0) ">:")))
(if (not newstr) (setq newstr entrot))
(vla-put-Rotation ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(initget 1)
(setq newstr (getangle "\n请输入属性新转角度: "))
(foreach n attlst (vla-put-Rotation n newstr ))
)
);cond
)
(progn
(initget 1)
(setq newstr (getangle "\n请输入属性新转角度: "))
(foreach n attlst (vla-put-Rotation n newstr ))
)
);if
)
((eq x0 "Font")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq entsty (vla-get-StyleName ent))
(setq newstr (getstring (strcat "\n请输入属性{ " enttxt " }新字型<" entsty ">:")))
(if (eq "" newstr) (setq newstr entsty))
(vla-put-StyleName ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(initget 1)
(setq newstr (getstring "\n请输入属性新字型<Standard>:"))
(if (eq "" newstr) (setq newstr "Standard"))
(foreach n attlst (vla-put-StyleName n newstr ))
)
);cond
)
(progn
(setq newstr (getstring "\n请输入属性新字型<Standard>:"))
(if (eq "" newstr) (setq newstr "Standard"))
(foreach n attlst (vla-put-StyleName n newstr ))
)
);if
)
;;---------------------------------------------------------------------------------------------------------------------------------
((eq x0 "Layer")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq entlay (vla-get-Layer ent))
(setq newstr (getstring (strcat "\n请输入属性{ " enttxt " }所在新层<" entlay ">:")))
(if (eq "" newstr) (setq newstr entlay))
(vla-put-Layer ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(setq newstr (getstring "\n请输入属性所在新层<0>:"))
(if (eq "" newstr) (setq newstr "0"))
(foreach n attlst (vla-put-Layer n newstr ))
)
);cond
)
(progn
(setq newstr (getstring "\n请输入属性所在新层<0>:"))
(if (eq "" newstr) (setq newstr "0"))
(foreach n attlst (vla-put-Layer n newstr ))
)
);if
)
;;---------------------------------------------------------------------------------------------------------------------------------
((eq x0 "Color")
(if (> (length attlst) 1)
(progn
(initget "Single All")
(setq y0 (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
(if (not y0) (setq y0 "All"))
(cond ((= y0 "Single")
(setq mm 0)
(repeat (length attlst)
(setq ent (nth mm attlst))
(setq enttxt (vla-get-TextString ent))
(setq entcor (vla-get-Color ent))
(setq k1 T)
(while k1
(initget 4)
(setq newstr (getint (strcat "\n请输入属性{ " enttxt " }新颜色<" (itoa entcor) ">:")))
(if ( or (and (>= newstr 0) (<= newstr 256)) (eq nil newstr))
(setq k1 nil)
)
)
(if (not newstr) (setq newstr entcor))
(vla-put-Color ent newstr )
(setq mm (1+ mm))
)
)
((= y0 "All")
(setq k1 T)
(while k1
(initget 5)
(setq newstr (getint "\n请输入属性新颜色: "))
(if (and (>= newstr 0) (<= newstr 256))
(setq k1 nil)
)
)
(foreach n attlst (vla-put-Color n newstr ))
)
);cond
)
(progn
(setq k1 T)
(while k1
(initget 5)
(setq newstr (getint "\n请输入属性新颜色: "))
(if (and (>= newstr 0) (<= newstr 256))
(setq k1 nil)
)
)
(foreach n attlst (vla-put-Color n newstr ))
)
);if
)
(T (setq k nil))
);cond
);progn
) ;if
);progn
);if
);progn
(setq k nil)
);if
);while
(princ)
);end