本帖最后由 作者 于 2004-2-7 7:01:07 编辑
- (defun c:xl-tr (/ cmd ss r e lst) (princ "\nc:xl-tr = 自动焊接曲线端头---------无痕.2004.2")
- (vl-load-com)
- (vl-cmdf ".undo" "be")
- (setq cmd (getvar "cmdecho")
- pkb (getvar "pickbox")
- os (getvar "osmode"))
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (setq pt1 (getpoint "\n两点框选焊接实体:")
- pt2 (getcorner pt1 "\n第二点:")
- ss (ssget "w" pt1 pt2 '((0 . "*polyline,line,ellipse,arc")))
- r (getdist "\n焊接容许误差:"))
- (vl-cmdf ".zoom" "w" pt1 pt2)
- (setvar "pickbox" 0)
- (repeat (setq n (sslength ss))
- (setq e (ssname ss (setq n (1- n)))
- lst(append lst (list (xl-ept e T))(list (xl-ept e nil)))
- )
- )
- (foreach m lst (x@tr m))
- (setvar "osmode" os)
- (setvar "pickbox" pkb)
- (setvar "cmdecho" cmd)
- (vl-cmdf "zoom" "p" ".undo" "e")
- )
- (defun xl-ept (e key / obj pt)
- (setq obj (vlax-ename->vla-object e)
- pt (cond
- ((member (cdr (assoc 0 (entget e))) '("LINE" "ARC" "ELLIPSE"))
- (if key(vlax-get obj 'startpoint)(vlax-get obj 'endpoint)))
- (T (vlax-curve-getpointatparam obj
- (if key (vlax-curve-getstartparam obj)(vlax-curve-getendparam obj))))
- )
- )(list e pt)
- )
- (defun x@tr (ept / maxpt minpt ss2)
- (setq maxpt (polar (cadr ept) (* 0.25 PI) (* 1.414 r))
- minpt (polar (cadr ept) (* 1.25 PI) (* 1.414 r))
- ss2 (ssget "c" minpt maxpt '((0 . "*polyline,line,ellipse,arc"))))
- (vl-cmdf ".extend" ss2 "" ept "")
- (vl-cmdf ".trim" ss2 "" ept "")
- )
|