lisp程序能求多段线上任意一点到其中一个端点的距离,,每次要量桩号很烦...哪位大侠给个..谢谢了........
最好能求多段线外面任意一点,通过改点作垂直投影线交多段线上一点,再求这一点的桩号。。。也就是点到端点的距离。。。。。。。。。。。。。...
最好能求多段线外面任意一点,通过改点作垂直投影线交多段线上一点,再求这一点的桩号。。。也就是点到端点的距离。。。。。。。。。。。。。
展开
1个回答
展开全部
;;;用AP命令加载后,输入命令GM,先选中心线,再选任意点即可
(defun C:GM (/ cur pt olderr olderror *error*)
;;自定义错误处理函数
(defun myerror (s)
(if (and (/= s "函数被取消")
(/= s "函数已取消")
(/= s "Function cancelled")
(/= s "quit / exit abort")
)
(princ (strcat "错误:" s))
)
(setq *error* olderror)
(command "UNDO" "END")
(setvar "CMDECHO" 1)
(princ)
)
;;系统变量设置
(setvar "cmdecho" 0)
(setq olderror *error*
*error* myerror
)
(while (not cur)
(princ "\n请选择曲线:")
(setq cur (car (entsel)))
(if cur (setq cur (vlax-ename->vla-object cur)))
)
(setq pt (getpoint))
(if(not pt) (exit))
(setq pt (vlax-curve-getClosestPointTo cur pt))
(princ "\n桩号 = ")
(princ (vlax-curve-getDistAtPoint cur pt))
;;还原系统变量
(setq *error* olderror)
(setvar "CMDECHO" 1)
(princ)
)
(defun C:GM (/ cur pt olderr olderror *error*)
;;自定义错误处理函数
(defun myerror (s)
(if (and (/= s "函数被取消")
(/= s "函数已取消")
(/= s "Function cancelled")
(/= s "quit / exit abort")
)
(princ (strcat "错误:" s))
)
(setq *error* olderror)
(command "UNDO" "END")
(setvar "CMDECHO" 1)
(princ)
)
;;系统变量设置
(setvar "cmdecho" 0)
(setq olderror *error*
*error* myerror
)
(while (not cur)
(princ "\n请选择曲线:")
(setq cur (car (entsel)))
(if cur (setq cur (vlax-ename->vla-object cur)))
)
(setq pt (getpoint))
(if(not pt) (exit))
(setq pt (vlax-curve-getClosestPointTo cur pt))
(princ "\n桩号 = ")
(princ (vlax-curve-getDistAtPoint cur pt))
;;还原系统变量
(setq *error* olderror)
(setvar "CMDECHO" 1)
(princ)
)
追问
可能运行啊,,是点取多段线上任意一点,就能生成长度哦哦哦,,,最好能连续点,生成长度保存到txt文件里
追答
;;;可导出桩号的代码
(defun C:GM (/ cur pt fi mile)
;;自定义错误处理函数
(defun myerror (s)
(if (and (/= s "函数被取消")
(/= s "函数已取消")
(/= s "Function cancelled")
(/= s "quit / exit abort")
)
(princ (strcat "错误:" s))
)
(if fi (setq fi (close fi)))
(setq *error* olderror)
(command "UNDO" "END")
(setvar "CMDECHO" 1)
(princ)
)
;;系统变量设置
(setvar "cmdecho" 0)
(setq olderror *error*
*error* myerror
)
(while (not cur)
(princ "\n请选择曲线:")
(setq cur (car (entsel)))
(if cur (setq cur (vlax-ename->vla-object cur)))
)
(setq fi (open "D:\\桩号.txt" "w"))
(while (not pt)
(setq pt (getpoint))
(if (not pt) (exit))
(setq pt (vlax-curve-getClosestPointTo cur pt T))
(setq mile (rtos (vlax-curve-getDistAtPoint cur pt) 2))
(princ (strcat "\n桩号 = " mile))
(write-line mile fi)
(setq pt nil)
)
(iffi (setq fi (close fi)))
;;还原系统变量
(setq *error* olderror)
(setvar "CMDECHO" 1)
(princ)
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询