明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1694|回复: 6

[基础] 请教高手怎样计算与 42 关联的值,其值累加,帮忙调试一下程序,谢谢

[复制链接]
发表于 2013-10-19 09:34:51 | 显示全部楼层 |阅读模式
本帖最后由 mycad 于 2013-10-19 09:36 编辑

((-1 . <图元名: 7ee59540>) (0 . "LWPOLYLINE") (330 . <图元名: 7ee2ccc0>) (5 .
"3AE8") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (6 .
"Continuous") (100 . "AcDbPolyline") (90 . 5) (70 . 128) (43 . 0.0) (38 . 0.0)
(39 . 0.0) (10 -31.9401 27.6725) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10
33.6743 72.9142) (40 . 0.0) (41 . 0.0) (42 . -0.266791) (91 . 0) (10 123.316
80.3006) (40 . 0.0) (41 . 0.0) (42 . 0.515244) (91 . 0) (10 193.089 119.541)
(40 . 0.0) (41 . 0.0) (42 . -0.819695) (91 . 0) (10 274.414 126.927) (40 . 0.0)
(41 . 0.0) (42 . 0.746639) (91 . 0) (210 0.0 0.0 1.0))


(defun c:x()
  (setq a (entget (car(entsel)) '("*")))
  (setq i(length a))
  (repeat i
      (setq cc (+ cc (cadr(assoc '42 a))))
    )
)



"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-10-19 09:55:59 | 显示全部楼层
(defun c:x (/ A CC)
  (setq a (entget (car (entsel)) '("*")))
  (setq cc 0)
  (foreach i a
    (if        (= (car i) 42)
      (setq cc (+ cc (cadr i)))
    )
  )
)
发表于 2013-10-19 10:07:21 | 显示全部楼层
本帖最后由 自贡黄明儒 于 2013-10-19 11:12 编辑

;;;试一试
  1. (defun c:x1 (/ A)
  2.   (setq a (entget (car (entsel)) '("*")))
  3.   (apply '+
  4.          (mapcar '(lambda (i)
  5.                     (if        (= (car i) 42)
  6.                       (cadr i)  0
  7.                     )
  8.                   )
  9.                  a
  10.          )
  11.   )
  12. )
 楼主| 发表于 2013-10-19 10:57:54 | 显示全部楼层
错误: 参数类型错误: consp 0.0
 楼主| 发表于 2013-10-19 10:59:37 | 显示全部楼层
测试数据,主要是判断pline线有无弧段
谢谢  自贡黄明儒 !

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2013-10-19 11:13:14 | 显示全部楼层

;;  错误: 参数类型错误: consp 0.0

(defun c:x()
  (setq a (entget (car(entsel)) '("*")))
  (setq n(length a))
  (setq i 18)
  (while ( <= i n)
      ;(last(setq m(assoc 42 a)))
       ;(setq b (cdr (assoc 42 a)))

   
      ;(setq cc (+ cc (cdr(assoc '42 a))))
      (setq cc(nth i a))
      (if (= (car cc) 42)

          (progn
              ;(setq count(+ count (cadr c)))
              (setq b (cdr (assoc 42 a)))
              (setq count(+ count b))
            )

        )
       (setq i(+ i 1))
    )

)
发表于 2013-11-1 16:06:06 | 显示全部楼层
老黄的(cadr i) 应该改为(cdr i)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-26 06:01 , Processed in 0.185904 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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