- 积分
- 15341
- 明经币
- 个
- 注册时间
- 2002-2-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-10-21 16:44:00
|
显示全部楼层
;|I want to draw a circle around an item. Copy the only things are the
circle. I don't want lines or text that run out of the circle to be copied.
I have seen this before. Can someone help? Maybe someone has a program
that I can use?|;
;;Select with pline or circle - by fence, window or crossing
(defun C:SSWITHOBJECT (/ *ERROR* OBJ OBJLST PTLST TPTLST SS COUNT TYP
CENPT RAD STPT STANG DIV INCRANG 2NDANG
)
(defun *ERROR* (MSG)
(cond
((or (not MSG)
(member MSG
'("console break"
"Function cancelled"
"quit / exit abort"
)
) ;member
) ;or
) ;condition, no message to display
((princ (strcat "\nError: " MSG))) ;else display message
) ;cond
(setvar "cmdecho" 1)
(princ)
) ;end error
(defun ISCLOSED (POLY)
(if (= "LWPOLYLINE" (cdr (assoc 0 (entget POLY))))
(= 1 (logand 1 (cdr (assoc 70 (entget POLY)))))
) ;if
) ;end
(defun MASSOC (KEY ALIST / X NLIST)
(foreach X ALIST
(if (eq KEY (car X))
(setq NLIST (cons (cdr X) NLIST))
)
)
(reverse NLIST)
) ;end
;;remove duplicate adjacent points from point list
;;arguments: OLST - pointlist, FUZ - fuzz distance
(defun REMDUPPTS (OLST FUZ / NLST P1 P2)
(while (> (length OLST) 1)
(setq P1 (car OLST)
P2 (cadr OLST)
)
(if (> (distance P1 P2) FUZ)
(setq NLST (cons P1 NLST))
) ;if
(setq OLST (cdr OLST))
) ;while
(setq NLST (cons (last OLST) NLST))
(reverse NLST)
) ;end
;start
(setvar "cmdecho" 0)
(sssetfirst)
(initget 1 "F W C ")
(setq TYP
(getkword
"\nSelect by (F)ence, (W)indow inside or (C)rossing <C>: "
)
)
(if (or (= TYP "") (= TYP "C"))
(setq TYP "C")
) ;if
(cond
((= TYP "W")
(prompt
"\nSelect circle or pline to define Window selection set:"
)
)
((= TYP "C")
(prompt
"\nSelect circle or pline to define Crossing selection set:"
)
)
((= TYP "F")
(prompt
"\nSelect circle or pline to define Fence selection set:"
)
)
) ;conditions
(setq OBJ (car (entsel)))
(while
(or
(null OBJ)
(and
(/= "LWPOLYLINE" (cdr (assoc 0 (entget OBJ))))
(/= "CIRCLE" (cdr (assoc 0 (entget OBJ))))
) ;and
) ;or
(princ
"\nSelection was not a pline or circle - try again..."
)
(setq OBJ (car (entsel)))
) ;while
(setq OBJLST (entget OBJ))
(cond
((= "LWPOLYLINE" (cdr (assoc 0 OBJLST)))
(setq PTLST (MASSOC 10 (entget OBJ)))
) ;cond pline
((= "CIRCLE" (cdr (assoc 0 OBJLST)))
(setq CENPT (cdr (assoc 10 OBJLST)) ;center pt
RAD (cdr (assoc 40 OBJLST)) ;radius
STPT (polar CENPT 0.0 RAD) ;start pt
STANG 0.0 ;start angle
DIV 360 ;number of divisions
INCRANG (/ pi 180) ;increment angle
2NDANG (+ STANG INCRANG) ;second angle
PTLST (list STPT)
) ;setq
(while (> DIV 1)
(setq PT (polar CENPT 2NDANG RAD)) ;2nd pt
(setq PTLST (cons PT PTLST))
(setq 2NDANG (+ 2NDANG INCRANG))
(setq DIV (1- DIV))
) ;while
) ;cond circle
) ;conditions
(foreach X PTLST ;trans for rotated UCS
(setq TPTLST (cons (trans X 0 1) TPTLST))
) ;WCS to UCS
(setq TPTLST (REMDUPPTS TPTLST 0.001))
(cond
((= TYP "W")
(setq SS (ssget "WP" TPTLST))
(if SS
(progn
(setq COUNT (sslength SS))
(princ "\nSelection set contains ")
(princ COUNT)
(princ " objects by Window method")
) ;progn
(princ "\nNothing selected") ;else
) ;if
) ;cond W
((= TYP "C")
(setq SS (ssget "CP" TPTLST))
(if SS
(progn
(ssdel OBJ SS) ;remove OBJ
(setq COUNT (sslength SS))
(princ "\nSelection set contains ")
(princ COUNT)
(princ " objects by Crossing method")
) ;progn
(princ "\nNothing selected") ;else
) ;if
) ;cond C
((= TYP "F")
(if (ISCLOSED OBJ)
(setq TPTLST (cons (car TPTLST) (reverse TPTLST)))
;first point at last
) ;if
(setq SS (ssget "F" TPTLST))
(if SS
(progn
(ssdel OBJ SS) ;remove OBJ
(setq COUNT (sslength SS))
(princ "\nSelection set contains ")
(princ COUNT)
(princ " objects by Fence method")
) ;progn
(princ "\nNothing selected") ;else
) ;if
) ;cond F
) ;conditions
(if SS
(sssetfirst NIL SS)
) ;select
(*ERROR* NIL) ;reset vars
(princ)
) ;end |
|