|
发表于 2003-6-9 10:09:00
|
显示全部楼层
(defun C:tts (/ SS SS1 N N1 NN ENT CHECK TMP PT_LIST pt plobj new_PT_LIST A )
(command "explode" "all" "")
(command "explode" "all" "")
(command "explode" "all" "")
(defun DO_IT1 ()
(if (not
(member (setq TMP (cdr (assoc 10 (entget ENT)))) PT_LIST)
)
(setq PT_LIST (append PT_LIST (list TMP)))
)
(if (not
(member (setq TMP (cdr (assoc 11 (entget ENT)))) PT_LIST)
)
(setq PT_LIST (append PT_LIST (list TMP)))
)
)
(setq SS (ssget '((0 . "polyline,line,lwpolyline"))))
(setq PT_LIST '())
(setq N 0)
(repeat (sslength SS)
(setq ENT (ssname SS N))
(setq CHECK (cdr (assoc 100 (reverse (entget ENT)))))
(cond
((= CHECK "AcDbPolygonMesh")
(command "_.COPY" ENT "" "0,0" "@")
(command "_.EXPLODE" (entlast))
(setq SS1 (ssget ""))
(setq N1 0)
(repeat (sslength SS1)
(setq ENT (entget (ssname SS1 N1)))
(setq NN 0)
(repeat 4
(if
(not (member (setq TMP (cdr (assoc (+ 10 NN) ENT))) PT_LIST)
)
(setq PT_LIST (append PT_LIST (list TMP)))
)
(setq NN (1+ NN))
)
(setq N1 (1+ N1))
)
(command "_.ERASE" SS1 "")
)
((OR(= CHECK "AcDb3dPolyline")
(= (CDR (ASSOC 0 (ENTGET ENT))) "OLYLINE")
(= (CDR (ASSOC 0 (ENTGET ENT))) "LWPOLYLINE"))
(command "_.COPY" ENT "" "0,0" "@")
(command "_.EXPLODE" (entlast))
(setq SS1 (ssget ""))
(setq N1 0)
(repeat (sslength SS1)
(setq ENT (ssname SS1 N1))
(DO_IT1)
(setq N1 (1+ N1))
)
(command "_.ERASE" SS1 "")
)
(t
(DO_IT1)
)
)
(setq N (1+ N))
)
;;;
(command "_.PLINE")
(foreach pt PT_LIST
(command pt)
)
(command "")
(setq plobj (entlast))
;;;
(setq A (car (vl-sort PT_LIST '(lambda (z1 z2)(< (caddr z1)(caddr z2))))) )
(command "move" "all" "" A '(0 0 0) "")
;;;
(setq plobj (entlast))
(setq new_PT_LIST (GetListOfPline plobj))
(entdel plobj)
new_PT_LIST
)
(defun GetListOfPline (EntityName / SSE_Pline N newEntityName)
(setq SSE_Pline (entget EntityName))
(setq LastList nil)
(if (= (cdr (assoc 0 SSE_Pline)) "LWPOLYLINE")
(progn
(setq LastList (LIST (LIST 0 0)))
(setq N 0)
(while (/= (nth N SSE_Pline) nil)
(if (= (car (nth N SSE_Pline)) 10)
(setq LastList (append LastList (list (list (cadr (nth N SSE_Pline)) (caddr (nth N SSE_Pline)) )) ))
)
(setq N (+ N 1))
)
(setq LastList (cdr LastList))
)
)
(if (= (cdr (ASSOC 0 SSE_Pline)) "OLYLINE")
(PROGN
(setq LastList (list (list 0 0)))
(setq newEntityName (entnext EntityName))
(while (= (cdr (assoc 0 (entget newEntityName))) "VERTEX")
(setq LastList (append LastList (list (list (cadr (assoc 10 (entget newEntityName))) (caddr (assoc 10 (entget newEntityName))) ))))
(setq newEntityName (entnext newEntityName))
)
(setq LastList (cdr LastList))
)
)
(setq LastList LastList)
) |
|