明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: wanchr

[提问] 请问图元信息里的10坐标组怎么提高他精度

[复制链接]
 楼主| 发表于 2023-11-29 09:20:13 | 显示全部楼层
飞雪神光 发表于 2023-11-29 08:28
导出之前就去重 明经上找个去重函数 还有再回复我 请点击下方的回复 否则看不到
                       ...

(defun extract-entity-coordinates (ss)
  (setq coordinates '())

  (if (sslength ss)
    (progn
      (setq total-entities (sslength ss))
      (setq i 0)

      (while (< i total-entities)
        (setq entity (ssname ss i))
        (setq entity-type (cdr (assoc 0 (entget entity))))

        (cond
          ((= entity-type "CIRCLE")
              (setq entity-coordinates(mapcar (function (lambda (x) (rtos x 2 8))) (cdr (assoc 10 (entget entity))))))
         ; 上面一行怎么把xyz,连起来,用于下面的比较
          (t
           (setq entity-coordinates '()))
        )

        (setq coordinates (append coordinates entity-coordinates)) ;这里比较去重,二个表怎么比较啊,
        (setq i (1+ i))
      )
    )
  )

  coordinates
)
把用到的函数告诉我啊,我水货不知道怎么弄。
发表于 2023-11-29 11:06:04 | 显示全部楼层
wanchr 发表于 2023-11-29 09:20
(defun extract-entity-coordinates (ss)
  (setq coordinates '())

  1. (defun extract-pts (ss)
  2.         (defun BF-list-delsame (lst buzz)
  3.                 (if Lst
  4.                         (cons (car Lst)
  5.                                 (BF-list-delsame
  6.                                         (vl-remove-if
  7.                                                 '(lambda (x) (equal (car lst) x buzz))
  8.                                                 (cdr lst)
  9.                                         )
  10.                                         buzz
  11.                                 )
  12.                         )
  13.                 )
  14.         )
  15.   (if (sslength ss)
  16.     (progn
  17.                         (setq pts '())
  18.       (setq num (sslength ss))
  19.       (setq i 0)
  20.                         (while (< i num)
  21.         (setq ty (ssname ss i))
  22.         (setq tylx (cdr (assoc 0 (entget ty))))
  23.                                 (cond
  24.           ((= tylx "CIRCLE")
  25.                                                 (setq pts (append pts (list (cdr (assoc 10 (entget ty))))))
  26.                                         )
  27.                                 )
  28.                                 (setq i (1+ i))
  29.       )
  30.                 )
  31.   )
  32.         (BF-list-delsame pts 0.1)
  33. )
  34. (extract-pts (ssget))
 楼主| 发表于 2023-11-29 13:03:53 | 显示全部楼层

这个去重函数可以运行,可是提出来的坐标精度还是有问题啊。
1、这个精度不足(setq entity-coordinates (append entity-coordinates (list (cdr (assoc 10 (entget entity))))))
2、这坐标精度有,可xyz分三行没法去重了,(setq entity-coordinates(mapcar (function (lambda (x) (rtos x 2 8))) (cdr (assoc 10 (entget entity))))))
帮我改下,谢谢
发表于 2023-11-29 13:20:45 | 显示全部楼层
本帖最后由 飞雪神光 于 2023-11-29 13:26 编辑
wanchr 发表于 2023-11-29 13:03
这个去重函数可以运行,可是提出来的坐标精度还是有问题啊。
1、这个精度不足(setq entity-coordinates  ...

1.精度没有不足 我给你的去重有容差可以设置  2这里求精度纯属多余了 不用纠结精度的问题 前面有人说过了 你看到的并不是他的实际精度 正常处理就行
 楼主| 发表于 2023-11-29 14:05:02 | 显示全部楼层
飞雪神光 发表于 2023-11-29 13:20
1.精度没有不足 我给你的去重有容差可以设置  2这里求精度纯属多余了 不用纠结精度的问题 前面有人说过了 ...

不是,去重后的写盘输出时精度不足,这个时候它肯定转成文本数字了。不是计算去重的精度不足啊
发表于 2023-11-29 18:47:33 | 显示全部楼层
wanchr 发表于 2023-11-29 14:05
不是,去重后的写盘输出时精度不足,这个时候它肯定转成文本数字了。不是计算去重的精度不足啊

去重已经完成了 输出就用write-line princ 啥的 rtos设置输出精度
发表于 2023-11-29 19:29:48 | 显示全部楼层
你的coordinates表结构是(list x1 y1 z1 x2 y2 z2......),这种不好比较去重
应该用这种(list(list x1 y1 z1)(list x2 y2 z2)......)

下面就可以去重
(if(not(member entity-coordinates coordinates))
(setq coordinates(cons entity-coordinates coordinates))
)

(if(vl-position entity-coordinates coordinates)
(setq coordinates(cons entity-coordinates coordinates))
)
 楼主| 发表于 2023-11-29 20:47:30 | 显示全部楼层
本帖最后由 wanchr 于 2023-11-29 20:58 编辑
飞雪神光 发表于 2023-11-29 18:47
去重已经完成了 输出就用write-line princ 啥的 rtos设置输出精度

(defun extract-coordinates()
  (setq aa (extract-entity-coordinates ss)) ; 这里是去重后对象的坐标信息
(setq bb (mapcar (lambda (coord)
                                  (apply 'list (mapcar (lambda (num)
                                                        (rtos num 2 8))
                                                      coord)))
                               aa)))
aa里面是下面这种坐标
((1.48815e+06 1.10276e+06 1.46543e-06)
(1.48915e+06 1.10276e+06 1.46543e-06))
上面转换不成功,到底要怎么处理这个数据吗。rtos 这个函数真搞不懂,我是想他保留3位小数的。
发表于 2023-11-29 23:45:51 | 显示全部楼层
wanchr 发表于 2023-11-29 20:47
(defun extract-coordinates()
  (setq aa (extract-entity-coordinates ss)) ; 这里是去重后对象的坐标 ...

你这不转换出来了么 可以导出了 保留三位rtos控制
  1. (defun extract-coordinates()
  2.   (setq aa (extract-pts (ssget))) ; 这里是去重后对象的坐标信息
  3.         (setq bb (mapcar '(lambda (coord) (apply 'list (mapcar '(lambda (num) (rtos num 2 3)) coord))) aa))
  4. )
发表于 2023-11-29 23:55:48 | 显示全部楼层
rtos这么基础的函数都搞不懂还写什么代码 先把基础学明白再说吧 多逛论坛 少查GPT
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-24 07:27 , Processed in 0.171841 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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