我的朋友帮我写了一个代码:
- (defun c:test (/ x1 x2 y1 y2 points point1 point2 point_1 point_2)
- ;Get PL vertex
- (setq points '())
- (setq entselect (entsel))
- (setq entname (car entselect))
- (setq select_point (cadr entselect))
- (setq x (car select_point) y (cadr select_point))
- (setq ent (entget entname))
- (if (equal (cdr (assoc 0 ent)) "LINE" )
- (progn
- (setq point_1 (cdr (assoc 10 ent)) point_2 (cdr (assoc 11 ent)) )
- (setq x1 (car point_1) y1 (cadr point_1) x2 (car point_2) y2 (cadr point_2))
- (setq le_point (list (* 0.5 (+ x1 x2)) (* 0.5 (+ y1 y2)) ))
- )
-
- (progn
- (mapcar '(lambda (x) (cond
- ((= 10 (car x)) (setq points (cons (cdr x) points)) )
- )
- )
- ent
- )
- (setq add_point (car points))
- (setq points (reverse points))
- (setq points (cons add_point points))
- (setq points (reverse points))
- (princ 'lyt)
- ;Get chamfer vertex marked
- (setq judgement 1)
- (while judgement
- (setq point1 (car points))
- (setq point2 (cadr points))
- (setq x1 (car point1) y1 (cadr point1) x2 (car point2) y2 (cadr point2))
-
- (if (and (or (and (< x x1) (> x x2)) (and (< x x2) (> x x1))) (or (and (< y y1) (> y y2)) (and (< y y2) (> y y1))))
- (progn
- (setq point_1 point1 point_2 point2 judgement 'nil)
- )
- )
-
- (setq points (cdr points))
- )
- (setq x1 (car point_1) y1 (cadr point_1) x2 (car point_2) y2 (cadr point_2))
- (setq le_point (list (* 0.5 (+ x1 x2)) (* 0.5 (+ y1 y2)) ))
-
- )
- )
-
-
-
- ;Calc & dim
- (setq choice1 (abs (- y1 y2)) )
- (setq choice2 (abs (- x1 x2)) )
- (if (= choice1 choice2)
- (setq choice (strcat "C" (rtos choice1 2 1)))
- (setq choice (strcat (rtos choice1 2 1) "x" (rtos choice2 2 1)))
- )
- (setq height 2.5) ;Change test height
- (command "qleader" le_point pause pause)
- (setq ent (entget (entlast)))
- (setq points '(""))
- (mapcar '(lambda (x)
- (cond
- ((= 10 (car x)) (setq points (cons (cdr x) points)))
- )
- )
- ent
- )
- (setq point_end (car points))
- (setq point_start (cadr points))
- (if (> (- (car point_end) (car point_start)) 0)
- (progn
- (setq point (list (+ (car point_end) (* 0.7 height)) (- (cadr point_end) (* 0.5 height))))
- (command "text" point height 0 choice )
- )
- (progn
- (setq point (list (- (car point_end) (* 0.7 height) ) (- (cadr point_end) (* 0.5 height))))
- (princ point)
- (command "text" point height 0 choice )
- (setq entname (entlast))
- (setq ent (entget entname))
- (entmod
- (mapcar '(lambda ( x)
- (cond
- ((= (car x) 72) (cons (car x) 2))
- ((= (car x) 11) (cons (car x) point))
- (t x)
- )
- )
- ent
- )
- )
- )
- )
- )
该代码有以下问题:
1.必须运行“qleader”,将“comment type”设置为“none”
2.dim值位于导线后面,而不是导线顶部
3.应添加“设置文字高度”并使tim层变暗
4.如果图形不是水平或垂直的,那么dim将是错误的,请查看照片
正确的方法是:1选择倒角边,2选择一个参考,3选择另一个参考边,看照片:
|