CAD lisp 求助一段代码实现自动标注!
我有很多直线,每个直线端点处都有直径4的圆圈,求助一段代码实现每段实现的尺寸都被标注出来,最好标注的内容在特定图层!...
我有很多直线,每个直线端点处都有直径4的 圆圈,求助一段代码实现每段实现的尺寸都被标注出来,最好标注的内容在特定图层!
展开
展开全部
(defun c:autodimlines ()
(setq ss (ssget '((0 . "line"))))
(setq number (sslength ss))
(setq i 0)
(repeat number
(setq entname (ssname ss i))
(setq ent (entget entname))
(setq point_a (cdr (assoc 10 ent)))
(setq point_b (cdr (assoc 11 ent)))
(setq d (* -0.2 (distance point_a point_b)))
(command "dimaligned" point_a point_b point_b)
(setq ent (entget(entlast)))
(setq x1 (car point_a) y1 (cadr point_a) x2 (car point_b) y2 (cadr point_b))
(setq point (calculate_dalposition x1 y1 x2 y2 d))
(entmod (subst (cons 10 point) (assoc 10 ent) ent) )
(setq i (+ i 1))
)
)
(defun calculate_dalposition (x1 y1 x2 y2 d)
(if (/= (- y2 y1) 0)
(progn
(setq k (/ (- x1 x2) (- y2 y1)) )
(setq thita (atan k))
(if (< thita 0)
(setq thita1 (+ 3.1415926 thita) thita2 (* -1 thita))
(setq thita1 thita thita2 thita)
)
(setq x (- x2 (* d (cos thita1))))
(setq y (- y2 (* d (sin thita2))))
(list x y)
)
(progn
(setq y (- y2 d) x x2)
(list x y)
)
)
)
不知道cad能运行不 浩辰 可以
(setq ss (ssget '((0 . "line"))))
(setq number (sslength ss))
(setq i 0)
(repeat number
(setq entname (ssname ss i))
(setq ent (entget entname))
(setq point_a (cdr (assoc 10 ent)))
(setq point_b (cdr (assoc 11 ent)))
(setq d (* -0.2 (distance point_a point_b)))
(command "dimaligned" point_a point_b point_b)
(setq ent (entget(entlast)))
(setq x1 (car point_a) y1 (cadr point_a) x2 (car point_b) y2 (cadr point_b))
(setq point (calculate_dalposition x1 y1 x2 y2 d))
(entmod (subst (cons 10 point) (assoc 10 ent) ent) )
(setq i (+ i 1))
)
)
(defun calculate_dalposition (x1 y1 x2 y2 d)
(if (/= (- y2 y1) 0)
(progn
(setq k (/ (- x1 x2) (- y2 y1)) )
(setq thita (atan k))
(if (< thita 0)
(setq thita1 (+ 3.1415926 thita) thita2 (* -1 thita))
(setq thita1 thita thita2 thita)
)
(setq x (- x2 (* d (cos thita1))))
(setq y (- y2 (* d (sin thita2))))
(list x y)
)
(progn
(setq y (- y2 d) x x2)
(list x y)
)
)
)
不知道cad能运行不 浩辰 可以
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用天正 有自动标注功能啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询