本帖最后由 tryhi 于 2016-4-4 17:02 编辑
- ;;; __________________________________________
- ;;; 连续复制 改编自langjs 2016.03.27
- ;;; 命令:fz 右键默认距离复制 esc键退出
- ;;; __________________________________________
- (defun c:fz (/ *error* d en p0 p1 p2 r snap ss ssnext)
- (defun ssnext (en / ss)
- (setq ss (ssadd))
- (while (setq en (entnext en))(ssadd en ss))
- )
- (defun *error* (s)(command ".UNDO" "E"))
- (setq snap (getvar "osmode"))
- (setvar "cmdecho" 0)
- (if (setq ss (ssget))
- (if (setq p0 (getpoint "\n指定基点:"))
- (progn(command ".UNDO" "BE")
- (while t (princ "\n指定下一点或距离:")
- (if d (princ (strcat "<" (rtos d) ">:")))
- (setq en (entlast))
- (command ".copy" ss "" p0 pause)
- (setq p1 (getvar "lastpoint")p2 (mapcar '+ p1 p1))
- (if (equal p0 p1)
- (progn
- (setq p1 (polar p0 r d))
- (if (< snap 16384)(setvar "osmode" (+ snap 16384)))
- (command ".move" (ssnext en) "" p2 p1)
- (setvar "osmode" snap)
- (setq snap (getvar "osmode"))
- )
- (setq d (distance p0 p1) r (angle p0 p1)))
- (setq ss (ssnext en) p0 p1 )
- )
- )
- )
- )
- (princ)
- )
写得不错,稍微修改了下后自用,主要改了两个地方,复制时保持原有的捕捉设置,不强制设置为0,还有就是复制的时候不采取先复制后删除的方式,这样对于大量图形可以明显提高速度。还有就是退出函数你这样写有点多余,直接局部定义*error*即可 |