Jump to content

Legends Lisp


Steven P

Recommended Posts

Good afternoon,

 

Just wondering if anyone has a LIPS or similar that can make a legend??

 

For example to scroll through all the layers one by one, draw a line (anywhere, they can be moved later) with attributes 'by-layer' and write the layer name next to it, then onto the next one and draw the line below it with its name and so on.

 

(I have a plan with 30 or so layers which needs a legend, the layers are all nicely named "cable" "Pipe" etc but can be edited later and can be used directly)

 

 

Thanks

Link to comment
Share on other sites

There is a program called LayerLegend... a lisp.. will search for it tomorrow..

 

Not mine but does the job..

(defun c:ll (/ osm ortho clayer celtype cecolor start-point line-length text-height *error*)
(defun *error* (msg)
(setvar "osmode" osm)
(setvar "orthomode" ortho)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(setvar "cecolor" cecolor)
(princ msg)
)

(defun mfp (pt pa) (list (+ (car pt) (car pa)) (+ (cadr pt) (cadr pa)) (+ (caddr pt) (caddr pa))))


(setq osm (getvar "osmode"))
(setq ortho (getvar "orthomode"))
(setq clayer (getvar "clayer"))
(setq celtype (getvar "celtype"))
(setq cecolor (getvar "cecolor"))
(setq start-point (getpoint "\nSelect point to start legend: "))
(setvar "orthomode" 1)
(setq line-length (getdist start-point "\nEnter length of line or click end point: "))
(setq text-height (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
(setvar "osmode" 0)
(setvar "celtype" "ByLayer")
(setvar "cecolor" "ByLayer")
(command "_line" start-point (mfp start-point (list line-length 0 0)) "")
(command "-text" (mfp start-point (list 6 -0.25 0)) "0" (getvar "clayer"))
(while (setq lay (cdadr (tblnext "layer" (not lay)))); make list of Layer names
 (setq laylist (cons lay laylist))
)
(foreach
 lay
 (vl-sort laylist '<); sorted alphabetically
 (setvar 'clayer lay)
 (setq start-point (mfp start-point (list 0 (- 0 (+ text-height -1)) 0)))
 (command
   "_line" start-point (mfp start-point (list line-length 0 0)) ""
   "-text" (mfp start-point (list 6 -0.25 0)) "0" lay ; [could leave (getvar 'clayer) in there]
 )
); foreach


(setvar "osmode" osm)
(setvar "orthomode" ortho)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(setvar "cecolor" cecolor)
)

Edited by Aftertouch
Link to comment
Share on other sites

There is a program called LayerLegend... a lisp.. will search for it tomorrow..

 

I downloaded such thing long time ago - maybe it was this. Atleast the result is the same and prompts for a selection set like in the video (so it has to be that one).

Anyway when Lee Mac has a suggestion consider it as a top priority, since his codes always work flawlessly and are bug/error-free.

Link to comment
Share on other sites

Thanks,

 

Lee that was exactly what I was looking for, and I have no idea why I didn't check your website first - it may be an old routine but it does what it says. Brilliant as always.

 

 

Grrrr, thanks as well, I tried Lees code first and it works but I will give yours a go later this morning too (more than one way to do something is always good)

Link to comment
Share on other sites

  • 2 months later...

New to the forums...and have a related question...I have a file (that I inherited) that has dozens of line types, some used, some unused. I would like to automate making a "linetype legend" with the name of all of the linetypes and and an associated line with that linetype applied (very similar to Lee Mac's layer legend, just with linetypes instead of layers). I've scoured the web, and am coming up dry. Is there a lisp (or acad function) for that that I am just not finding? if not, what would it take to write one? ...I use/tinker with lisp routines but am no coder... and manually assigning hundreds of linetypes seems overly tedious. Thanks for your thoughts!

Link to comment
Share on other sites

I would like to automate making a "linetype legend" with the name of all of the linetypes and and an associated line with that linetype applied (very similar to Lee Mac's layer legend, just with linetypes instead of layers).

 

Please try the following modification of my Layer Legend program:

[color=GREEN];; Linetype Legend  -  Lee Mac[/color]
[color=GREEN];; Generates a set of lines at a user-specified point and of a given length[/color]
[color=GREEN];; with associated linetype text sorted alphabetically for every linetype in a drawing.[/color]

([color=BLUE]defun[/color] c:linetypelegend ( [color=BLUE]/[/color] ang bpt hgt ltp len lst ocs )    
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] bpt ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify point for legend: "[/color]))
           ([color=BLUE]progn[/color]
               ([color=BLUE]initget[/color] 6)
               ([color=BLUE]setq[/color] len ([color=BLUE]getdist[/color]  [color=MAROON]"\nSpecify line length: "[/color] bpt))
           )
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]while[/color] ([color=BLUE]setq[/color] ltp ([color=BLUE]tblnext[/color] [color=MAROON]"ltype"[/color] ([color=BLUE]null[/color] ltp)))
               ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 ltp)) lst))
           )
           ([color=BLUE]setq[/color] ocs ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color])
                 ang ([color=BLUE]angle[/color] '(0.0 0.0) ([color=BLUE]trans[/color] ([color=BLUE]getvar[/color] 'ucsxdir) 0 ocs [color=BLUE]t[/color]))
                 hgt ([color=BLUE]getvar[/color] 'textsize)
           )
           ([color=BLUE]foreach[/color] ltp ([color=BLUE]acad_strlsort[/color] lst)
               ([color=BLUE]entmake[/color]
                   ([color=BLUE]list[/color]
                      '(000 . [color=MAROON]"LINE"[/color])
                      '(008 . [color=MAROON]"0"[/color])
                      '(039 . 0.0)
                      '(062 . 256)
                      '(370 . -1)
                       ([color=BLUE]cons[/color] 006 ltp)
                       ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] bpt 1 0))
                       ([color=BLUE]cons[/color] 011 ([color=BLUE]trans[/color] ([color=BLUE]cons[/color] ([color=BLUE]+[/color] ([color=BLUE]car[/color] bpt) len) ([color=BLUE]cdr[/color] bpt)) 1 0))
                   )
               )
               ([color=BLUE]entmake[/color]
                   ([color=BLUE]list[/color]
                      '(000 . [color=MAROON]"TEXT"[/color])
                      '(006 . [color=MAROON]"BYLAYER"[/color])
                      '(008 . [color=MAROON]"0"[/color])
                      '(039 . 0.0)
                      '(062 . 256)
                      '(370 . -1)
                      '(072 . 0)
                      '(073 . 1)
                       ([color=BLUE]cons[/color] 001 ltp)
                       ([color=BLUE]cons[/color] 007 ([color=BLUE]getvar[/color] 'textstyle))
                       ([color=BLUE]cons[/color] 040 hgt)
                       ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] bpt 1 ocs))
                       ([color=BLUE]cons[/color] 011 ([color=BLUE]trans[/color] bpt 1 ocs))
                       ([color=BLUE]cons[/color] 050 ang)
                       ([color=BLUE]cons[/color] 210 ocs)
                   )
               )
               ([color=BLUE]setq[/color] bpt ([color=BLUE]list[/color] ([color=BLUE]car[/color] bpt) ([color=BLUE]-[/color] ([color=BLUE]cadr[/color] bpt) ([color=BLUE]*[/color] 1.75 hgt)) ([color=BLUE]caddr[/color] bpt)))
           )
       )
   )
   ([color=BLUE]princ[/color])
)

Link to comment
Share on other sites

Please try the following modification of my Layer Legend program:

...

 

You make it look so easy!

 

BTW you could collect these into a new application (with DCL) :

(LM:Legend legendtype)

; legendtype:
"APPID"    ; ?
"BLOCK"    ; <<
"DIMSTYLE" ; <<
"LAYER"    ; <<
"LTYPE"    ; <<
"STYLE"    ; <<
"UCS"      ; ?
"VIEW"     ; ?
"VPORT"    ; ?

 

Just throwing off an idea. o:)

Link to comment
Share on other sites

Wow...that was fast. It seems to do the trick. That just saved hours of my life.

I'll have to fiddle with spacing to get it do display how I need it to, but this is great. Thanks amillion

Link to comment
Share on other sites

You make it look so easy!

 

Thanks :)

 

Wow...that was fast. It seems to do the trick. That just saved hours of my life.

 

You're welcome! - It wasn't too significant a modification to the existing program. ;)

 

I'll have to fiddle with spacing to get it do display how I need it to, but this is great. Thanks a million

 

For the spacing, simply change the 1.75 to a value of your choosing.

Link to comment
Share on other sites

There is a couple of posts elsewhere theswamp etc same subject Blocks linetypes layers, one thing if use tblnext will it not do every linetype wether used or not ? This may be an extra option to only do used.

Link to comment
Share on other sites

  • 4 years later...

anybody knows how to make a program similar to this one you comment on this post, but that additionally can calculate the area and being put next to the the legend? thank you in advanced!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...