9
43
34
初来乍到
使用道具 举报
62
466
404
后起之秀
(defun c:test ( / addpolyline *error* pt p2 pts e _offset1 _offset2 _layer1 _layer2 ) ;|v set offset and layers here v|; (setq _offset1 2.) (setq _layer1 "0") (setq _offset2 (+ _offset1 0.5)) (setq _layer2 "Defpoints") ;|^ set offset and layers here ^|; (vl-load-com) (defun addpolyline ( pointslst layer closed flag / e ) (setq e (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length pointslst)) (cons 70 (if closed 1 0)) (cons 8 layer) (cons 43 0.0) ) (mapcar (function (lambda ( x ) (if (listp x)(cons 10 x) (cons 42 x) ) ) ) pointslst ) ) ) ) (if (and e flag) (vlax-ename->vla-object e) e ) ) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (if (and (setq pt (getpoint "\nSpecify starting point: ")) (setq pts (cons pt pts)) ) (while (setq p2 (getpoint pt "\nSpecify next point: ")) (and e (mapcar (function vla-delete) e)) ( (lambda ( p ) (setq e (apply (function append) (mapcar (function (lambda ( x y / o ) (setq o (vlax-invoke p 'Offset y)) (vla-put-layer (car o) _layer2) (append (vlax-invoke p 'Offset x) o) ) ) (list _offset1 (- _offset1)) (list _offset2 (- _offset2)) ) ) ) (vla-delete p) ) (addpolyline (setq pts (cons (setq pt p2) pts)) _layer1 nil t ) ) ) ))
(defun c:test ( / addpolyline *error* p pt p2 pts e _offset1 _offset2 _layer1 _layer2 ) ;|v set offset and layers here v|; (setq _offset1 2.) (setq _layer1 "0") (setq _offset2 0.5) (setq _layer2 "Defpoints") ;|^ set offset and layers here ^|; (vl-load-com) (defun addpolyline ( pointslst layer closed flag / e ) (setq e (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length pointslst)) (cons 70 (if closed 1 0)) (cons 8 layer) (cons 43 0.0) ) (mapcar (function (lambda ( x ) (if (listp x)(cons 10 x) (cons 42 x) ) ) ) pointslst ) ) ) ) (if (and e flag) (vlax-ename->vla-object e) e ) ) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (and (not *testcommandjustification*) (setq *testcommandjustification* "Center") ) (while (and (not pt) (not (prompt (strcat "\n\n** Current Justification: " *testcommandjustification* " **") ) ) (not (initget 1 "Justification")) (setq pt (getpoint "\nSpecify starting point or [Justification]: ")) ) (cond ( (listp pt) (setq pts (cons pt pts)) ) (t (initget 1 "Top Bottom Center") (setq *testcommandjustification* (getkword "\nSpecify justification [Top/Bottom/Center]: ") pt nil ) ) ) ) (while (and pts (setq p2 (getpoint pt "\nSpecify next point: "))) (and e (mapcar (function vla-delete) e)) ( (lambda ( p ) (cond ( (eq *testcommandjustification* "Center") (setq e (apply (function append) (mapcar (function (lambda ( x y / o ) (setq o (vlax-invoke p 'Offset y)) (vla-put-layer (car o) _layer2) (append (vlax-invoke p 'Offset x) o) ) ) (list (* 0.5 _offset1) (- (* 0.5 _offset1))) (list (+ (* 0.5 _offset1) _offset2) (- (+ (* 0.5 _offset1) _offset2)) ) ) ) ) (vla-delete p) ) ( (eq *testcommandjustification* "Bottom") (setq e (append (list p) (mapcar (function (lambda ( o la ) (setq p (car (vlax-invoke p 'offset o) ) ) (vla-put-layer p la) p ) ) (list _offset2 _offset1 _offset2) (list _layer1 _layer1 _layer2) ) ) ) ) ( (eq *testcommandjustification* "Top") (setq e (append (list p) (mapcar (function (lambda ( o la ) (setq p