新不由己 发表于 2018-5-12 23:07:58

求高手帮改改,偏移为当前图层

(defun c:11 (/ getds obj)
(vl-load-com)
(setvar 'cmdecho 0)
(initget 2)
(setq getds (getdist "\n输入偏移距离<可直接量取>:"))
(if (ssget ":s" '((0 . "Arc,Circle,Ellipse,*Line")))
    (vlax-for obj (vla-get-activeselectionset
      (vla-get-activedocument (vlax-get-acad-object))
      )
      (vla-offset obj getds)
      (vla-offset obj (* getds -1))
    )
    (vlax-release-object obj)
)
(if (not (getpoint "\n按鼠标左键不删除源对象 <空格删除>"))
    (command "_.ERASE" (ssget "p") "")
    )
(princ)
)

Linhay 发表于 2018-5-15 18:56:39

(command "offset" "l" "c")

434939575 发表于 2018-5-13 09:22:38

(defun c:11 (/ getds obj)
(vl-load-com)
(setq lay (getvar "CLAYER"))
(setvar 'cmdecho 0)
(initget 2)
(setq getds (getdist "\n输入偏移距离<可直接量取>:"))
(if (ssget ":s" '((0 . "Arc,Circle,Ellipse,*Line")))
   (progn
   (vlax-for obj (vla-get-activeselectionset
      (vla-get-activedocument (vlax-get-acad-object))
      )
   (foreach x (list getds(* getds -1))
       (vla-offset obj x )
       (vla-put-layer (vlax-ename->vla-object (entlast)) lay)
       )
      
    )


   )
    (vlax-release-object obj)
)
(if (not (getpoint "\n按鼠标左键不删除源对象 <空格删除>"))
    (command "_.ERASE" (ssget "p") "")
    )
(princ)
)

edata 发表于 2018-5-13 17:48:19

借用二楼代码简单修改。
(defun c:11 (/ getds obj RetVal objarray x k)
(vl-load-com)
(setq lay (getvar "CLAYER"))
(setvar 'cmdecho 0)
(initget 2)
(setq getds (getdist "\n输入偏移距离<可直接量取>:"))
(if (ssget ":s" '((0 . "Arc,Circle,Ellipse,*Line")))
    (progn
      (vlax-for        obj (vla-get-activeselectionset(vla-get-activedocument(vlax-get-acad-object)))
        (foreach x (list getds (* getds -1))          
          (setq RetVal(vl-catch-all-apply 'vla-offset (list obj x )))
          (if (vl-catch-all-error-p RetVal)
          (princ (vl-catch-all-error-message RetVal))
          (progn
              (setq objarray (vlax-variant-value RetVal))
              (foreach k (vlax-safearray->list objarray)
                (vla-put-layer k lay)
                )
              )
          )          
          )
        )
      )
    (vlax-release-object obj)
)
(if (not (getpoint "\n按鼠标左键不删除源对象 <空格删除>"))
    (command "_.ERASE" (ssget "p") "")
)
(princ)
)

新不由己 发表于 2018-5-15 18:16:15

edata 发表于 2018-5-13 17:48
借用二楼代码简单修改。

:handshake

新不由己 发表于 2018-5-15 18:16:37

434939575 发表于 2018-5-13 09:22


:handshake

大尾巴狼 发表于 2018-9-5 17:03:29

Linhay 发表于 2018-5-15 18:56
(command "offset" "l" "c")

就这么简单:lol
页: [1]
查看完整版本: 求高手帮改改,偏移为当前图层