aawilds Posted October 18, 2017 Posted October 18, 2017 I have a bit a head scratcher. I want a lisp that when run I will be able to select the whole drawing and all the mleaders will automatically justify to the side that the leader and arrow is on. Occasionally our leaders get move and it is time consuming to change them individually. Any help would be greatly appreciated. Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Here you go .. does not check for locked layers. (defun c:foo (/ pts s) (if (setq s (ssget "_X" '((0 . "multileader")))) (foreach ml (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s))) (setq pts (vlax-invoke ml 'getleaderlinevertices 0)) (cond ((equal (car pts) (cadddr pts) 1e- (print "Vertical leader..")) ((< (car pts) (cadddr pts)) (vla-put-textjustify ml 1)) ((vla-put-textjustify ml 3)) ) ) ) (princ) ) (vl-load-com) Quote
aawilds Posted October 18, 2017 Author Posted October 18, 2017 Thank you so much . I have got to learn the visual lisp functions and how to use them, because that is far simpler then what I was trying to do by changing DXF codes. Quote
Grrr Posted October 18, 2017 Posted October 18, 2017 Nice startup, Ron! I just decided to experiment on what the heck is going on with your code, and played with this: (defun C:test ( / SS i ) (and (setq SS (ssget "_:L" '((0 . "MULTILEADER")))) (repeat (setq i (sslength SS)) (foo (ssname SS (setq i (1- i)))) ) ) (princ) ) (setq foo (lambda ( e / e o L pts ) (defun GroupByN ( n L / r ) (repeat n (and L (setq r (cons (car L) r))) (setq L (cdr L)) r) (if L (cons (reverse r) (GroupByN n L)) (list (reverse r))) ); defun GroupByN (cond ( (and ; (setq e (car (entsel "\nPick mleader: "))) (setq o (vlax-ename->vla-object e)) (setq L (GroupByN 3 (vlax-invoke o 'GetLeaderLineVertices 0))) (setq pts (list (car L)(last L))) ) (vl-some (function (lambda ( x / xf yf al ) (mapcar 'set '(xf yf al) x) (and (apply xf (append (mapcar 'car pts) (if (eq eq xf) (list 1e-1)))) (apply yf (append (mapcar 'cadr pts) (if (eq eq yf) (list 1e-1)))) (progn (vla-put-TextJustify o (eval al)) ; (alert (vl-symbol-name al)) T ) ) ); lambda ); function '( (eq > acAttachmentPointBottomCenter) ; OK (eq < acAttachmentPointTopCenter) ; OK (< eq acAttachmentPointMiddleLeft) ; NOT (> eq acAttachmentPointMiddleRight) ; NOT (< < acAttachmentPointBottomLeft) ; OK (> < acAttachmentPointBottomRight) ; OK (< > acAttachmentPointTopLeft) ; OK (> > acAttachmentPointTopRight) ; OK ); list ); vl-some ) ); cond (princ) ); lambda ); setq foo I assume that the first point of the 'GetLeaderLineVertices method is the first point of the leader line (closest vertex to the text content) whereas the last point represents the arrowhead point - is that correct? Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Thank you so much . I have got to learn the visual lisp functions and how to use them, because that is far simpler then what I was trying to do by changing DXF codes. Glad to help. DXF codes are nice but mleaders are much easier to manipulate via vla-* functions IMO. Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Nice startup, Ron! I just decided to experiment on what the heck is going on with your code, and played with this: (defun C:test ( / SS i ) (and (setq SS (ssget "_:L" '((0 . "MULTILEADER")))) (repeat (setq i (sslength SS)) (foo (ssname SS (setq i (1- i)))) ) ) (princ) ) (setq foo (lambda ( e / e o L pts ) (defun GroupByN ( n L / r ) (repeat n (and L (setq r (cons (car L) r))) (setq L (cdr L)) r) (if L (cons (reverse r) (GroupByN n L)) (list (reverse r))) ); defun GroupByN (cond ( (and ; (setq e (car (entsel "\nPick mleader: "))) (setq o (vlax-ename->vla-object e)) (setq L (GroupByN 3 (vlax-invoke o 'GetLeaderLineVertices 0))) (setq pts (list (car L)(last L))) ) (vl-some (function (lambda ( x / xf yf al ) (mapcar 'set '(xf yf al) x) (and (apply xf (append (mapcar 'car pts) (if (eq eq xf) (list 1e-1)))) (apply yf (append (mapcar 'cadr pts) (if (eq eq yf) (list 1e-1)))) (progn (vla-put-TextJustify o (eval al)) ; (alert (vl-symbol-name al)) T ) ) ); lambda ); function '( (eq > acAttachmentPointBottomCenter) ; OK (eq < acAttachmentPointTopCenter) ; OK (< eq acAttachmentPointMiddleLeft) ; NOT (> eq acAttachmentPointMiddleRight) ; NOT (< < acAttachmentPointBottomLeft) ; OK (> < acAttachmentPointBottomRight) ; OK (< > acAttachmentPointTopLeft) ; OK (> > acAttachmentPointTopRight) ; OK ); list ); vl-some ) ); cond (princ) ); lambda ); setq foo I assume that the first point of the 'GetLeaderLineVertices method is the first point of the leader line (closest vertex to the text content) whereas the last point represents the arrowhead point - is that correct? From my test, the first point is the closest to the arrow. Quote
Grrr Posted October 18, 2017 Posted October 18, 2017 From my test, the first point is the closest to the arrow. Short test confirmed this: (and (setq p ((lambda (L) (list (car L) (cadr L) (caddr L))) (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'GetLeaderLineVertices 0))) (entmakex (list (cons 0 "POINT") (cons 62 1) (cons 10 p))) ) Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.