- 积分
- 8801
- 明经币
- 个
- 注册时间
- 2003-7-14
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-10-14 10:35:00
|
显示全部楼层
存成*.lsp,加载后,在command中输入cm即可。
(defun c:CM ()
;**** Internal error handler defined locally ****
(defun DR_ERR (S) ; If an error (such as CTRL-C) occurs
(if (/= S "Function cancelled") ; while this command is active...
(if (= S "quit / exit abort")
(princ)
(princ (strcat "\nError: " S))
);end if
);end if
(if DR_OER ;If an old error routine exists
(setq *error* DR_OER) ;then, reset it
);end if
(if (not BASEPT) ;if an initial displacement was used
(foreach x SSELIST (redraw X 4));unhighlight the last selection set
)
(setvar "cmdecho" 1) ;reset command echo upon error
(princ)
);end error defun
;**** Set our new error handler ****
(if (not *DEBUG*)
(if *error*
(setq DR_OER *error* *error* DR_ERR)
(setq *error* DR_ERR)
);end if
);end if
;**** BEGIN MAIN FUNCTION ****
(if (setq EMARK (entlast))
(while (setq B (entnext EMARK))
(setq EMARK B)
)
)
(setq SS (ssget))
(setvar "cmdecho" 0)
(prompt "\nBase point or Displacement: ")
(command "copy" SS "" pause)
(setq BASEPT (getvar "lastpoint"))
(prompt "\nCopy point: ")
(command pause)
(if (equal BASEPT (setq LASTPT (getvar "lastpoint")))
(progn (setq REFPT LASTPT)
(setq BASEPT nil)
)
)
(if BASEPT
(while (entnext EMARK) ;while there are new entities
(setq SSOLD SS)
(setq SS (ssadd)) ;reset SS
(while (entnext EMARK) ;while there are new entities
(setq EMARK (entnext EMARK))
(ssadd EMARK SS) ;add them to new SS
)
(if (equal BASEPT (setq LASTPT (getvar "lastpoint")))
(progn (command "erase" SS "")
(command "copy" SSOLD "" REFPT "")
(setvar "lastpoint" (polar BASEPT ANGLPT DISTPT))
)
(progn (setq ANGLPT (angle BASEPT LASTPT))
(setq DISTPT (distance BASEPT LASTPT))
(setq REFPT (polar '(0.0 0.0 0.0) ANGLPT DISTPT))
(setq BASEPT LASTPT) ;increment basepoint
(prompt (strcat "\nCopy point <@" (rtos (car REFPT)) "," (rtos (cadr REFPT)) "," (rtos (caddr REFPT))">: "))
(command "copy" SS "" BASEPT pause)
)
)
);end while
(while (entnext EMARK) ;while there are new entities
(setq SSOLD SS)
(setq SS (ssadd)) ;reset SS
(while (entnext EMARK) ;while there are new entities
(setq EMARK (entnext EMARK))
(redraw EMARK 3)
(if SSELIST
(setq SSELIST (append (list EMARK) SSELIST))
(setq SSELIST (list EMARK))
)
(ssadd EMARK SS) ;add them to new SS
)
(ssget "")
(setq REFPT (getpoint (strcat "\nDisplacement <" (rtos (car REFPT)) "," (rtos (cadr REFPT)) "," (rtos (caddr REFPT))">: ")))
(if (not REFPT)
(setq REFPT (getvar "lastpoint"))
)
(command "copy" SS "" REFPT "")
);end while
);end if
(setvar "cmdecho" 1)
(princ)
);end defun
(princ) |
|