Author Topic: Leaders  (Read 1664 times)

0 Members and 1 Guest are viewing this topic.

EJ48

  • Guest
Leaders
« on: February 21, 2018, 03:42:19 PM »
So I am looking for some advice on how to accomplish what I am trying to do in mapping. I am very new to making Lisp routines and still trying to get the language down but a pretty decent AutoCAD user. So what I am trying to accomplish is making a Lisp routine that will help me put leaders on other side of a entity to make organizing a large map faster. There is a way of using a already built in tool in autoCAD but I find it not very speedy. If anyone can help or point me in the right direction I would be so thankful. Hopefully learn more about building Lisp routines.

rw2691

  • Newt
  • Posts: 133
Re: Leaders
« Reply #1 on: February 25, 2018, 06:04:58 AM »
Since I rarely need to do this kind of leader, due to my vocation with CAD, I just handle it manually when it happens. But what is the "already built in tool in autoCAD" that you are using for it?

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Leaders
« Reply #2 on: February 25, 2018, 06:45:57 AM »
This may not be the application that you are looking for, since you may be doing dimensions, but it would be something that I would want.

Code: [Select]
(defun C:DAL () ;; by Alan Henderson @ AutoCAD Community Forum in 2004
      (setq ARRSIZ (getvar "TEXTSIZE"))
      (setq P1 (getpoint "\nPick 1st end of Double Arrowhead Line ? "))
      (if P1 (setq P2 (getpoint P1 "\nPick 2nd end of Double Arrowhead Line ? ")))
      (if (and P1 P2 (setq DD (distance P1 P2)) (< (* ARRSIZ 2) DD))
          (progn (setq P3 (polar P1 (angle P1 P2) ARRSIZ))
                 (setq P4 (polar P2 (angle P2 P1) ARRSIZ))
                 (command "PLINE" P1 "W" 0 (* ARRSIZ 0.5) P3 "W" 0 0 P4 "W" (* ARRSIZ 0.5) 0.0 P2 "")
                 )
          (cond ((not P1) (princ "\n1st point not selected."))
                ((not P2) (princ "\n2nd point not selected."))
                ((<= DD (* ARRSIZ)) (princ "\nPoints too close together."))
                )
          )
      (princ)
      )

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Leaders
« Reply #3 on: February 25, 2018, 07:16:02 AM »
Sorry, I didn't run that code before posting. It just sounded right, but it is supposed to do a single bar with opposing arrows at both ends. Unfortunately it did not even do that... only one end.

Nevertheless it is a good place to start. You could easily modify the code to have the kind of leader that you actually want.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Leaders
« Reply #4 on: February 25, 2018, 08:49:01 AM »
Try this...

Code: [Select]
(defun C:DAL () ;; by Alan Henderson @ AutoCAD Community Forum in 2004
                       ;; modified by rw2691 @TheSwamp in 2018
      (setq ARRSIZ (getvar "TEXTSIZE"))
      (setq P1 (getpoint "\nPick 1st end of Double-Arrowhead Line: "))
      (if P1 (setq P2 (getpoint P1 "\nPick 2nd end of Double-Arrowhead Line: ")))
      (if (and P1 P2 (setq DD (distance P1 P2)) (< (* ARRSIZ 2.5) DD)) ;; arriz was 2
          (progn (setq P3 (polar P1 (angle P1 P2) ARRSIZ))
                 (setq P4 (polar P2 (angle P2 P1) ARRSIZ))
                 (command "PLINE" P1 "W" 0 (* ARRSIZ 0.5) P3 "W" 0 0 P4 "W" (* ARRSIZ 0.5) 0.0 P2 "")
                 )
          (progn (setq P3 (polar P1 (angle P2 P1) (* ARRSIZ 2)))
                 (setq P4 (polar P2 (angle P1 P2) (* ARRSIZ 2)))
                 (command "pline" p3 "w" 0 0 p1 "W" 0 (* ARRSIZ 0.5) (polar P1 (angle P2 P1) ARRSIZ) "w" 0 0 "")
                 (command "pline" p4 "w" 0 0 p2 "W" 0 (* ARRSIZ 0.5) (polar P2 (angle P1 P2) ARRSIZ) "w" 0 0 "")
                 )       
                 ;; *** what it was as a cond function ***       
                 ;; (cond ((not P1) (princ "\n1st point not selected."))
                 ;;       ((not P2) (princ "\n2nd point not selected."))
                 ;;       ((<= DD (* ARRSIZ)) (princ "\nPoints too close together."))
                 ;;       )
          )
      (princ)
      )

It will draw a single bar with double arrows if there is room, or it will draw two bars with opposing arrows if there is not room. You can tweak the conditions to your liking. Your active Text Size controls the size of the arrows.

Rick
« Last Edit: February 25, 2018, 08:52:45 AM by rw2691 »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Leaders
« Reply #5 on: March 06, 2018, 08:36:12 AM »
Since no one else has commented, I am taking an initiative to talk about overall quality of drafting. In this case, relative to leader arrows. This might be deemed off-subject, but it looks like a good starting place to me.

The above code that I posted is good for its situation, sizing the arrow by text height, but it is an isolated remedy for the problem. In my opinion, a system wide method for all drafting would be more desirable.

Therefore, I want to suggest a different method for sizing leader arrows. Too often I see drawings that use a line width that is too fat for their linetype (dashes, dot-dashes, etc). Additionally, line width is an internal CAD control for the character strokes within text (about which, many are apparently unaware). So my practice is to employ line width as a printing control for lines, text, and leader arrows.

Subsequently, I use line color for sizing text lettering and arrow size, along with line width, when printing. I stick to the standard color set of gray, white, red, yellow, green, cyan, and blue. Gray (which I call silver to differ it from green by one letter codes) is the smallest character size that I want use, and blue is the largest. My choice is that any irregular color (per an outside drafter) is always printed as if it is red.

I also always work in model space, and line sizes are fixed by various "print.ctb" files (PrintBlack, PrintMono, etc), which can be saved from the custom line width and printing configuration menu. Then that file can be selected by the print GUI when printing.

When I see the colors I know how the line strokes will look when printed. Any text that is, say "red" or "green", will always have their specific widths, or for text, its character height and stroke width. I handle this with a LISP system of algorithms. When I print small text it is always readable, and when I print large text its strokes look natural for the height. By the same system all line types are equally legible, and arrow size is cosmetically correct.

It makes a good looking drawing, and more importantly, it allows all printed data (line types and text) to be recognizable and readable. Likewise, because it is a systematic control, every drawing has the same draftsmanship.

All of it is dynamic by the LTscale variable, CTB file, and color selections. The three combine to produce a natural drawing at any drafting scale.

Yet for myself, I go a little further. I draw lines and post text by layer assignment. I have also built a Text Editor that integrates the color controls. It is similar to the Mtext Editor, but rather than being an RTF type, it is an ASCII Editor. It can compose multiple lines, and each line is terminated with a color code (S,W,R,Y,G,C,B) for sizing all the text on that line. An example is as follows.

THIS IS AVERAGE SIZING\Y
THIS IS TINY SIZING\S
THIS IS THE LARGEST SIZE\B

The above (with the custom editor) will create a paragraph where each line has a different character height. It makes things look good, and an alternate mixed height within a line is not permitted. I just don't think that mixed height within a line is helpful for reading. Yet mixed line heights within a paragraph brings emphasis to important and secondary information. Such as with a Title Block (mine are always free-style paragraphs) where the title is large, and subordinate information is smaller.

You can employ the same method with Mtext. A LISP can create a file with NotePad; save it; then load and convert it to Mtext. I do this as well, for compatibility with other companies and their drafting practice... they frequently prefer Mtext.

For myself, it is always about having the same product all the time.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."