-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgroup manipulation.lsp
68 lines (67 loc) · 2.43 KB
/
group manipulation.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
;;**************************************************************************************************************;;
;;objGroup ;;
;;CREATES GROUPS BASED ON USER SELECTION (MASS GROUPING FUNCTION) ;;
;;Written CAB 9/12/18 ;;
;;**************************************************************************************************************;;
(defun c:objGroup ( / ss x ent pt)
(setq ss (ssget))
(setq x (sslength ss))
(while (> x 0)
(setq ent (entget (ssname ss (1- x))))
(if (and (not (assoc 102 ent))
(not (= (cdr (assoc 0 ent)) "LINE")))
(progn
(vla-getboundingbox (vlax-ename->vla-object (ssname ss (1- x))) 'll 'ur)
(command ".-group" "create" "*" "" (ssget "_C" (vlax-safearray->list ll) (vlax-safearray->list ur)) "")
)
)
(setq x (1- x))
)
)
;;**************************************************************************************************************;;
;;scgrp ;;
;;scales all groups in a given selection set ;;
;;Written CAB 12/11/18 ;;
;;**************************************************************************************************************;;
(defun c:scgrp ( / ss grp x factor done ent name y pt xlst ylst)
(setq ss (ssget))
(setq factor (getreal "Enter scale factor: "))
(setq x (sslength ss))
(while (> x 0)
(setq ent (entget (ssname ss (1- x))))
(setq grp (ssadd))
(if (assoc 330 ent)
(progn
(setq ent (entget (cdr (assoc 330 ent))))
(foreach item ent
(if (= (car item) 340)
(progn
(setq name (cdr (assoc -1 (entget (cdr item)))))
(if (not (member name done))
(progn
(setq done (cons name done))
(ssadd name grp)
)))))
(setq y (sslength grp)
xlst nil
ylst nil)
(while (> y 0)
(vla-getboundingbox (vlax-ename->vla-object (ssname grp (1- y))) 'll 'ur)
(setq xlst (cons (car (vlax-safearray->list ll)) xlst)
xlst (cons (car (vlax-safearray->list ur)) xlst)
ylst (cons (cadr (vlax-safearray->list ll)) ylst)
ylst (cons (cadr (vlax-safearray->list ur)) ylst)
y (1- y))
)
(if (and grp xlst ylst)
(progn
(setq pt (vlax-3d-point (/ (+ (car (vl-sort xlst '<)) (car (vl-sort xlst '>))) 2) (/ (+ (car (vl-sort ylst '<)) (car (vl-sort ylst '>))) 2) 0))
(print pt)
(setq y (sslength grp))
(while (> y 0)
(vla-scaleentity (vlax-ename->vla-object (ssname grp (1- y))) pt factor)
(setq y (1- y))
)
))))
(setq x (1- x))
))