乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: flopo

[编程交流] 三维多边形lisp

[复制链接]

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 12:39:37 | 显示全部楼层
这是当之无愧的,我甚至从来没有研究过closestpointtoprojection。
回复

使用道具 举报

28

主题

76

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-6 12:43:36 | 显示全部楼层
大家好,
在从点到三维多边形绘制垂直线之后,我必须测量连续交点三维多边形-垂直线之间的距离。Lisp程序这样做会帮我很多。。。见附件-图纸。谢谢
3dpoly-dist.dwg
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 12:45:58 | 显示全部楼层
试试这个:(李的例行修改)
  1. (defun c:perp (/ i ss ent pt p1 p2)
  2. (vl-load-com)
  3. (command "_undo" "_begin")
  4. (princ "\n>> Select Points >>")
  5. (if (setq i  -1
  6.            ss (ssget '((0 . "POINT"))) )
  7.    (if (and (setq ent (car (entsel "\nSelect Curve: ")))
  8.             (wcmatch (cdr (assoc 0 (entget ent))) "*LINE,CIRCLE,ELLIPSE,ARC"))
  9.      (while (setq pt (ssname ss (setq i (1+ i))))
  10.        (setq
  11.          p2 (vlax-curve-getClosestPointto ent (setq p1 (cdr (assoc 10 (entget pt)))))
  12.        )
  13.        (if (entmake (list '(0 . "LINE") '(8 . "perp") (cons 10 p1) (cons 11 p2)))
  14.          (entmake
  15.            (list '(0 . "MTEXT")
  16.                  '(100 . "AcDbEntity")
  17.                  '(100 . "AcDbMText")
  18.                  '(8 . "point")
  19.                  (cons 10 p1)
  20.                  '(40 . 0.6)
  21.                  '(41 . 6.03584)
  22.                  '(71 . 1)
  23.                  '(72 . 5)
  24.                  (cons 1 (vl-princ-to-string (distance p1 p2)))
  25.                  '(7 . "Standard")
  26.                              ;'(210 0.0 0.0 1.0)
  27.                  '(42 . 1.6)
  28.                  '(43 . 0.6)
  29.                  '(50 . 0.0)
  30.                  '(73 . 1)
  31.                  '(44 . 1.0)
  32.            )
  33.          )
  34.        )
  35.      )
  36.    )
  37. )
  38. (command "_undo" "_end")
  39. (princ)
  40. )
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 12:50:12 | 显示全部楼层
要跟上此线程,您应该查看以下内容:
http://cadtutor.net/forum/showthread.php?t=42442
 
以下是您的解决方案:
http://cadtutor.net/forum/showpost.php?p=286596&postcount=13
 
http://cadtutor.net/forum/showthread.php?t=42505
 
http://www.theswamp.org/index.php?topic=31120.0
http://www.theswamp.org/index.php?topic=31110.0
 
http://discussion.autodesk.com/forums/thread.jspa?messageID=6296446
http://discussion.autodesk.com/forums/thread.jspa?threadID=753908&tstart=0
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 12:53:45 | 显示全部楼层
很好的代码Cab,但我认为他是在沿着3dpoly的距离。
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 12:57:15 | 显示全部楼层
哎呀,谢谢Wizman。
  1. (defun c:perp (/ i ss ent pt p1 p2 ptList LASTPT)
  2. (vl-load-com)
  3. (command "_undo" "_begin")
  4. (princ "\n>> Select Points >>")
  5. (if (setq i  -1
  6.            ss (ssget '((0 . "POINT"))) )
  7.    (if (and (setq ent (car (entsel "\nSelect Curve: ")))
  8.             (wcmatch (cdr (assoc 0 (entget ent))) "*LINE,CIRCLE,ELLIPSE,ARC"))
  9.      (while (setq pt (ssname ss (setq i (1+ i))))
  10.        (setq p2 (vlax-curve-getClosestPointto ent (setq p1 (cdr (assoc 10 (entget pt))))))
  11.        (setq ptList (cons p2 ptList))
  12.        (entmake (list '(0 . "LINE") '(8 . "perp") (cons 10 p1) (cons 11 p2)))
  13.      )
  14.    )
  15. )
  16. (if ptList
  17.    (progn
  18.      (setq Startpt (vlax-curve-getstartpoint ent)
  19.            Lastpt Startpt)
  20.      ;;  sort by distance
  21.      (setq ptList (vl-sort ptList '(lambda (e1 e2)
  22.                                      (< (vlax-curve-getdistatpoint ent e1)
  23.                                         (vlax-curve-getdistatpoint ent e2)))))
  24.    (foreach pt ptList
  25.      (if (> (distance pt Startpt) 0.001)
  26.          (entmake
  27.            (list '(0 . "MTEXT")
  28.                  '(100 . "AcDbEntity")
  29.                  '(100 . "AcDbMText")
  30.                  '(8 . "point")
  31.                  (cons 10 (polar pt (angle pt Lastpt)(/ (distance pt Lastpt) 2.)))
  32.                  '(40 . 0.6)
  33.                  '(41 . 0.0)
  34.                  '(71 .
  35.                  '(72 . 5)
  36.                  (cons 1 (rtos (distance pt Lastpt) 2 2))
  37.                  '(7 . "Standard")
  38.                              ;'(210 0.0 0.0 1.0)
  39.                  '(50 . 0.0)
  40.                  '(73 . 1)
  41.                  '(44 . 1.0)
  42.            )
  43.          )
  44.        )
  45.       (setq LastPt pt)
  46.      )
  47.    )
  48. )
  49. (command "_undo" "_end")
  50. (princ)
  51. )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:58:25 | 显示全部楼层
不错,艾伦
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 13:04:05 | 显示全部楼层
良好的编码Cab
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 13:05:45 | 显示全部楼层
毫无疑问,弗洛波先生会再次提出要求。。。
回复

使用道具 举报

28

主题

76

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-6 13:08:01 | 显示全部楼层
 
 
 
 
没有更多请求。。。。关于这个问题
谢谢,伙计们!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 10:02 , Processed in 0.392976 second(s), 81 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表