以前通过用户名Kent Cooper找到此lisp。
lisp例程将允许在两侧偏移用户输入的距离,并能够连接两侧的端点,使其成为一个对象。
有人能帮我修改一下,使两端在连接之前也延伸到与偏移相同的距离吗。
谢谢
- ;; OffsetBothSidesJoin.lsp [command name: OBSJ]
- ;; To Offset the same object to Both Sides at the same distance, and
- ;; if open-ended, Join the resulting objects with PEDIT.
- ;; On first use, offers regular Offset command's default distance,
- ;; but only if numerical [not "Through"].
- ;; Remembers specified offset distance, separately from regular
- ;; Offset command's default, and offers as default on later use.
- ;; Kent Cooper, 21 March 2014
- ;
- (defun C:OBSJ (/ osd disttemp obj); = Offset to Both Sides
- ;
- (setq osd (getvar 'offsetdist))
- (setvar 'peditaccept 1)
- ;
- (if *obsjdist (initget 6) (initget 7))
- ; no 0, no negative, no Enter on first use
- (setq
- disttemp
- (getdist
- (strcat
- "\nBoth-sides-offset distance"
- (strcat
- (if (or *obsjdist (> osd 0))
- (strcat ; then - construct default
- " <"
- (if *obsjdist
- (rtos *obsjdist)
- (rtos osd)
- ); end if
- ">"
- ); end strcat
- "" ; else - no default offered on first use if Offset's is Through
- ); end if
- ); end strcat
- ": "
- ); end strcat
- ); end getdist
- *obsjdist
- (cond
- (disttemp); User specified something other than Enter - use it
- (*obsjdist); Enter with prior value set - use that
- ((> osd 0) osd)
- ; Enter on first use with non-Through Offset default - use that
- ); end cond & *obsjdist
- ); end setq
- ;
- (while T
- (if
- (setq obj
- (vlax-ename->vla-object
- (car (entsel "\nSelect object to Offset to Both Sides [Esc to exit]: "))
- ); end vlax-...
- ); end setq
- (progn
- (vla-offset obj *obsjdist)
- (setq ent1 (entlast))
- (vla-offset obj (- *obsjdist))
- (if (not (vlax-curve-isClosed obj)); e.g. Line, Arc, open Polyline
- (command "_.pedit" "_m" ent1 (entlast) "" "_j" "_j" "_b" (* *obsjdist 2.5) "")
- ); if
- ); end progn
- ); end if
- ); end while
- ;
- (princ)
- ); end defun
- (prompt "Type OBSJ to Offset to Both Sides by the same distance and Join if possible.")
|