下面是该代码的快速修改。您需要按顺序拾取轮廓段,然后选择要偏移的项目。
- (defun c:foo (/ _pts lm:clockwise-p a b c e o s)
- ;; Clockwise-p - Lee Mac
- ;; Returns T if p1,p2,p3 are clockwise oriented
- (defun lm:clockwise-p (p1 p2 p3)
- ((lambda (n) (< (car (trans p2 0 n)) (car (trans p1 0 n)))) (mapcar '- p1 p3))
- )
- (defun _pts (e) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget e))))
- (while (setq e (car (entsel "\nPick profile segments in order: ")))
- (setq c (cons (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) c))
- )
- (setq b 0)
- (if (and c (setq s (ssget '((0 . "lwpolyline") (-4 . ">") (90 . 2)))))
- (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
- (setq a (_pts e))
- (setq a (cond ((lm:clockwise-p (car a) (cadr a) (caddr a)) -)
- (+)
- )
- )
- (foreach d (reverse c)
- ;; vlax-invoke will return a list of objects rather than an array
- (setq o (car (vlax-invoke (vlax-ename->vla-object e) 'offset (a (setq b (+ b d))))))
- ;; Use entmod so layer does not need to exist
- ;; (entmod (append (entget (vlax-vla-object->ename o)) (list (cons 8 d))))
- )
- )
- )
- (princ)
- )
|