-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtalisman.lsp
192 lines (187 loc) · 6.78 KB
/
talisman.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
;-----------------------------------------------------
(setq _acad (vlax-get-acad-object))
(setq _doc (vla-get-activedocument _acad))
(defun obDt (object)(vlax-dump-object object t))
;-----------------------------------------------------
converts radians to degrees
(defun rtod (r) (* 180.0 (/ r pi)))
; converts degrees to radians
(defun dtor (d) (* pi (/ d 180.0)))
;-----------------------------------------------------
(defun _dxf(ent code)(cdr(assoc code (entget ent))))
;-----------------------------------------------------
(defun e->obj (e / eo)
(if (=
(type e)
(type (entlast))
)
(setq eo (vlax-ename->vla-object e))
(if (= (type e) (type (vlax-ename->vla-object (entlast ))))
(setq eo e )
)
)
eo
)
;-----------------------------------------------------
; selection set to list of objects
(defun-q sset->objects (sset / i objs)
(setq objs '())
(setq i 0 )
(if (and sset (> (sslength sset) 0))
(while (< i (sslength sset))
(setq objs
(cons (e->obj (ssname sset i)) objs) i (1+ i))
)
)
objs
)
;-----------------------------------------------------
(defun c:gg ()
(if (= (getvar "PICKSTYLE") 0)
(setvar "PICKSTYLE" 1 )
(if (= (getvar "PICKSTYLE") 1)
(setvar "PICKSTYLE" 0 )
)
)
)
;-----------------------------------------------------
(defun c:L* ()
(command "-layer" "t" "*" "u" "*" "on" "*" "")
)
;-----------------------------------------------------
(defun c:l0 ()
(command "-layer" "u" "0" "t" "0" "on" "0" "s" "0" "")
)
;-----------------------------------------------------
(defun c:xlh ()(xl+ "h"))
(defun c:xlv ()(xl+ "v"))
;-----------------------------------------------------
(defun xl+ (vh)
(command "xline" vh (getpoint))
)
;-----------------------------------------------------
(defun c:qa ( / pline astr pt )
(setq pline (e->obj (car(entsel "\nSelect Polyline"))))
(setq astr (rtos (* 0.0001 (vla-get-Area pline)) 2 1))
(setq pt (getpoint))
(command "-text" pt 25 0.0 astr)
)
;-----------------------------------------------------
(defun-q c:sheetname()
(command "-layout" "r" (car (layoutlist)) (vl-filename-base (getvar "dwgname")))
)
;-----------------------------------------------------
(defun-q c:mwb ( / blkFolder blks blocknames)
(setvar "texteval" 1)(setvar "filedia" 0 )
(setq blkFolder (strcat (getvar "DWGPREFIX") (vl-filename-base (getvar "dwgname")) "-blocks"))
(vl-mkdir blkfolder)
(setq blks (vla-get-blocks _doc) blocknames '())
(vlax-for i blks
(if (= :vlax-false (vla-get-isxref i))
(setq blocknames (cons (vla-get-name i) blocknames)))
)
(setq blocknames (vl-remove-if-not '(lambda (x) (snvalid x)) blocknames))
(foreach x blocknames (command "-wblock" (strcat blkfolder "/" x ".dwg") "="))
)
;-----------------------------------------------------
;(defun-q c:upblk ()
; (setq blkFolder (strcat (getvar "DWGPREFIX") (vl-filename-base (getvar "dwgname")) "-blocks"))
; (setq blks (vl-directory-files blkfolder "*.dwg" 1))
;)
;-----------------------------------------------------
(defun c:bqa ( / pline astr blk )
(setq pline (e->obj (car(entsel "\nSelect Polyline"))))
(setq astr (rtos (* 0.0001 (vla-get-Area pline)) 2 1))
)
;-----------------------------------------------------
(defun-q calcMid (ll ur)
(polar ll (angle ll ur)(/ (distance ll ur) 2.0) )
)
;-----------------------------------------------------
(defun C:TabSort (/ cnt doc lay)
(vl-load-com)
(setq cnt 1 doc (vla-get-activedocument (vlax-get-acad-object)) )
(foreach lay (acad_strlsort (vl-remove "Model" (layoutlist)))
(vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt)
(setq cnt (1+ cnt))
)
(princ)
)
;-----------------------------------------------------
(defun-q get-xref-defs(/ blk xrefs)
(vlax-for blk (vla-get-blocks _doc)
(if (= :vlax-true (vla-get-isXref blk))
(setq xrefs (cons (vla-get-name blk) xrefs))
)
)
xrefs
)
;-----------------------------------------------------
; Set attribute value
(defun-q att-set-value (blockent tag value / att-obj-list )
(setq att-obj-list (vlax-safearray->list (vlax-variant-value (vla-getattributes (e->obj blockent)))))
(foreach n att-obj-list
(if (= tag (vlax-get-property n "TagString"))
(vlax-put-property n "TextString" value)
)
)
)
;-----------------------------------------------------
; Get attribute value
; (defun-q att-get-value (blockent tag / att-obj-list value)
; (setq att-obj-list (vlax-safearray->list (vlax-variant-value (vla-getattributes (e->obj blockent)))))
; (foreach n att-obj-list
; (if (= tag (vlax-get-property n "TagString"))
; (setq value (vlax-get-property n "TextString" ))
; )
; )
; value
; )
;-----------------------------------------------------
(defun-q att-get-value (blockent tag / att-obj-list value)
(setq value (cadr (assoc tag (att-get-all blockent))))
value
)
;-----------------------------------------------------
(defun-q att-get-all (blockent / att-obj-list value)
(setq att-obj-list (vlax-safearray->list (vlax-variant-value (vla-getattributes (e->obj blockent)))))
(setq resultlist '())
(foreach n att-obj-list
(setq resultlist (cons (list (vlax-get-property n "TagString") (vlax-get-property n "TextString" )) resultlist))
)
(setq resultlist (reverse resultlist))
resultlist
)
;-----------------------------------------------------
(defun att-feed ( from_block to_block att_map / x )
(foreach x att_map
(att-set-value to_block (cadr x) (att-get-value from_block (car x)))
)
)
;-----------------------------------------------------
; Rooms polylines , areas and tags
(defun c:room-link ( / )
(setq pline (e->obj (car (entsel "\nSelect Polyline"))))
(setq RoomBlock(e->obj (car (entsel "\nSelect Block"))))
(att-set-value RoomBlock "PLINK" (vla-get-handle pline))
(att-set-value RoomBlock "ROOM-AREA" (rtos (* 0.0001 (vla-get-area pline)) 2 1))
)
;-----------------------------------------------------
(defun c:rl ()(c:room-link))
;-----------------------------------------------------
(defun RoomCalc (bent / pline)
(setq pline (e->obj (handent (att-get-value bent "PLINK"))))
(att-set-value bent "ROOM-AREA" (rtos (* 0.0001 (vla-get-area pline)) 2 1 ))
)
;-----------------------------------------------------
(defun c:RoomAuto ( / blks )
(setq i 0 blks (ssget "x" (list (cons 0 "insert")(cons 2 "B-ROOMN"))))
(while (< i (sslength blks))
(progn
(RoomCalc (e->obj (ssname blks i)))
(setq i (1+ i))
)
)
)
(defun c:rau ()(c:RoomAuto))
;-----------------------------------------------------