woodman78 发表于 2022-7-5 19:43:04

帮助学习Leemac例程:

我从LeeMac那里找到了这段代码,但当我运行它并选择一条多段线时,什么都没有发生。谁能告诉我为什么?
 
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/polyline-offset-trim-and-erase/td-p/4503753

Commandobill 发表于 2022-7-5 20:39:31

你是说这个?

(defun c:offout ( / e s )
   (if (setq s (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
       (vl-catch-all-apply 'vla-offset
         (list (vlax-ename->vla-object (setq e (ssname s 0)))
               (if
                   (LM:listclockwise-p
                     (mapcar 'cdr
                           (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget e))
                     )
                   )
                   -0.75
                  0.75
               )
         )
       )
   )
   (princ)
)

;; List Clockwise-p-Lee Mac
;; Returns T if the point list is clockwise oriented

(defun LM:ListClockwise-p ( lst )
   (minusp
       (apply '+
         (mapcar
               (function
                   (lambda ( a b )
                     (- (* (car b) (cadr a)) (* (car a) (cadr b)))
                   )
               )
               lst (cons (last lst) lst)
         )
       )
   )
)
(vl-load-com) (princ)
 
它为我而跑。虽然,李的标准不是很有活力。

Lee Mac 发表于 2022-7-5 21:13:01

 
该程序将选定的闭合四顶点多段线向外偏移0.75个单位,因此,在您的情况下,您选择的多段线要么小于该偏移距离,要么足够大,以至于在放大之前无法察觉该偏移。
 
页: [1]
查看完整版本: 帮助学习Leemac例程: