CAD二次开发 lisp提取提取质心及流水编号ZX python c#

CAD二次开发 lisp提取提取质心及流水编号ZX python c#
(defun c:ZX()
(setvar"osmode" 0)
(setq dm (getstring “\n请输入村代码(大写字母):”))
(setq c1 (strcat dm “-ZDX”))
(setq c2 (strcat dm “-LSH”))
(setq huzhum “无编号”)

   (princ "\n选取加入范围线...")
   (setq plines (ssget   (list (cons 0 "*POLYLINE") (cons 8 c1))))
   (if (/= plines nil)
   (progn
   (setq count 0)
   (while (< count (sslength plines))
   (setq entnam1 (ssname plines count))      ;;;;返回选择集中指定图元
   (setq entnam (entget entnam1 '("*")))     ;;;;获取对象定义数据

   (setq zbc ())
   (foreach gxz entnam (if (= 10 (car gxz))(setq zbc (cons  (cdr gxz) zbc))))
    (setq zbc (reverse zbc))                 ;;倒置表的元素顺序

     (setq dwdlst zbc dwdnum 0 xx 0 yy 0)
     (while
     (/= dwdlst nil)
     (setq ptl (car dwdlst))
     (setq dwdlst (cdr dwdlst))
     (setq dwdnum (+ 1 dwdnum))
     (setq x (nth 0 ptl))                    ;;;;返回表中第N个元素
     (setq y (nth 1 ptl))
     (setq xx (+ x xx))
     (setq yy (+ y yy))
     );while
   (setq x (/ xx dwdnum))
   (setq y (/ yy dwdnum))
   (setq dwd (list x y))

    (setq huz (ssget "cp" zbc (list (cons 0 "TEXT") (cons 8 c2))))
    (setq tm2 (entget (ssname huz 0)))
    (setq  huzhum (cdr (assoc 1 tm2)))      ;;;;返回流水号


   (setq fn (strcat "d:/" dm "-ZX.CSV"))
   (setq fp1 (open fn "a"))
   (write-line (strcat  huzhum ","(rtos y 2 3) "," (rtos  x 2 3) ",0" )  fp1)
   (close fp1)
   (command "change" entnam1 "" "p" "c" "2" "")


   (setq count (+ 1 count))
    (setq  huzhum "无编号")

);while
));ifp
(close fn));defun

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DK业

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值