本帖最后由 llsheng_73 于 2022-12-13 17:53 编辑
- (vl-load-com)
- (defun xyofen(e fun / p i pt n en)
- (or(=(type e)'ename)(setq e(vlax-vla-object->ename e)))
- (cond((vl-position'(0 . "LINE")(setq en(entget e)))
- (list(vlax-curve-getstartpoint e)(vlax-curve-getendpoint e)))
- ((WCMATCH(cdr(assoc 0 en))"*POLYLINE")
- (setq i -1 n(vlax-curve-getEndParam e))
- (while(< i n)
- (setq i(1+ i)p(vlax-curve-getPointAtParam e i))
- (or(equal(car pt)p fun)(setq pt(cons p pt))))
- (reverse pt))
- (t(vl-remove'nil(mapcar'(lambda(x)(cdr(assoc x en)))'(10 11 12 13 14))))))
- (defun s2e(s / n lst)(if(=(type s)'pickset)(repeat(setq n(sslength s))(setq n(1- n)lst(cons(ssname s n)lst)))))
- (defun PerLn(p p1 p2);;;点p到p1,p2所在直线垂距及垂足
- (setq p2(mapcar'- p1 p2))
- (list(abs(car(trans(mapcar'- p1 p) 0 p2)))
- (trans(mapcar'+(mapcar'*'(1 1 0)(trans p1 0 p2))(mapcar'*'(0 0 1)(trans p 0 p2)))p2 0)))
- (defun delsame(l1 fuz / l2);;带容差去重(重复过的取第一次出现)
- (while l1(setq l2(cons(car l1)l2)l1(vl-remove-if'(lambda (x)(equal(car l1)x fuz))(cdr l1))))
- (reverse l2))
- (defun ScreenWid();;当前屏幕宽度
- (*(apply'/(getvar'screensize))(getvar'viewsize)))
- (defun c:tt(/ s pt pts p o w ls)
- (while(setq s(s2e(ssget)))
- (and(setq a nil pt nil o(getpoint"指定参考线上一点"))
- (vl-every(function(lambda(x)(setq pt(cons(xyofen x 1e-3)pt))))s)
- (setq pts(delsame(apply(function append)pt)1e-3))
- (while(/=(car(mapcar(function set)'(a p)(grread 5)))3)(redraw)
- (setq ls nil)
- (if(= a 5)
- (progn
- (grdraw(polar o(angle p o)(setq w(ScreenWid)))(polar p(angle o p)w)5)
- (vl-some(function(lambda(x / q s)
- (setq q(cadr(PerLn x p o)))
- (or(vl-some(function(lambda(a)
- (vl-some(function(lambda(a b / o)(and(setq o(inters x q a b))(not(equal x o 1e-3)))))a(cdr a))))pt)
- (grdraw x q 4)
- (setq ls(cons(list x q)ls)))nil))pts)))))
- (if(= a 3)(vl-every(function(lambda(x)(entmakex(list'(0 . "line")(cons 10(car x))(cons 11(cadr x))'(62 . 4)))))ls))
- ))
没有象黄老师那样搞自动参考线,需要自己通过两点确定参考方向,也没有计算所需要的参考线长度
|