-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVolume.LSP
182 lines (166 loc) · 5.59 KB
/
Volume.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
;; volume
(defun c:Vol ( / ss ss_Length entn cn obj volume)
(vl-load-com)
(princ "\nMacro: Volume")
(setvar "cmdecho" 0)
(setvar "highlight" 1)
(setq volume 0.0)
(setq ss (ssget))
(command "._Select" ss "")
(setq ss (ssget "P" '((0 . "3DSOLID"))))
(if (= ss nil)
(princ "Nothing to do.")
(progn
(setq ss_Length (sslength ss) cn 0)
(repeat ss_Length
(setq entn (ssname ss cn))
(setq cn (1+ cn))
(setq obj (vlax-ename->vla-object entn))
(if obj
(setq volume (+ (vlax-get-property obj 'Volume) volume))
);_end of if
);_ end of repeat
);_ end of progn
);_ end of if
(princ (strcat "\n" "Solids Selected: "(rtos ss_Length 2 0) " \nTotal Volume: "(rtos volume 2 2)))
(princ)
) ;_ end of defun
(defun C:*Vol* ( / ss ss_Length entn cn obj volume)
(vl-load-com)
(setvar "cmdecho" 0)
(setvar "highlight" 1)
(setq volume 0.0)
(setq ss (ssget))
(command "._Select" ss "")
(setq ss (ssget "P" '((0 . "3DSOLID"))))
(if (= ss nil)
(princ "Nothing to do.")
(progn
(setq ss_Length (sslength ss) cn 0)
(repeat ss_Length
(setq entn (ssname ss cn))
(setq cn (1+ cn))
(setq obj (vlax-ename->vla-object entn))
(if obj
(setq volume (+ (vlax-get-property obj 'Volume) volume))
);_end of if
);_ end of repeat
);_ end of progn
);_ end of if
(princ (strcat "\n" "Solids Selected: "(rtos ss_Length 2 0) " " ))
volume
) ;_ end of defun
;; extrusion
(defun c:Ext ( / ss ss_Length entn cn region_Last region_List newArea maxArea maxEntity ss_subtract)
(vl-load-com)
(princ "\nMacro: Extrusion\n")
(princ)
(setq region_List '())
(setvar "cmdecho" 0)
(setvar "highlight" 1)
(setq ss (ssget))
(command "._Select" ss "")
(setq ss (ssget "P" '( (-4 . "<OR")
(0 . "*POLYLINE")
(0 . "REGION")
(0 . "CIRCLE")
(0 . "ELLIPSE")
(-4 . "OR>")
)))
(if (= ss nil)
(princ "Nothing to do.")
(progn
(setq ss_Length (sslength ss) cn 0)
;;(command "_region" ss "")
(repeat ss_Length
(setq entn (entget (ssname ss cn)))
(setq cn (1+ cn))
;;(setq obj (vlax-ename->vla-object entn))
(if entn
(progn
(if (equal (cdr (assoc 0 entn)) "REGION")
(setq region_Last (cdr (assoc -1 entn)))
(progn
(command "_region" (cdr (assoc -1 entn)) "")
(setq region_Last (entlast))
);- end of progn
);_ end of if
(setq region_List (append region_List (list region_Last)))
;; find the external boundary
(setq newArea (vlax-get-property (vlax-ename->vla-object region_Last) 'area))
(if (< maxArea newArea)
(progn
(setq maxArea newArea)
(setq maxEntity region_Last))
);_ end of if
);_ end of progn
);_end of if
);_ end of repeat
(setq region_List (vl-remove maxEntity region_List))
(foreach region region_list
(command "_subtract" maxEntity "" region "")
)
(command "_Extrude" (entlast) "")
(princ)
);_ end of progn
);_ end of if
);_ end of defun
;; make regions with holes
(defun c:CAH ( / ss ss_Length entn cn region_Last region_List newArea maxArea maxEntity ss_subtract)
(vl-load-com)
(princ "\nMacro: Make Region with Holes\n")
(princ)
(setq region_List '())
(setvar "cmdecho" 0)
(setvar "highlight" 1)
(setq ss (ssget))
(command "._Select" ss "")
(setq ss (ssget "P" '( (-4 . "<OR")
(0 . "*POLYLINE")
(0 . "REGION")
(0 . "CIRCLE")
(0 . "ELLIPSE")
(-4 . "OR>")
)))
(if (= ss nil)
(princ "Nothing to do.")
(progn
(setq ss_Length (sslength ss) cn 0)
;;(command "_region" ss "")
(repeat ss_Length
(setq entn (entget (ssname ss cn)))
(setq cn (1+ cn))
(if entn
(progn
(if (equal (cdr (assoc 0 entn)) "REGION")
(setq region_Last (cdr (assoc -1 entn)))
(progn
(command "_region" (cdr (assoc -1 entn)) "")
(setq region_Last (entlast))
);- end of progn
);_ end of if
(setq region_List (append region_List (list region_Last)))
;; find the external boundary
(setq newArea (vlax-get-property (vlax-ename->vla-object region_Last) 'area))
(if (< maxArea newArea)
(progn
(setq maxArea newArea)
(setq maxEntity region_Last))
);_ end of if
);_ end of progn
);_end of if
);_ end of repeat
(setq region_List (vl-remove maxEntity region_List))
(foreach region region_list
(command "_subtract" maxEntity "" region "")
)
(princ)
);_ end of progn
);_ end of if
);_ end of defun
(defun C:Sqm (/ floor)
(initget 7)
(setq floor (getint "\nEnter the floor height: "))
(princ (strcat "\nTotal Area: "(rtos (/ (C:*Vol*) floor) 2 2)))
(princ)
);_ endof defun