(求助)各位大神能否帮小弟在以下的代码中把数值改一下
麻烦各位路过的大神帮忙看一下,代码现在的问题就是,输入的数值比如说:我输入2,但是最终偏移的两边尺寸是4 求大神帮忙改成,输入2,最终的两边偏移的尺寸还是2,谢谢大家了;双偏留中线
(defun c:SS( / en m n pon ename et ppp ouse )
(setvar "cmdecho" 1)
(COMMAND "OFFSET" PAUSE "")
;(prompt "\n Select Objects to Offset: ")
(setq en (ssget))
(setq m (sslength en ))
(setq n 0)
(setvar "cmdecho" 0)
(repeat m
(setq ename (ssname en n))
(setq et(entget ename))
(setq ppp (trans (cdr (assoc 10 et)) 0 1))
(setq ouse (list ename ppp))
(setq pon(trans (list (+ (car ppp) 1001) (- (cadr ppp) 1000) ) 0 1 ))
(command "offset" "" ouse pon "")
(setq ouse (list (entlast) (trans (cdr (assoc 10 (entget (entlast)))) 0 1)))
(command "offset" (* (getvar "offsetdist") 2 )ouse ppp "")
(command "offset" (/ (getvar "offsetdist") 2 ) "")
(setq n (+ n 1))
)
)
我小白,不是大神
(defun c:tt( / en m n pon ename et ppp ouse x)
(setvar "cmdecho" 1)
(COMMAND "OFFSET" PAUSE "")
;(prompt "\n Select Objects to Offset: ")
(setq en (ssget))
(setq m (sslength en ))
(setq n 0)
(setvar "cmdecho" 0)
(setq x (*(getvar "offsetdist")0.5))
(repeat m
(setq ename (ssname en n))
(setq et(entget ename))
(setq ppp (trans (cdr (assoc 10 et)) 0 1))
(setq ouse (list ename ppp))
(setq pon(trans (list (+ (car ppp) 1001) (- (cadr ppp) 1000) ) 0 1 ))
; (command "offset" "" ouse pon "")
(command "offset" x ouse pon "")
(setq ouse (list (entlast) (trans (cdr (assoc 10 (entget (entlast)))) 0 1)))
(command "offset" (* (getvar "offsetdist") 2 )ouse ppp "")
(command "offset" (/ (getvar "offsetdist") 2 ) "")
(setq n (+ n 1))
)
) ;双偏留中线
(defun c:SS( / en m n pon ename et ppp ouse )
(setvar "cmdecho" 1)
(COMMAND "OFFSET" PAUSE "")
;(prompt "\n Select Objects to Offset: ")
(setq en (ssget))
(setq m (sslength en ))
(setq n 0)
(setvar "cmdecho" 0)
(repeat m
(setq ename (ssname en n))
(setq et(entget ename))
(setq ppp (trans (cdr (assoc 10 et)) 0 1))
(setq ouse (list ename ppp))
(setq pon(trans (list (+ (car ppp) 1001) (- (cadr ppp) 1000) ) 0 1 ))
(command "offset" (*(getvar "offsetdist")0.5) ouse pon "")
(setq ouse (list (entlast) (trans (cdr (assoc 10 (entget (entlast)))) 0 1)))
(command "offset" (* (getvar "offsetdist") 2 )ouse ppp "")
(command "offset" (/ (getvar "offsetdist") 2 ) "")
(setq n (+ n 1))
)
)
努.力 发表于 2023-12-7 18:21
;双偏留中线
(defun c:SS( / en m n pon ename et ppp ouse )
(setvar "cmdecho" 1)
大神您好,您改后的确实可以实现我想要的,就是我这边试了一下,之前的是能实现批量的,现在改后就不能批量了,可不可以帮忙再改一下呢,谢谢您啦 努.力 发表于 2023-12-7 21:40
我小白,不是大神
(defun c:tt( / en m n pon ename et ppp ouse x)
(setvar "cmdecho" 1)
大神非常棒,能解决问题的就是大神,哈哈,您太谦虚了,谢谢您帮我解决了问题 (defun c:tt (/ d)
(if (and (or (and (setq d (getreal "\n输入双线间距<2>")) (/= d 0))
(setq d 2)
)
(setq d (* d 0.5))
(ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE")))
)
(vlax-for e (vla-get-activeselectionset (vla-get-ActiveDocument (vlax-get-acad-object)))
(vl-catch-all-apply 'vla-Offset (list e d))
(vl-catch-all-apply 'vla-Offset (list e (- d)))
)
)
(princ)
) bonny 发表于 2023-12-7 23:00
高效简洁,厉害 bonny 发表于 2023-12-7 23:00
谢谢大神的支持 确实简洁明了
页:
[1]