- UID
- 365699
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-12-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
;;;批量偏移
;;;ago9999,梨胡鸟编写(QQ17137646)
(defun c:py (/ en offd pt py_fs offd dx_ss dx_ss dx_n pt pt0 n)
(command "undo" "be") ; 定义返回点
(setvar "cmdecho" 0) ; 关闭命令提示
(if (or (= py_fs0 nil) (eq py_fs0 ""))
(setq py_fs0 "Z")
)
(princ "\n请输入偏移方式[正向(Z)/反向(F)/双向(S)/通过(T)]<")
(princ py_fs0) ;输入偏移方式
(princ ">:")
(setq py_fs (getstring))
(if (or (= py_fs nil) (eq py_fs ""))
(setq py_fs py_fs0)
(setq py_fs0 py_fs)
)
(if (or (eq py_fs "t") (eq py_fs "T"))
(princ "\n采用通过点偏移方式")
(progn
(if (= offd0 nil)
(setq offd0 "0")
)
(princ "\n请输入偏移距离(")
(princ offd0)
(princ ")") ;输入偏移距离
(setq offd (getdist))
(if (= offd nil)
(setq offd offd0)
(setq offd0 offd)
)
)
)
(princ "\n请选择线段,弧,圆,多段线:")
(setq dx_ss (ssget))
(if (or (eq py_fs "s") (eq py_fs "S"))
(setq pt (list 0 0))
(setq pt (getpoint "\n请选择基点"))
) ;输入偏移基点
(setq n 0)
(while (< n (sslength dx_ss))
(setq dx_n (ssname dx_ss n))
(if
(or (eq py_fs "t") (eq py_fs "T"))
(command "OFFSET" "t" dx_n pt "")
(progn
(cond
((or (eq "LINE" (cdr (assoc '0 (entget dx_n))))
(eq "LWPOLYLINE" (cdr (assoc '0 (entget dx_n))))
)
(command "OFFSET" offd dx_n pt "") ;正向偏移
(setq ptst (cdr (assoc '10 (entget dx_n))))
(setq pten (cdr (assoc '10 (entget (entlast)))))
(if (or (eq py_fs "f") (eq py_fs "F")) ;正向偏移删除
(command "ERASE" "l" "")
)
(if (or (eq py_fs "f")
(eq py_fs "F")
(eq py_fs "s")
(eq py_fs "S")
) ;反向偏移
(progn
(setq pt0 (list (- (* 2 (nth 0 ptst)) (nth 0 pten))
(- (* 2 (nth 1 ptst)) (nth 1 pten))
)
)
(command "OFFSET" offd dx_n pt0 "")
)
)
)
((or (eq "ARC" (cdr (assoc '0 (entget dx_n))))
(eq "CIRCLE" (cdr (assoc '0 (entget dx_n))))
)
(command "OFFSET" offd dx_n pt "") ;正向偏移
(setq rst (cdr (assoc '40 (entget dx_n))))
(setq ren (cdr (assoc '40 (entget (entlast)))))
(if (or (eq py_fs "s") (eq py_fs "S")) ;正向偏移复制
(command "copy" "l" "" "0,0,0" "0,0,0")
)
(if (or (eq py_fs "f")
(eq py_fs "F")
(eq py_fs "s")
(eq py_fs "S")
) ;反向偏移
(progn
(setq r0 (- (* 2 rst) ren))
(if (<= r0 0)
(command "ERASE" "l" "") ;正向偏移删除
(progn
(setq dx_n0 (entget (entlast)))
(setq dx_n0
(subst (cons '40 r0) (assoc '40 dx_n0) dx_n0)
)
(entmod dx_n0)
) ;正向偏移更改
)
)
)
)
)
)
)
(setq n (1+ n))
)
(command "undo" "e") ; 定义返点
(setvar "cmdecho" 1) ; 打开命令提示
(princ)
) |
|