很好,使用(vlax invoke’offset)将绘制对象,并返回一个列表,其中包含由命令创建的所有对象的名称,如下所示:
- (#<VLA-OBJECT IAcadLWPolyline 01ece35c> #<VLA-OBJECT IAcadLWPolyline 01ed026c> #<VLA-OBJECT IAcadLWPolyline 01ed02bc>)
基于CAB中的LISPhttp://www.theswamp.org/index.php?topic=2899.5;wap2,我使用了以下内容:
- (defun c:offset (/ ename dist err_obj vobj enew)
- (setq enew (entlast))
- (vl-load-com)
- (and
- (null (initget 7))
- (setq dist (getdist "\nEnter offset distance: "))
- (while (setq ent (entsel "\nSelect object to offset."))
- (if (and (setq vobj (vlax-ename->vla-object (car ent)))
- (vlax-method-applicable-p vobj "Offset")
- )
- (progn
-
- (if (vl-catch-all-error-p
- (vl-catch-all-apply 'vlax-invoke
- (list vobj 'Offset (- dist))))
- (prompt "\nNegative distance failed.")
- (setq enew (vlax-invoke vobj 'offset (- dist))); This makes the offset done twice, must put it inside the error catch, but how??
- )
- )
- (prompt "\n*** Can not offset that object, try again. ***")
- )
- )
- )
- (princ)
- )
- (princ)
所以所要做的就是修改,使其从“vlax调用”中获取列表,而不是再次要求选择下一个对象,这应该很容易。然而,它绘制了两次偏移量(显然,因为它在“if”中有两个要偏移的调用),所以我正在考虑放置
- (setq enew (vlax-invoke vobj 'offset (- dist)))
线路内部捕捉到错误,但无法使其工作。我以后再谈,因为已经太晚了。
感谢所有的帮助和评论!! |