如何查询多段线上任意点距离起点长度
1个回答
2017-05-28
展开全部
autolisp程序编写,用VBAX函数,代码如下:
(defun C:tes ( / &dis1 &k1 &n1 &p1 &ss1)
(if (null vlax-dump-object) (vl-load-com) )
(setq &ss1 '("LINE" "LWPOLYLINE" "CIRCLE" "ARC" "HELIX" "ELLIPSE" "SPLINE" "POLYLINE"))
;曲线有起点:直线,多段线,圆,圆弧,螺旋对象,椭圆,样条曲线,二维多段线
(if (and
(setq &k1 (entsel "\n请选择曲线"))
(setq &k1 (car &k1))
(member (cdr (assoc 0 (entget &k1))) &ss1);确认是曲线
(setq &p1 (getpoint "\n请选择指定点"))
(setq &p1 (vlax-curve-getclosestpointto &k1 &p1));取得最近点
(setq &n1 (vlax-curve-getParamAtPoint &k1 &p1));取得参数
(setq &dis1 (vlax-curve-getDistAtParam &k1 &n1));到起点距离
)
(princ (strcat "\n指定点到曲线起点距离为" (rtos &dis1)));命令行显示
)
(princ)
);复制到记事本,以【.lsp】为后缀命名,打开cad,【appload】加载,命令【TES】就可以查询到起点距离。
(defun C:tes ( / &dis1 &k1 &n1 &p1 &ss1)
(if (null vlax-dump-object) (vl-load-com) )
(setq &ss1 '("LINE" "LWPOLYLINE" "CIRCLE" "ARC" "HELIX" "ELLIPSE" "SPLINE" "POLYLINE"))
;曲线有起点:直线,多段线,圆,圆弧,螺旋对象,椭圆,样条曲线,二维多段线
(if (and
(setq &k1 (entsel "\n请选择曲线"))
(setq &k1 (car &k1))
(member (cdr (assoc 0 (entget &k1))) &ss1);确认是曲线
(setq &p1 (getpoint "\n请选择指定点"))
(setq &p1 (vlax-curve-getclosestpointto &k1 &p1));取得最近点
(setq &n1 (vlax-curve-getParamAtPoint &k1 &p1));取得参数
(setq &dis1 (vlax-curve-getDistAtParam &k1 &n1));到起点距离
)
(princ (strcat "\n指定点到曲线起点距离为" (rtos &dis1)));命令行显示
)
(princ)
);复制到记事本,以【.lsp】为后缀命名,打开cad,【appload】加载,命令【TES】就可以查询到起点距离。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询