明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: yth0407

求转出槽孔每个点坐标成文本文件的LISP!

  [复制链接]
发表于 2007-9-10 11:26:00 | 显示全部楼层
我写了一个,不过测出的坐标跟你的图不对应。你的图上的坐标自己标的?不对应CAD的坐标系
  1. (defun c:cs(/ X YH_BO YH_FILE YH_LE YH_PT1 YH_PTL)
  2.   (vl-load-com)
  3.   (command)
  4.   (setq YH_pt1 (getpoint "\n选择空内部点或者右键选择孔边界:"))
  5.   (if YH_pt1
  6.     (progn
  7.       (setq YH_le (entlast)
  8.      YH_ptl '()
  9.      )
  10.       (command "boundary" "a" "i" "n" "" "" YH_pt1 "")
  11.       (setq YH_bo (entlast))
  12.       (if (eq YH_le YH_bo)
  13. (alert "错误,所选区域不封闭!")
  14. (progn
  15.    (mapcar '(lambda (x) (if (= (car x) 10) (setq YH_ptl (append YH_ptl (list (cdr x)))))) (entget YH_bo))
  16.    (setq YH_file (open "C:\\1.txt" "W"))
  17.    (mapcar '(lambda (x) (write-line (strcat "X" (rtos (car X)) "Y" (rtos (cadr X))) YH_file)) YH_ptl)
  18.    (close YH_file)
  19.    (startapp "notepad" "C:\\1.txt")
  20.    (entdel YH_bo)
  21.    )
  22. )
  23.       )
  24.     (alert "此功能未完成")
  25.     )
  26.   )
 楼主| 发表于 2007-9-11 02:40:00 | 显示全部楼层
谢谢楼上的兄弟,能不能写得转出来每个槽孔的坐标最后一个跟第一个是一样的,就是从哪一点开始最后也是回到那一点,一个槽孔才算闭合啊,还有能不能写得能够连续转出多个槽孔点的坐标?麻烦sailorcwx兄再帮帮忙,谢谢!
发表于 2007-9-11 12:48:00 | 显示全部楼层
(defun c:cs(/ X YH_BO YH_FILE YH_INDEX YH_LE YH_PT1 YH_PTL YH_PTL1)
  (vl-load-com)
  (command)
  (setq YH_ptl '())
  (while (setq YH_pt1 (getpoint "\n选择孔内部点或者右键退出:"))
    (setq YH_le (entlast))
    (command "boundary" "a" "i" "n" "" "" YH_pt1 "")
    (setq YH_bo (entlast))
    (setq YH_ptl1 '())
    (if (eq YH_le YH_bo)
      (alert "错误,所选区域不封闭!")
      (progn
 (mapcar '(lambda (x) (if (= (car x) 10) (setq YH_ptl1 (append YH_ptl1 (list (cdr x)))))) (entget YH_bo))
 (entdel YH_bo)
 )
      )
    (if YH_ptl1 (setq YH_ptl (append YH_ptl (list YH_ptl1))))
    )
  (if YH_ptl
    (progn
      (setq YH_file (open "C:\\1.txt" "W")
     YH_index 0
     )
      (repeat (length YH_ptl)
 (setq YH_ptl1 (nth YH_index YH_ptl))
 (write-line (strcat "======第" (rtos (1+ YH_index) 2 0) "个孔顶点坐标======") YH_file)
 (mapcar '(lambda (x) (write-line (strcat "X" (rtos (car X)) "Y" (rtos (cadr X))) YH_file)) YH_ptl1)
 (write-line "" YH_file)
 (setq YH_index (1+ YH_index))
 )
      (close YH_file)
      (startapp "notepad" "C:\\1.txt")
      )
    )
  )
 楼主| 发表于 2007-9-12 01:10:00 | 显示全部楼层
能连续了但是每个孔还是不能回到开始那个点啊?就是每个槽孔第一点开始,最后一点还是回到第一点的?sailorcwx兄再帮忙看看.
发表于 2007-9-12 10:06:00 | 显示全部楼层
哦,忘记了
  1. (defun c:cs(/ X YH_BO YH_FILE YH_INDEX YH_LE YH_PT1 YH_PTL YH_PTL1)
  2.   (vl-load-com)
  3.   (command)
  4.   (setq YH_ptl '())
  5.   (while (setq YH_pt1 (getpoint "\n选择孔内部点或者右键退出:"))
  6.     (setq YH_le (entlast))
  7.     (command "boundary" "a" "i" "n" "" "" YH_pt1 "")
  8.     (setq YH_bo (entlast))
  9.     (setq YH_ptl1 '())
  10.     (if (eq YH_le YH_bo)
  11.       (alert "错误,所选区域不封闭!")
  12.       (progn
  13. (mapcar '(lambda (x) (if (= (car x) 10) (setq YH_ptl1 (append YH_ptl1 (list (cdr x)))))) (entget YH_bo))
  14. (entdel YH_bo)
  15. )
  16.       )
  17.     (if YH_ptl1 (setq YH_ptl (append YH_ptl (list (append YH_ptl1 (list (car YH_ptl1)))))))
  18.     )
  19.   (if YH_ptl
  20.     (progn
  21.       (setq YH_file (open "C:\\1.txt" "W")
  22.      YH_index 0
  23.      )
  24.       (repeat (length YH_ptl)
  25. (setq YH_ptl1 (nth YH_index YH_ptl))
  26. (write-line (strcat "======第" (rtos (1+ YH_index) 2 0) "个孔顶点坐标======") YH_file)
  27. (mapcar '(lambda (x) (write-line (strcat "X" (rtos (car X)) "Y" (rtos (cadr X))) YH_file)) YH_ptl1)
  28. (write-line "" YH_file)
  29. (setq YH_index (1+ YH_index))
  30. )
  31.       (close YH_file)
  32.       (startapp "notepad" "C:\\1.txt")
  33.       )
  34.     )
  35.   )
 楼主| 发表于 2007-9-12 23:35:00 | 显示全部楼层
谢谢,非常感谢.
 楼主| 发表于 2007-9-12 23:41:00 | 显示全部楼层
sailorcwx兄写的已基本上可以满足了,再次感谢sailorcwx兄,真是太谢谢了.
 楼主| 发表于 2007-10-3 08:39:00 | 显示全部楼层
sailorcwx兄能不能再出来帮帮忙,能不能把这程式再改一下,比如一个异形孔两线的交点有了R角,也能转出这R角的中点坐标。
发表于 2007-10-3 15:36:00 | 显示全部楼层
什么是R角。锐角?
发表于 2007-10-5 10:20:00 | 显示全部楼层
试试看能否满足要求。
游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0

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

本版积分规则

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

GMT+8, 2025-2-27 20:09 , Processed in 0.193863 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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