明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3065|回复: 7

[求助]如何测量两线最远距离?

[复制链接]
发表于 2004-10-16 09:01:00 | 显示全部楼层 |阅读模式
[求助]请高手帮忙如何测量在同一平面的两线段最远距离?


其中包括圆弧线,样条曲线,多段线,并显示测量位置线及在命令行提示测量数据.
发表于 2004-10-16 11:20:00 | 显示全部楼层

回复

你是想做什么用呢? 得到图面范围吗?
发表于 2004-10-16 22:18:00 | 显示全部楼层
圆弧线,样条曲线,多段线


你说的线段是????


或你要的特征点是??
 楼主| 发表于 2004-10-17 03:58:00 | 显示全部楼层
谢谢回复


测量在同一平面的两线段最远距离的目的是得到图面范围,便于排料.


圆弧线,样条曲线,直线或多段线组成的图形
发表于 2004-10-17 09:02:00 | 显示全部楼层

回复

获取屏幕角点坐标程序,是否对你有用: 以前在本站上收集的lisp程序,可以参考一下: dispbbs.asp?boardid=16&star=1&replyid=88899&id=12315&skin=0&page=1

本帖子中包含更多资源

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

x
 楼主| 发表于 2004-10-17 10:44:00 | 显示全部楼层

谢谢热心的5,我下载了你全部的,还是不行,我的意图是当在一个平面内,一条是直线,另一条是弧线,要知道二线最远的距离才行.

发表于 2004-10-17 11:46:00 | 显示全部楼层

回复

那要处理具体实体了,通过坐标,或者实体的范围BoundingBox,


如果有图形贴上来, 标明目的意图!
 楼主| 发表于 2004-10-17 14:47:00 | 显示全部楼层
不好意思!我不会贴图,比如一个四边图形,底边是直边顶边是弧线,二边是直线,但不相等,请问底边到弧边最远点的距离,目的是我知道最远点的距离也就可以知道用多宽的钢板下料了,如果我用在网上下载的<测量在同一平面的两线段最短距离>的方法也可以检查出最远点,但麻烦,我想能不能直接测量出最远点.下面是我网上下载的<测量在同一平面的两线段最短距离>,相当好用. ;_求共面曲线间最近距离及最近点的LISP程序__BY__WKAI__晓东CAD论坛______________
;_2004.01.05.16.02___________________________________________________________
;____________________________________________________________________________
;____________________________________________________________________________
(defun c:ln (/ ent1 ent2 n1 n2 dist)
(princ "\n请选择共面的线段、圆、圆弧,或者复义线,第一段:")
(setq vlobject1 (vlax-ename->vla-object (setq ent1 (car (entsel)))))
(princ "\n请选择共面的线段、圆、圆弧,或者复义线,第二段:")
(setq vlobject2 (vlax-ename->vla-object (setq ent2 (car (entsel)))))
(setq int (vlax-variant-value (vla-intersectwith vlobject1 vlobject2 acextendnone)))
(if (> (vlax-safearray-get-u-bound int 1) 0)
(princ "\n最小距离为:0")
(progn
(setq s1 (is_pl ent1 vlobject1))
(setq s2 (is_pl ent2 vlobject2))
(setq n1 0
n2 0
)
(repeat (sslength s1)
(setq ent1 (ssname s1 n1)
n1 (1+ n1)
n2 0
)
(repeat (sslength s2)
(setq ent2 (ssname s2 n2)
n2 (1+ n2)
)
(setq dist (append dist (list (distance_between_ents ent1 ent2))))
)
)
(setq dist (car (vl-sort dist (function (lambda (e1 e2) (< (car e1) (car e2)))))))
(command "line" (cadr dist) (caddr dist) "")
(princ "\n最小距离为:")
(princ (car dist)) )
)
(is_simple_obj s1)
(is_simple_obj s2)
(princ)
)
;____________________________________________________________________________
;____________________________________________________________________________
;____________________________________________________________________________
(defun is_pl (e v / s)
(if (or (= "POLYLINE" (cdr (assoc 0 (entget e))))
(= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
)
(progn
(vla-copy v)
(command "explode" (entlast))
(setq s (ssget "p"))
)
(setq s (ssadd)
s (ssadd e s)
)
)
s
)
(defun is_simple_obj (s)
(if (> (sslength s) 1)
(command "erase" s "")
)
)
;____________________________________________________________________________
;____________________________________________________________________________
;____________________________________________________________________________
(defun distance_between_arc_and (a1 a2 / dd en1 en2 di1 di2)
(if (= "CIRCLE" (cdr (assoc 0 (entget (vlax-vla-object->ename a1)))))
(progn
(setq cen1 (vlax-safearray->list (vlax-variant-value (vla-get-center a1))))
(setq di3 (vlax-curve-getClosestPointTo a2 cen1))
(setq en3 (polar cen1 (angle cen1 di3) (vla-get-radius a1)))
(setq dd (append dd (list (list (distance di3 en3) en3 di3))))
)
(progn
(setq en1 (vlax-safearray->list (vlax-variant-value (vla-get-startpoint a1))))
(setq en2 (vlax-safearray->list (vlax-variant-value (vla-get-endpoint a1))))
(setq cen1 (vlax-safearray->list (vlax-variant-value (vla-get-center a1))))
(setq di1 (vlax-curve-getClosestPointTo a2 en1))
(setq di2 (vlax-curve-getClosestPointTo a2 en2))
(setq di3 (vlax-curve-getClosestPointTo a2 cen1))
(setq en3 (polar cen1 (angle cen1 di3) (vla-get-radius a1)))
(setq dd (append dd (list (list (distance di1 en1) en1 di1))))
(setq dd (append dd (list (list (distance di2 en2) en2 di2))))
(if (vlax-curve-getParamAtPoint a1 en3)
(setq dd (append dd (list (list (distance di3 en3) en3 di3))))
)
)
)
(car (vl-sort dd (function (lambda (e1 e2) (< (car e1) (car e2))))))
)
(defun distance_between_line_and (a1 a2 / dd en1 en2 di1 di2)
(setq en1 (vlax-safearray->list (vlax-variant-value (vla-get-startpoint a1))))
(setq en2 (vlax-safearray->list (vlax-variant-value (vla-get-endpoint a1)))) (setq di1 (vlax-curve-getClosestPointTo a2 en1))
(setq di2 (vlax-curve-getClosestPointTo a2 en2))
(setq dd (append dd (list (list (distance di1 en1) en1 di1))))
(setq dd (append dd (list (list (distance di2 en2) en2 di2)))) (car (vl-sort dd (function (lambda (e1 e2) (< (car e1) (car e2))))))
)
;____________________________________________________________________________
;____________________________________________________________________________
;____________________________________________________________________________
(defun distance_between_ents (e1 e2 / a1 a2 en1 en2 cen1 di1 di2 di3 dd dd_l)
(command "osnap" "non")
(setq vlo1 (vlax-ename->vla-object e1))
(setq vlo2 (vlax-ename->vla-object e2))
(setq int (vlax-variant-value (vla-intersectwith vlo1 vlo2 acextendnone)))
(if (> (vlax-safearray-get-u-bound int 1) 0)
(princ "\n距离为0")
(progn
(if (or (= "ARC" (cdr (assoc 0 (entget e1))))
(= "CIRCLE" (cdr (assoc 0 (entget e1))))
)
(setq dd_l (append dd_l (list (distance_between_arc_and vlo1 vlo2))))
(setq dd_l (append dd_l (list (distance_between_line_and vlo1 vlo2))))
)
(if (or (= "ARC" (cdr (assoc 0 (entget e2))))
(= "CIRCLE" (cdr (assoc 0 (entget e2))))
)
(setq dd_l (append dd_l (list (distance_between_arc_and vlo2 vlo1))))
(setq dd_l (append dd_l (list (distance_between_line_and vlo2 vlo1))))
)
(setq dd_l (car (vl-sort dd_l (function (lambda (e1 e2) (< (car e1) (car e2)))))))
dd_l
)
)
)
;____________________________________________________________________________
;____________________________________________________________________________
;____________________________________________________________________________
(princ "\n求共面曲线间最近距离及最近点的LISP程序__BY__WKAI__晓东CAD论坛")
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-18 11:26 , Processed in 0.260640 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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