- (defun c:dk( / mydefunction dk_bili dk_min dk_layer)
- (setq dk_bili 0.2 ;引线比例
- dk_min 50 ;折线最小距离
- dk_layer "SE_HOLE"
- );;变量设置
- (if (not (tblsearch "LAYER" "SE_HOLE"))
- (progn
- (entmake (list '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- '(70 . 0)
- '(62 . 201)
- '(6 . "Continuous")
- '(2 . "SE_HOLE")))
- )
- )
- (defun dk::draw_dk(/ dis dx x y pt2 pt3 dk_distance);(hcl_make_rec p1 p2 "0" 1 40)
- ; (setq dk_distance (* (distance pt1 pt0) (- 0.5 dk_bili))
- ; pt2 (point_mid pt0 pt1)
- ; pt2 (polar pt2 (- pi (angle pt0 pt1)) dk_distance)
- ; )
- (setq dis (* (min (abs (- (car pt1) (car pt0))) (abs (- (cadr pt1) (cadr pt0)))) dk_bili)
- dis (max dis dk_min)
- )
- (if (< (car pt0) (car pt1))
- (setq dx dis)
- (setq dx (- dis))
- )
- (setq x (+ (car pt0) dx))
- (if (< (cadr pt0) (cadr pt1))
- (setq dx dis)
- (setq dx (- dis))
- )
- (setq y (- (cadr pt1) dx)
- pt2 (list x y)
- )
- (entmake (list
- '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 dk_layer)
- '(90 . 3) '(43 . 0)
- (cons 10 pt0) (cons 10 pt2) (cons 10 pt1)
- )
- )
- (if dk_has_rec
- (dk::make_rec)
- )
- )
- (defun dk::make_rec();(hcl_make_rec p1 p2 "0" 1 40)
- (entmake (list
- '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 dk_layer)
- '(90 . 4) '(70 . 1) '(43 . 0)
- (list 10 (car pt0) (cadr pt0)) (list 10 (car pt0) (cadr pt1))
- (list 10 (car pt1) (cadr pt1)) (list 10 (car pt1) (cadr pt0))
- )
- )
- )
- (defun dk_print_parm( / tip_rec)
- (initget 0 "F")
- (if dk_has_rec
- (setq tip_rec "有轮廓")
- (setq tip_rec "无轮廓")
- )
- (princ (strcat "\n【标注洞口】\n 当前模式:" tip_rec
- ))
- )
- (defun mydefunction(/ pt0 pt1)
- ;;begin mydefunction
- (dk_print_parm)
- (while (setq pt0 (getpoint "\n 第一点[F切换模式]:"))
- (cond
- ((= "F" pt0)
- (setq dk_has_rec (not dk_has_rec))
- )
- (t
- (if (setq pt1 (getpoint pt0 "\n 第二点:"))
- (progn
- (dk::draw_dk)
- )
- )
- )
- )
- (dk_print_parm)
- )
- )
- (setvar 'cmdecho 0)
- (mydefunction)
- (setvar 'cmdecho 1)
- (prin1)
- )
|