Author Topic: lisp request please - text to multileader  (Read 8167 times)

0 Members and 1 Guest are viewing this topic.

ira

  • Guest
Re: lisp request please - text to multileader
« Reply #15 on: August 29, 2017, 04:17:52 PM »
L2M lisp asks to pick as much text as you want to make part of the multileader, then asks you to pick a single line to turn into the leader part of the multileader.  So because the exploede leader I am trying to turn into a multileader is just a bunch of lines (not poly lines)it does not do what i want.  I think the lisp im asking to be modified is the way to go I just want to be able to delete the original exploded lines.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: lisp request please - text to multileader
« Reply #16 on: August 29, 2017, 04:48:24 PM »
Looking at the code, I just realized it is out of date, the attached code should work for you.

As for modifying the existing code, this SHOULD work; however, there may be circumstances where it won't work or will produce undesirable results since you would not have selected the lines at any point in time a crossing window would need to be used. An alternative approach is to select the lines and extract the start and end points from that and erase the lines, which is essentially what my code in the attached LISP does.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:am (/ newleader pt1 pt2 ss txt x w rjp-getbbwdth)
  2.   (defun rjp-getbbwdth (obj / out ll ur)
  3.     (vla-getboundingbox obj 'll 'ur)
  4.     (setq out (mapcar 'vlax-safearray->list (list ll ur)))
  5.     (distance (car out) (list (caadr out) (cadar out)))
  6.     )
  7.   (if (setq ss (ssget '((0 . "*TEXT"))))
  8.     (progn (setq txt (apply
  9.                        'strcat
  10.                        (mapcar
  11.                          'cdr
  12.                          (vl-sort
  13.                            (mapcar '(lambda (x)
  14.                                       (cons (vlax-get x 'insertionpoint)
  15.                                             (strcat (vlax-get x 'textstring) " ")
  16.                                             )
  17.                                       )
  18.                                    (setq
  19.                                      ss (mapcar
  20.                                           'vlax-ename->vla-object
  21.                                           (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  22.                                           )
  23.                                      )
  24.                                    )
  25.                            (function (lambda (y1 y2) (< (cadr (car y2)) (cadr (car y1))))
  26.                                      )
  27.                            )
  28.                          )
  29.                        )
  30.                  w (car (vl-sort (mapcar 'rjp-getbbwdth ss) '>))
  31.                  txt (apply 'strcat
  32.                             (mapcar 'chr (reverse (cdr (reverse (vl-string->list txt)))))
  33.                             )
  34.                  )
  35.            (mapcar 'vla-delete ss)
  36.            )
  37.     )
  38.   (if (and (setq pt1 (getpoint "\nSpecify leader arrowhead location: "))
  39.            (setq pt2 (getpoint pt1 "\nSpecify landing location: "))
  40.            )
  41.     (progn
  42. (set oPt1 (osnap pt1 "_nea")
  43.        oPt2 (osnap pt2 "_nea"))
  44. (if (/= oPt1 nil)
  45. (if (/= oPt2 nil)
  46. (command "._erase" "_c" oPt1 oPt2 "")
  47.  (command "._erase" oPt1 "")
  48. )
  49. )
  50.  
  51. (command "._MLEADER" pt1 pt2 "")
  52.            (setq newleader (vlax-ename->vla-object (entlast)))
  53.            (vla-put-textstring newleader txt)
  54.            (vla-put-textwidth newleader w)
  55.            )
  56.     )
  57.   (princ)
  58.   )
  59.  
« Last Edit: August 29, 2017, 04:52:41 PM by cmwade77 »