本帖最后由 作者 于 2005-7-27 21:20:14 编辑
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Function: Select an Entity and program will add segments to polyline ;from EndPoint and StartPoint still the polyline is a loop or end; ;********************************************** ;Note isFlag: 0-- add segments to polyline from EndPoint ; 1-- do from StartPoint ; 2-- do nothing ;********************************************** ;In curve if epoint0(EndPoint)=spoint0(StartPoint) ; then the curve is a loop; ;******************* ;AssocStSels0: a flag to determine there is segments or not; ;
(defun c:aw ( / ssa ent-p AssocStObj ColorChange) ; main (command "undo" "be") (setq oldos (getvar "osmode")) (setvar "osmode" 0 ) (setvar"cmdecho" 0)
(defun joinline(entline ); determine (setq epoint0(vlax-curve-getEndPoint(vlax-ename->vla-object entline))) (setq spoint0(vlax-curve-getstartPoint(vlax-ename->vla-object entline))) (if (vl-every '< (mapcar 'abs (mapcar '- epoint0 spoint0) )'(0.001 0.001 0.001)) (setq AssocStObj nil) (progn (cond ((= 0 isFlag)(joinline1 entline epoint0 )) ((= 1 isFlag)(joinline1 entline spoint0 )) ) ) ) )
(defun joinline1(entline spoint ); do (setq pp1 (mapcar '+ spoint '(0.001 0.001 0)) pp2 (mapcar '- spoint '(0.001 0.001 0)) AssocStSels (ssget "c" pp1 pp2) AssocStSels(ssdel entline AssocStSels) AssocStSels0(sslength AssocStSels)) (if (and(= 1 isFlag)(= 0 AssocStSels0)) (setq isFlag 2)) (if (and(= 0 isFlag)(= 0 AssocStSels0)) (setq isFlag 1)) (if (= 1 AssocStSels0) (progn (setq AssocStObj (ssname AssocStSels 0))
(setq AssPro(cdr(assoc 0 (entget AssocStObj)))) (if (or (= ent-p "LWPOLYLINE") (= ent-p "POLYLINE")) (progn (command "pedit" entline "j" AssocStObj "" "") (setq ssa (ssadd )) (setq ssa (ssname (ssget "l")0)) (setq ent-p (cdr (assoc 0 (entget ssa)))) ) (progn (command "pedit" entline "y" "j" AssocStObj "" "") (setq ssa (ssadd )) (setq ssa (ssname (ssget "l")0)) (setq ent-p (cdr (assoc 0 (entget ssa)))) ) )
(if (= AssPro "SPLINE")
(cond
((= 0 isFlag )(setq isFlag 1))
((= 1 isFlag )(setq isFlag 2))
(t(setq isFlag 2))
)
) ) )
(if (= 2 isFlag) (setq AssocStObj nil)(setq AssocStObj t))
(if (= 0 isFlag) (setq AssocStSels nil)) ) (setq ssa (car(entsel "\nPick a Line:")) ent-p (cdr (assoc 0 (entget ssa)))) (setq AssocStSels0 0 isFlag 0) (if (or(= ent-p "LINE")(= ent-p "ARC")(= ent-p"LWPOLYLINE" )) (progn (joinline ssa ) (while AssocStObj (joinline ssa ) )
(initget "Yes No" ) (setq ColorChange (getkword "\nChange the LWPOLYLINE's Color into Red[Yes/No]<N>:")) (cond ((= ColorChange "Yes")(command "change" ssa "" "p" "c" 230 "")) )
) (prompt "\nPlease Select a line or arc!\n") ) (setvar "osmode" oldos) (command "undo" "e") (prompt "\n*****Designed by TANG.J.Z!*****") (princ) ) |