- 积分
- 878
- 明经币
- 个
- 注册时间
- 2020-7-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2020-9-2 12:16:21
|
显示全部楼层
谢谢,有时间的话,看看这个函数能从里面找出点能利用的函数不,给您添麻烦了,谢谢我看不太懂,哪部分能提取出来当反向函数。
*******************
;;;批量偏移
;;;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)
)
|
|