请问这个双向偏移,能否加个循环?
如果不加循环的话,量多了,使用起来,就不是很方便了,还请老师帮忙看看(defun c:TT1()
(setvar "CMDECHO" 0)
(if *move* (setq Newmove (getreal (strcat"\n请输入偏移距离:<" (rtos *move* 2 2) ">:") ) )
(setq Newmove (getreal "\n请输入偏移距离:"))
)
(if (null Newmove) (setq Newmove *move*) (setq *move* Newmove))
(if (ssget '((0 . "Arc,Circle,Ellipse,*Line")))
(vlax-for o (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
(mapcar '(lambda (x)(vla-offset o x)) (list Newmove (- Newmove)))
)
)
(setvar "CMDECHO" 1)
(princ)
)
(defun c:TT1 (/ newmove)
(setvar "CMDECHO" 0)
(if *move*
(setq Newmove (getreal (strcat"\n请输入偏移距离:<" (rtos *move* 2 2) ">:")))
(setq Newmove (getreal "\n请输入偏移距离:"))
)
(if (null Newmove)
(setq Newmove *move*)
(setq *move* Newmove)
)
(while (ssget '((0 . "Arc,Circle,Ellipse,*Line")))
(vlax-for o (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
(mapcar '(lambda (x)
(vla-offset o x)
)
(list Newmove (- Newmove))
)
)
)
(setvar "CMDECHO" 1)
(princ)
) taoyi0727 发表于 2019-12-30 12:59
(defun c:TT1 (/ newmove)
(setvar "CMDECHO" 0)
(if *move*
厉害,搞定了 taoyi0727 发表于 2019-12-30 12:59
(defun c:TT1 (/ newmove)
(setvar "CMDECHO" 0)
(if *move*
2020下测试 乱码 xotoo 发表于 2019-12-31 13:51
2020下测试 乱码
可以用呀!上面动图就是用2020试的
taoyi0727 发表于 2019-12-31 14:19
可以用呀!上面动图就是用2020试的
不清楚怎么回事
我系统是WIN10 X64 1909
xotoo 发表于 2020-1-1 13:38
不清楚怎么回事
我系统是WIN10 X64 1909
可能你电话系统或是CAD的版本问题 你用的不是简体中文
只是猜测哈 taoyi0727 发表于 2019-12-30 12:59
(defun c:TT1 (/ newmove)
(setvar "CMDECHO" 0)
(if *move*
u撤回多了,就会出错,选择对象:; 错误: Automation 错误。 调用方法 Clear (接口 IAcadSelectionSet) 失败 能修改偏移后的颜色就更好了 双向批量偏移py
(defun c:plpy (/ CLOCKWISEP OFFSET KD SS N EN kd0)
(defun CLOCKWISEP (en / lw minp MaxP lst)
(setq lw (vlax-ename->vla-object en))
(vla-GetBoundingBox lw 'MinP 'MaxP)
(setq
minp (vlax-safearray->list minp)
MaxP (vlax-safearray->list MaxP)
lst(mapcar
(function
(lambda (x)
(vlax-curve-getParamAtPoint
lw
(vlax-curve-getClosestPointTo lw x)
)
)
)
(list minp
(list (car minp) (cadr MaxP))
MaxP
(list (car MaxP) (cadr minp))
)
)
)
(if (or
(<= (car lst) (cadr lst) (caddr lst) (cadddr lst))
(<= (cadr lst) (caddr lst) (cadddr lst) (car lst))
(<= (caddr lst) (cadddr lst) (car lst) (cadr lst))
(<= (cadddr lst) (car lst) (cadr lst) (caddr lst))
)
t
)
)
(initget 7 "W N S")
(setq kd0 (getkword "\n[向外偏移W/向内偏移N/双向偏移S]<W>"))
(if (= "" kd0)
(setq kd0 "W")
)
(initget 6)
(setq offset (getreal "\n[输入偏移距离]<50>"))
(if (null offset)
(setq offset 50)
)
(initget 7 "Y N")
(setq kd (getkword "\n[删除源对象<Y>/不删除源对象<N>]<N>:"))
(if (= kd "")
(setq kd "N")
)
(while (setq ss (ssget '((0 . "*polyline,arc,circle"))))
(repeat (setq n (sslength ss))
(setq en (ssname ss (setq n (1- n))))
(cond
((or (= "ARC" (cdr (assoc 0 (entget en))))
(= "CIRCLE" (cdr (assoc 0 (entget en))))
)
(cond ((= kd0 "W")
(vla-offset (vlax-ename->vla-object en) offset)
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
)
((= kd0 "N")
(vla-offset (vlax-ename->vla-object en) (- offset))
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
)
(t
(vla-offset (vlax-ename->vla-object en) offset)
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
(vla-offset (vlax-ename->vla-object en) (- offset))
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
)
)
)
(t
(cond ((= kd0 "W")
(if (CLOCKWISEP en)
(vla-offset (vlax-ename->vla-object en) (- offset))
(vla-offset (vlax-ename->vla-object en) offset)
)
(vla-put-Color (vlax-ename->vla-object (entlast)) 4)
)
((= kd0 "N")
(if (CLOCKWISEP en)
(vla-offset (vlax-ename->vla-object en) offset)
(vla-offset (vlax-ename->vla-object en) (- offset))
)
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
)
(t
(vla-offset (vlax-ename->vla-object en) offset)
(vla-put-Color (vlax-ename->vla-object (entlast)) 1)
(vla-offset (vlax-ename->vla-object en) (- offset))
(vla-put-Color (vlax-ename->vla-object (entlast)) 4)
)
)
)
)
(if (= kd "Y")
(entdel en)
)
)
)
(princ)
)
页:
[1]
2