明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1098|回复: 3

polyline 怎么计算端点的个数

[复制链接]
发表于 2007-12-28 14:40 | 显示全部楼层 |阅读模式
polyline 怎么计算端点的个数 请教一下
发表于 2007-12-29 16:04 | 显示全部楼层

(cdr (assoc 90 (entget (car (entsel)))))---对于LWPOLYLINE

对于3dPolyLine来说:

(length (get-3dpoly-by-alisp (car (entsel))))

下面是3dpolyline的点坐标的程序。

;;Using DXF codes vertices are sub entities of the 3dpoly, have to use (entnext ...)
(defun get-3dpoly-by-alisp (poly / vtx elst lst)
  (setq vtx (entnext poly))
  (while (/= (cdr (assoc 0 (setq elst (entget vtx)))) "SEQEND")
    (setq lst (cons (cdr (assoc 10 elst)) lst)
   vtx (entnext vtx)
    )
  )
  (reverse lst)
)
;;Another way using VisualLISP
(defun get-3dpoly-by-vlisp (poly / )
  (vl-load-com)
  ;; Split a flat list into a points list
  (defun 3d-coord->pt-lst (lst)
    (if lst
      (cons (list (car lst) (cadr lst) (caddr lst))
     (3d-coord->pt-lst (cdddr lst))
      )
    )
  )
  (3d-coord->pt-lst
    (vlax-get (vlax-ename->vla-object poly) 'Coordinates)
  )
)
;;test
(defun C:test ()
  (if (setq 3dpoly (car (entsel)))
    (if (= (cdr (assoc 0 (entget 3dpoly)))  "POLYLINE")
      ;;(get-3dpoly-by-alisp 3dpoly)  ;1ST way
      (get-3dpoly-by-vlisp 3dpoly) ;2ND way
    )
  )
)

 楼主| 发表于 2007-12-30 16:32 | 显示全部楼层

谢谢,我试用一下

发表于 2008-1-1 12:53 | 显示全部楼层

(setq ss (ssget))

(setq i -1)
  (repeat (sslength ss)
    (setq en (ssname ss (setq i (1+ i)))

          顶点数   (cdr (assoc 90 (entget en)))

     )

   )

算法是这样的,

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-12 06:18 , Processed in 0.151460 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表