Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Leader with no text.

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
gregmcl
1631 Views, 6 Replies

Leader with no text.

Hi,

 

I'm trying to create a leader with no attachments. Code below. But I can't seem to shut of the Annotation Dialog.

(setvar "cmddia" 0)

(vl-cmdf ".Qleader"     "S"     "A"     "N"     pt1 pt2   ""  )

 

Also I am trying to create a leader with text that is aligned and above the leader line. Any suggestions ?

 

Thanks for any help in advanced.

 

Greg

6 REPLIES 6
Message 2 of 7
alanjt_
in reply to: gregmcl

Use the LEADER command over QLEADER.

 

Here's a simple one I use from time to time for a single segment directional arrow. Should be more than enough information from which you can glean...

 

(defun c:Arrow (/ _group _dist lastentity p1 p2 ent obj gr coords pt)
  ;; Draw quick arrow
  ;; Alan J. Thompson, 03.13.11

  (vl-load-com)

  (defun _group (l)
    (if (caddr l)
      (cons (list (car l) (cadr l) (caddr l)) (_group (cdddr l)))
    )
  )

  (defun _dist (a b) (distance (list (car a) (cadr a)) (list (car b) (cadr b))))

  (setq lastentity (entlast))
  (if (and (setq p1 (getpoint "\nSpecify first point: "))
           (setq p2 (getpoint p1 "\nSpecity next point: "))
           (vl-cmdf "_.leader" "_non" p2 "_non" p1 "" "" "_N")
           (not (equal lastentity (setq ent (entlast))))
           (setq obj (vlax-ename->vla-object ent))
      )
    (while (eq 5 (car (setq gr (grread T 15 0))))
      (redraw)
      (grdraw (cadr gr)
              (trans (vlax-curve-getClosestPointTo ent (setq pt (trans (cadr gr) 1 0))) 0 1)
              3
              -1
      )
      (if
        (equal
          (last (setq coords (_group (vlax-get obj 'Coordinates))))
          (car (vl-sort coords (function (lambda (a b) (< (_dist a pt) (_dist b pt))))))
        )
         (vlax-put obj 'Coordinates (apply (function append) (reverse coords)))
      )
      (grdraw (cadr gr) (trans (car coords) 0 1) 1 -1)
    )
  )
  (redraw)
  (princ)
)

 

Message 3 of 7
Kent1Cooper
in reply to: gregmcl


@gregmcl wrote:

.... 

I'm trying to create a leader with no attachments. ... But I can't seem to shut of the Annotation Dialog. ....


Wouldn't this do for that part of the question, if you're looking for a single-segment leader?

 

(command "_.leader" pause pause "" "" "_none")

 

Or, if you already have the points established:
 

(command "_.leader" pt1 pt2 "" "" "_none")

 

Works for me back in ol' 2004, but maybe some things have changed.

Kent Cooper, AIA
Message 4 of 7
Kent1Cooper
in reply to: gregmcl


@gregmcl wrote:

.... 

Also I am trying to create a leader with text that is aligned and above the leader line. Any suggestions ?

....


For that part, try these.  They assume you want whatever the current Text Style and height are, and that the Style has a defined height of 0.  They center the text above the midpoint of the Leader line, with its insertion point half the text height from the Leader.  Make adjustments for other situations.

 

If you want to type the Text content in dynamically on-screen after the Leader is drawn:

 

(defun C:TEST ()
  (command
    "_.leader"
    (setq p1 (getpoint))
    (setq p2 (getpoint p1))
    "" ""
    "_none"
  )
  (if (< (/ pi 2) (angle p1 p2) (* pi 1.5)); find more upright direction
    (setq ang (angle p2 p1))
    (setq ang (angle p1 p2))
  )
  (command
    "_.dtext"
    "_c"
    "_none"
    (polar
      (mapcar '/ (mapcar '+ p1 p2) '(2 2 2)); midpoint of Leader
      (+ ang (/ pi 2))
      (/ (getvar 'textsize) 2); offset for center point of Text
    )
    "" ; current height, assuming 0-height Style
    (/ (* ang 180) pi)
  )
)
 
If you have saved the Text content as a variable that you want fed in:

 

(defun C:TEST ()
  (command
    "_.leader"
    (setq p1 (getpoint))
    (setq p2 (getpoint p1))
    "" ""
    "_none"
  )
  (if (< (/ pi 2) (angle p1 p2) (* pi 1.5))
    (setq ang (angle p2 p1))
    (setq ang (angle p1 p2))
  )
  (command
    "_.text"
    "_c"
    "_none"
    (polar
      (mapcar '/ (mapcar '+ p1 p2) '(2 2 2))
      (+ ang (/ pi 2))
      (/ (getvar 'textsize) 2)
    )
    ""
    (/ (* ang 180) pi)
    YourTextContentVariableName
  )
)
 

And if you've saved the points to variables beforehand, just substitute those in place of the (setq p1...) and (setq p2...) lines.

Kent Cooper, AIA
Message 5 of 7
alanjt_
in reply to: Kent1Cooper

Yeah Kent, mine has a bit of fluff since I used it as a demo to show how one could reverse the direction of the leader with a bit of grread. I did another example that allowed for multiple vertices.

 

I just figured it was good enough for the OP to dig through and hack out what he/she wanted.

Message 6 of 7
gregmcl
in reply to: alanjt_

Thanks Fellows.

Message 7 of 7
Kent1Cooper
in reply to: gregmcl


@gregmcl wrote:

Thanks Fellows.


You're welcome.  Since the current Text Style and height can change, it's probably better to include the desired values right in the code than to require the User to have them right:

 

....

  (command
    "_.text" ; [or "_dtext" in type-it-on-screen version]

    "_style" "YourTextStyleName"
    "_c"
    "_none"
    (polar
      (mapcar '/ (mapcar '+ p1 p2) '(2 2 2))
      (+ ang (/ pi 2))
      (/ (getvar 'textsize) 2)
    )
    YourTextHeight ; omit this line if YourTextStyleName has a fixed height
    (/ (* ang 180) pi)

....

 

You could also force the right Dimension Style for the Leader part.  But if you want it usable with any Text Style or height the User wants, or any Leader style, don't make those changes, and leave it to the User to have things set as they want.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost