论坛有很多帖子给了提取LWPOLYLINE 和POLYLINE顶点坐标的程序段 下面附两个方法: 方法一: (defun vertexs (ename / plist pp n) (setq obj (vlax-ename->vla-object ename)) (setq plist (vlax-safearray->list (vlax-variant-value (vla-get-coordinates obj)))) (setq n 0) (setq entitytype (cdr (assoc 0 (entget ename)))) (if ( = entitytype "LWPOLYLINE") (setq ppm 2 ) (setq ppm 3) ) (repeat (/ (length plist) ppm);注意这个地方是用2还是3如果是LWPOLYLINE 则是2 POLYLINE 是3 (setq pp (append pp (list (list (nth n plist)(nth (1+ n) plist))))) (setq n (+ n ppm));注意这个地方是用2还是3 ) pp ) 方法二: (defun DXFEG (C E) (cdr (assoc C (entget E)))) (defun DXF (C E) (cdr (assoc C E))) (defun MAKEPOINTLIS (E / EG LIS) (setq LIS NIL) (cond ((= "LWPOLYLINE" (DXFEG 0 E)) (setq EG (entget E)) (while (setq EG (member (assoc 10 EG) EG)) (setq LIS (cons (cdar EG) LIS) EG (cdr EG) ) ) (reverse LIS) ) ((= "POLYLINE" (DXFEG 0 E)) (while (and (setq E (entnext E)) (setq EG (entget E)) (/= "SEQEND" (DXFEG 0 E)) ) (setq LIS (cons (DXF 10 EG) LIS)) ) (reverse LIS) ) (t (alert " not a polyline ") NIL) ) ) 推荐你用第二个。 |