(initcommandversion 1),然后调用OFFSET命令
尝试使用0 1 2 3之类的值,直到您看到:
Specify offset distance or Erase/Layer] <500.0000>:
然后使用此简单检查确认其工作:
(and
(setq e (car (entsel)))
(setq p (getpoint))
(initcommandversion x); adjust x with the value
(command "_.OFFSET" 500 e "_non" p "E") ; offset the entity "e" on 500 units distance, oriented on the "p" side
) 你好,Grrr
不幸的是没有效果。
仍然显示错误消息。 大家好。。
谢谢你的代码员。。
你的代码和我想的一样。
但它不是偏移多段线。。我需要偏移线和多段线。
然后试试这个:
(defun C:test ( / *error* acDoc sUndo Svars R n oLst o ang)
(defun *error* (m)
(and sUndo (vla-EndUndoMark acDoc)) (redraw)
(and Svars (mapcar 'setvar (mapcar 'car Svars) (mapcar 'cdr Svars)))
(and m (print m))
(princ)
); defun *error*
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-EndUndoMark acDoc) (setq sUndo (not (vla-StartUndoMark acDoc)))
(setq Svars (mapcar (function (lambda (x) (cons x (getvar x)))) '("CLIPROMPTLINES" "PICKBOX" "CMDECHO")))
(and Svars (mapcar 'setvar (mapcar 'car Svars) '(0 12 0)))
(setvar 'errno 0) (redraw)
(while (/= 52 (getvar 'errno))
(initget 128 "Distance")
(setq R (entsel (strcat "\nSpecify side to offset or istance " (if oLst (vl-princ-to-string (reverse oLst)) "") " <exit>: ")))
(cond
((= 7 (getvar 'errno)) (princ "\nNothing selected.") (setvar 'errno 0))
( (= 'STR (type R))
(while (setq n (getreal (strcat "\nSpecify offset value from the curve " (if oLst (vl-princ-to-string (reverse oLst)) "") " <enter>: ")))
(princ (strcat "\nOffset values: " (vl-princ-to-string (reverse (setq oLst (cons n oLst))))))
)
(setq oLst (reverse oLst))
)
((and (vl-consp R) (eq 'ENAME (type (car R))) (setq o (vlax-ename->vla-object (car R))) (not (vlax-method-applicable-p o 'Offset)))
(princ "\nThis object can not be offseted.") (setq o nil)
)
((and o (eq (vla-get-Lock (vla-item (vla-get-Layers acDoc) (vla-get-Layer o))) :vlax-true))
(princ "\nThis object is on a locked layer.") (setq o nil)
)
((and o (not oLst))
(grdraw (cadr R) (vlax-curve-getClosestPointTo o (cadr R)) 1 7)
(setq ang (angle (vlax-curve-getClosestPointTo o (cadr R)) (cadr R)))
(while (setq n (getreal (strcat "\nSpecify offset value from the curve " (if oLst (vl-princ-to-string (reverse oLst)) "") " <enter>: ")))
(princ (strcat "\nOffset values: " (vl-princ-to-string (reverse (setq oLst (cons n oLst))))))
)
(and (vl-consp oLst) (apply 'and (mapcar 'numberp oLst)) (setvar 'errno 52))
)
( (and o (vl-consp oLst) (apply 'and (mapcar 'numberp oLst))) (setvar 'errno 52) )
(T nil)
); cond
); while
(and o ang oLst
(foreach x oLst
(vla-Offset o
(cond
( (= ang 0) x) ; Right
( (equal ang (/ PI 2.) 1e-2) (- x)) ; UP
( (equal ang PI 1e-2) x) ; Left
( (equal ang (* 1.5 PI) 1e-2) x) ; Down
( (< 0 ang (/ PI 2.)) (- x)) ; Right Up
( (< (/ PI 2.) ang PI) x) ; Left Up
( (< PI ang (* PI 1.5)) x) ; Left Down
( (< (* PI 1.5) ang (* PI 2)) (- x)) ; Right Down
); cond
); vla-Offset
); foreach ;(command "_.OFFSET" x (car R) "_non" (cadr R) "E")
); and
(and sUndo (vla-EndUndoMark acDoc))
(and Svars (mapcar 'setvar (mapcar 'car Svars) (mapcar 'cdr Svars)))
(redraw) (princ)
);| defun |; (vl-load-com) (princ)
由于方向问题,我真的尽量避免vla偏移。
就这么简单。
(defun c:test (/ s p)
(while (and (setq s (car (entsel "\nSelect line to offset :")))
(wcmatch (cdr (assoc 0 (entget s))) "LINE,*POLYLINE")
(setq p (getpoint "\nSpecify offset side :"))
)
(foreach x '(1.7 1.75)
(command "_.offset" x (ssadd s) "_non" p "")
)
)
(princ)
)
你好,Grrr
完美的
正在工作!非常感谢。 非常感谢你,塔尔瓦特。
现在它工作得很好。
不客气。 尽管我试图用(cond)解决这个问题,但偏移方向仍然是一个问题。也许其他人可以对此做出贡献。
您需要测试多段线方向-请参见本例。
页:
1
[2]