2个回答
展开全部
;;;用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)
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询