乐筑天下

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

[编程交流] 距离最近Po的区块距离

[复制链接]

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:52:55 | 显示全部楼层
ASMI,
 
我在第12、13和14版中工作,它们大多没有activeX功能。我只将Acad 2000用于大型渲染项目。
 
在以后的AutoCAD版本中,我从未发现任何“我离不开”的东西
 
李,
 
我使用样板模板来实现真正的程序。我做了基本的弧线测试。我在飞行中写的主体-大卫
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 15:56:10 | 显示全部楼层
好的,我快速试用了ASMI的版本,它已经加快了当前的进程。然而,如果我可以通过某种选择过滤器(名称、图层最好)以某种方式选择许多块,然后将结果值列在表中,这将是一个很好的改进。如果这张表还可以有另一列,向我们展示关于块的独特之处,比如它的坐标或特定属性,我会很高兴。
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 15:59:12 | 显示全部楼层
我还有一个问题,一开始我忘了提,那就是图纸上的轨道和公路,代表它们的多段线,通常是3D的;然而,在这种情况下,我们希望将其视为2D,忽略Z值,因为这会扭曲真实距离。
 
再次感谢。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:02:17 | 显示全部楼层
这是一个初学者:
 
将返回块基点和到直线的距离的列表。
 
  1. ; pdis by ASMI, (modified by Lee Mac)
  2. (defun c:pdis (/ cCurve cBlock index ent dPt1 dPt2 blkDist blklist)
  3.    (vl-load-com)
  4.    (if
  5.    (and
  6.        (setq cCurve (entsel "\nSelect curve to measure > "))
  7.        (member (cdr (assoc 0 (entget (car cCurve))))
  8.            '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC" "CIRCLE" "ELLIPSE")
  9.        ) ;_  end member
  10.    ) ; end and
  11.       (progn
  12.           (setq cBlock (ssget '((0 . "INSERT")))
  13.             index  (1- (sslength cBlock))
  14.           ) ;_  end setq
  15.           (while (not (minusp index))
  16.           (setq ent  (entget (ssname cBlock index))
  17.             dPt1 (cdr (assoc 10 ent))
  18.             dPt2 (vlax-curve-getClosestPointTo (car cCurve) dPt1)
  19.             blkDist (distance dPt1 dPt2)
  20.           ) ;_  end setq
  21.           (setq blklist (cons (list dPt1 blkDist) blklist)
  22.             index     (1- index)
  23.           ) ;_  end setq
  24.           ) ; end while
  25.       ) ;_  end progn
  26.       (princ "\n<!> Empty selection or this isn't curve (line, polyline, etc.) <!> ")
  27.    ) ; end if
  28.    (alert (vl-princ-to-string blklist))
  29.    (princ)
  30. ) ; end of c:pdis
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:04:37 | 显示全部楼层
稍微好一点:
 
  1. (defun c:pdis (/ cCurve cBlock index ent dPt1 dPt2 blkDist blklist)
  2.    (vl-load-com)
  3.    (if
  4.    (and
  5.        (setq cCurve (entsel "\nSelect curve to measure > "))
  6.        (member (cdr (assoc 0 (entget (car cCurve))))
  7.            '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC" "CIRCLE" "ELLIPSE")
  8.        ) ;_  end member
  9.    ) ; end and
  10.       (progn
  11.           (setq cBlock  (ssget '((0 . "INSERT")))
  12.             index   (1- (sslength cBlock))
  13.             blklist "\n"
  14.           ) ;_  end setq
  15.           (while (not (minusp index))
  16.           (setq ent     (entget (ssname cBlock index))
  17.             dPt1     (cdr (assoc 10 ent))
  18.             dPt2     (vlax-curve-getClosestPointTo (car cCurve) dPt1)
  19.             blkDist (distance dPt1 dPt2)
  20.           ) ;_  end setq
  21.           (setq blklist (strcat "\n"
  22.                     (rtos (car dPt1))
  23.                     ","
  24.                     (rtos (cadr dPt1))
  25.                     " <---> "
  26.                     (rtos blkDist)
  27.                     blklist
  28.                 ) ;_  end strcat
  29.             index     (1- index)
  30.           ) ;_  end setq
  31.           ) ; end while
  32.       ) ;_  end progn
  33.       (princ "\n<!> Empty selection or this isn't curve (line, polyline, etc.) <!> ")
  34.    ) ; end if
  35.    (alert blklist)
  36.    (princ)
  37. ) ; end of c:pdis
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:08:46 | 显示全部楼层
好的,这个怎么样:
 
  1. (defun c:pdis (/ cCurve cBlock txtpnt index ent dPt1 dPt2 blkDist blklist txt)
  2.    (defun makelay (x)
  3.    (if (not (tblsearch "Layer" x))
  4.        (progn
  5.        (setvar "cmdecho" 0)
  6.        (command "-layer" "m" x "")
  7.        (setvar "cmdecho" 1)
  8.        ) ;_  end progn
  9.        (setvar "CLAYER" x)
  10.    ) ;_  end if
  11.    ) ;_  end defun
  12.    (defun Make_Text (txt_pt txt_val)
  13.    (entmake
  14.        (list '(0 . "TEXT")
  15.          '(8 . "TEXT")
  16.          (cons 10 txt_pt)
  17.          (cons 40 2.5)
  18.          (cons 1 txt_val)
  19.          '(50 . 0.0)
  20.          '(7 . "STANDARD")
  21.          '(71 . 0)
  22.          '(72 . 0)
  23.          '(73 . 0)
  24.        ) ; end list
  25.    ) ; end entmake
  26.    ) ;_  end defun
  27.    (vl-load-com)
  28.    (if
  29.    (and
  30.        (setq cCurve (entsel "\nSelect curve to measure > "))
  31.        (member (cdr (assoc 0 (entget (car cCurve))))
  32.            '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC" "CIRCLE" "ELLIPSE")
  33.        ) ;_  end member
  34.    ) ; end and
  35.       (progn
  36.           (while
  37.           (and
  38.               (setq cBlock (ssget '((0 . "INSERT"))))
  39.               (setq txtpnt (getpoint "\nSelect Point for Table > "))
  40.           ) ;_  end and
  41.              (makelay "TEXT")
  42.              (setq index   (1- (sslength cBlock))
  43.                blklist "\n"
  44.                txt        1
  45.              ) ;_  end setq
  46.              (while (not (minusp index))
  47.              (setq    ent    (entget (ssname cBlock index))
  48.                dPt1    (cdr (assoc 10 ent))
  49.                dPt2    (vlax-curve-getClosestPointTo (car cCurve) dPt1)
  50.                blkDist    (distance dPt1 dPt2)
  51.              ) ;_  end setq
  52.              (setq    blklist    (strcat    (rtos (car dPt1) 2 1)
  53.                        ","
  54.                        (rtos (cadr dPt1) 2 1)
  55.                        " <---> "
  56.                        (rtos blkDist 2 1)
  57.                    ) ;_  end strcat
  58.              ) ;_  end setq
  59.              (Make_Text (polar txtpnt (* pi 1.5) (* 3.5 txt)) blklist)
  60.              (setq    index (1- index)
  61.                txt   (1+ txt)
  62.              ) ;_  end setq
  63.              ) ; end while
  64.           ) ;_  end while
  65.       ) ;_  end progn
  66.       (princ "\n<!> Empty selection or this isn't curve (line, polyline, etc.) <!> ")
  67.    ) ; end if
  68.    (princ)
  69. ) ;_  end defun
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:11:01 | 显示全部楼层
对不起,所有的帖子!
 
还有一个更新:
 
  1. (defun c:pdis (/ oldlay cCurve cBlock txtpnt index ent dPt1 dPt2 blkDist blklist txt)
  2.    (defun makelay (x)
  3.    (if (not (tblsearch "Layer" x))
  4.        (progn
  5.        (setvar "cmdecho" 0)
  6.        (command "-layer" "m" x "")
  7.        (setvar "cmdecho" 1)
  8.        ) ;_  end progn
  9.        (setvar "CLAYER" x)
  10.    ) ;_  end if
  11.    ) ;_  end defun
  12.    (defun Make_Text (txt_pt txt_val)
  13.    (entmake
  14.        (list '(0 . "TEXT")
  15.          '(8 . "TEXT")
  16.          (cons 10 txt_pt)
  17.          (cons 40 2.5)
  18.          (cons 1 txt_val)
  19.          '(50 . 0.0)
  20.          '(7 . "STANDARD")
  21.          '(71 . 0)
  22.          '(72 . 0)
  23.          '(73 . 0)
  24.        ) ; end list
  25.    ) ; end entmake
  26.    ) ;_  end defun
  27.    (vl-load-com)
  28.    (setq oldlay (getvar "clayer"))
  29.    (if
  30.    (and
  31.        (setq cCurve (entsel "\nSelect curve to measure > "))
  32.        (member (cdr (assoc 0 (entget (car cCurve))))
  33.            '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC" "CIRCLE" "ELLIPSE")
  34.        ) ;_  end member
  35.    ) ; end and
  36.       (progn
  37.           (while
  38.           (and
  39.               (setq cBlock (ssget '((0 . "INSERT"))))
  40.               (setq txtpnt (getpoint "\nSelect Point for Table > "))
  41.           ) ;_  end and
  42.              (makelay "TEXT")
  43.              (setq index   (1- (sslength cBlock))
  44.                blklist "\n"
  45.                txt        1
  46.              ) ;_  end setq
  47.              (while (not (minusp index))
  48.              (setq    ent    (entget (ssname cBlock index))
  49.                dPt1    (cdr (assoc 10 ent))
  50.                dPt2    (vlax-curve-getClosestPointTo (car cCurve) dPt1)
  51.                blkDist    (distance dPt1 dPt2)
  52.              ) ;_  end setq
  53.              (setq    blklist    (strcat    (rtos (car dPt1) 2 1)
  54.                        ","
  55.                        (rtos (cadr dPt1) 2 1)
  56.                        "   <--->   "
  57.                        (rtos blkDist 2 1)
  58.                    ) ;_  end strcat
  59.              ) ;_  end setq
  60.              (Make_Text (polar txtpnt (* pi 1.5) (* 3.5 txt)) blklist)
  61.              (setq    index (1- index)
  62.                txt   (1+ txt)
  63.              ) ;_  end setq
  64.              ) ; end while
  65.           ) ;_  end while
  66.       ) ;_  end progn
  67.       (princ "\n<!> Empty selection or this isn't a Curve (line, polyline, etc.) <!> ")
  68.    ) ; end if
  69.    (setvar "clayer" oldlay)
  70.    (princ)
  71. ) ;_  end defun
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 16:15:17 | 显示全部楼层
干杯明天上班时我会试试的。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:19:36 | 显示全部楼层
没问题,告诉我结果
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 16:23:01 | 显示全部楼层
哎呀!多大的新上市。好的,李,麦克。坐标、表格等都是很好的训练。
 
我明天去看,因为该睡觉了。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 19:38 , Processed in 0.598713 second(s), 70 queries .

© 2020-2025 乐筑天下

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