Author Topic: Create a legend from block in the DWG?  (Read 6328 times)

0 Members and 1 Guest are viewing this topic.

hornet 103

  • Guest
Create a legend from block in the DWG?
« on: March 31, 2006, 09:30:05 AM »
I would like to build up a graphical legend from the blocks that are within the drawing, this would match the list which is produced
from the attribute extraction command.
It would be fantastic if the graphical blocks were copied, scaled to match the text in the list and then placed along side the line of
text that the graphic relates too.

Is the above possible? :-)

any offers

Hornet 103


<changed tritle to be more discriptive>
« Last Edit: March 31, 2006, 09:36:47 AM by CAB »

Crank

  • Water Moccasin
  • Posts: 1503
Re: Create a legend from block in the DWG?
« Reply #1 on: March 31, 2006, 12:32:50 PM »
Do you mean a table with blocks in it?
Vault Professional 2023     +     AEC Collection

whdjr

  • Guest
Re: Create a legend from block in the DWG?
« Reply #2 on: March 31, 2006, 12:41:28 PM »
This doesn't create a Legend but it might be usefull.
Link

Serge J. Gianolla

  • Guest
Re: Create a legend from block in the DWG?
« Reply #3 on: March 31, 2006, 08:07:32 PM »
I would like to build up a graphical legend from the blocks that are within the drawing, this would match the list which is produced
from the attribute extraction command.
It would be fantastic if the graphical blocks were copied, scaled to match the text in the list and then placed along side the line of
text that the graphic relates too.

Is the above possible? :-)

any offers

Hornet 103


<changed tritle to be more discriptive>

If you can put your hands on a book titled MAXIMISING AutoCAD: Inside AutoLISP, by J. Smith and R. Gesner published circa 1990. Chapter 7-29 deals with a code reading blocks attributes to generate a legend. It should not be to difficult to adapt. Possibly the code is available on the net doing a search on New Riders Publishing.
HTH

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create a legend from block in the DWG?
« Reply #4 on: March 31, 2006, 08:45:16 PM »

If you can put your hands on a book titled MAXIMISING AutoCAD: Inside AutoLISP, by J. Smith and R. Gesner published circa 1990.  ...............

I had my copy returned to me this week ... after 6 years separation .. < along with 5 others > great learning book Serge !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

RbtDanforth

  • Guest
Re: Create a legend from block in the DWG?
« Reply #5 on: March 31, 2006, 08:46:57 PM »
I wrote this little ditty many years ago for v11, I think, but it would read a space delimited text file and fill out the Bom.
Code: [Select]
(defun ABOM_err (st)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active
    (if (/= st "Function cancelled")
    (princ (strcat "\nError: " st))
  )
  (if (= (type FLN) 'FILE)
    (close FLN)
  )
  (setq FLN nil)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)
)


(defun C:ABOM (/ FLN B B1 B2 B3 TB SC olderr);
    (Setvar "CMDECHO" 0)
       (setq olderr *error*
        *error* BINS_err)
     (SETQ FLN (open (getstring "Bom list [inc ext] ?  ")"r")
           B (READ-LINE FLN)
           TB (ENTGET(SSNAME (SSGET "X"(LIST(CONS 2 "SHEET*")))0))
           SC (CDR (ASSOC 41 TB))
           ST (GETPOINT "\nSTARTPOINT\t")
           NUM(GETINT "\nSTART INT\t")
                   )
            (WHILE B (PROGN (SETQ B1 (SUBSTR B 4 2)
                                  B2 (SUBSTR B 8 42)
                                  B3 (SUBSTR B 51 10)
                                  )
                   (command ".insert" "BOM" "R" 0 "S" SC ST NUM  B1 B2 B3 )
                   (SETQ B (READ-LINE FLN)
                         NUM (1+ NUM)
                         ST (POLAR ST (/ PI 2)(* 0.209 SC))
                   )
                       ) ); WH
          (CLOSE FLN)  (Setvar "CMDECHO" 1)
(setq *error* olderr)
    'dUN
)



I used an errror trap here because otherwise it would leave the file open, if it died mid stream. You will note some distances etc that were specific to the block and attributes used.

I had it tied to another routine that would write script files and add the bom to each sheetin a semi auto fashion but it has been too long to remember all the details.

If I find the routine that made the lists from the Boms I will post it.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create a legend from block in the DWG?
« Reply #6 on: March 31, 2006, 08:52:35 PM »
hornet 103 ,
can you be a little more specific regarding your requirements.

Do you actually want the attributes ?
Do you want to extract one block's attributes, ar several. ?
is any additional processing of the data required or use the raw data. ?
Which Acad Version ie; do you have the 'Table' graphical object available ?
If so, have you played with fields ?


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Serge J. Gianolla

  • Guest
Re: Create a legend from block in the DWG?
« Reply #7 on: March 31, 2006, 09:02:21 PM »

If you can put your hands on a book titled MAXIMISING AutoCAD: Inside AutoLISP, by J. Smith and R. Gesner published circa 1990.  ...............

I had my copy returned to me this week ... after 6 years separation .. < along with 5 others > great learning book Serge !

Somehow I knew you would. I did notice some of it in partial codes :-)
I can't remember what was the story behind but I have 2 copies. You should have asked me one, you ain't too far! :wink:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create a legend from block in the DWG?
« Reply #8 on: March 31, 2006, 09:05:07 PM »
... or were you after this sort of thing ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create a legend from block in the DWG?
« Reply #9 on: March 31, 2006, 09:08:38 PM »
.....  I did notice some of it in partial codes :-)
 .....
Yep, Rusty Gesner , Tony Tanzillo and Reni Urban have a lot to answer for  :lol:
« Last Edit: March 31, 2006, 09:33:38 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

RbtDanforth

  • Guest
Re: Create a legend from block in the DWG?
« Reply #10 on: March 31, 2006, 11:32:32 PM »
I haven't worked out how to post an image here , but I created my electrical legend f'rinstance out of all the blocks that I expected to use .

Remembering the names of the blocks is a pain I don't want, so I wrote this
Code: [Select]
(DEFUN C:NAMB ( / A B)
           (SETQ A (ENTGET (CAR (ENTSEL "PICK BLOCK...")))
                 B (CDR (ASSOC 2 A)) C (GETPOINT "TEXT START...")
                 )
             (COMMAND "TEXT" "MC" C "" "" B  )
)

I just pick the block and the space next to it and it spits out the name of the block. I kick all those names into defpoints layer and any draftsman can read them but they don't show in the print.

I suppose you could name your blocks by a stock number say and have the print read the actual name as well.

But as I insert the legend unexploded, I added another twist with this code
Code: [Select]
(defun C:In (/ a s r ax)
(setq A(ENTGET (CAR (nENTSEL "\tPICK name?..")))
      AX(CDR(ASSOC 1 A))
          )(PRINC AX)
(while ax
(command ".insert" AX "s" 1 "r" PAUSE PAUSE )
)
)

Allows just picking a name off the list and inserting till you quit doing so. bailing with a ^c is kinda ugly :ugly:but it works and is very quick.

Serge J. Gianolla

  • Guest
Re: Create a legend from block in the DWG?
« Reply #11 on: April 01, 2006, 02:19:37 AM »
Yep, Rusty Gesner , Tony Tanzillo and Reni Urban have a lot to answer for  :lol:

Nothing like classical studies, Kerry! Maybe there are a couple of synopses 'round to lighten the studies 8-)

hornet 103

  • Guest
Re: Create a legend from block in the DWG?
« Reply #12 on: April 03, 2006, 03:41:48 AM »
greeting everyone from Hornet 103

In 2006-2007 there is a command that automatically counts the blocks and names, it then puts the numbers and names into a legend i.e. in a table format.
what Kerry Brown has put up on reply No8 is exactly what I am looking for.

Kerry How can I achieve this?

many thanks for your help

Hornet 103

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a legend from block in the DWG?
« Reply #13 on: April 03, 2006, 10:04:11 AM »
I haven't worked out how to post an image here ,

See the "Additional Options" at the bottom of the edit window when you are posting your message.
Simply Browse for you picture, HTH.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

RbtDanforth

  • Guest
Re: Create a legend from block in the DWG?
« Reply #14 on: April 03, 2006, 12:39:26 PM »
Hornet.

Some time ago I had to make up some pages of standard blocks and made up some lists of which blocks were to be on what sheets. The lists allow you to make sure the blocks are relevant to your table without going through all the odd stuff like dimticks etc.

The program then just feeds the list to the operator in the order of the list. If there are parts of this that are needlessly complicated just rip them out, or set them constant.

The error code is to close the opened file in case of crash.

Code: [Select]
(defun BINS_err (st)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
  (if (/= st "Function cancelled")
    (princ (strcat "\nError: " st))
  )
  (if (= (type FLN) 'FILE)
    (close FLN)
  )
  (setq FLN nil)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)
)

(DEFUN C:BINS (/ FLN  olderr SC RO B FLN FLX)
       ;(setq olderr *error* *error* BINS_err)
     (SETQ flx (princ(getfiled "block list?" "c:\\bob\\" "dir" 8))
           fln(open (findfile flx) "r")
           B (princ(READ-LINE FLN))
                   )
            (WHILE b (if (tblsearch "block" b)(princ b)
                (PROGN (SETQ B (STRCAT "C:/BLOCKS/" B))
                    (IF (wcmatch (GETSTRING (STRCAT "\n" b)) "Y,y")
                  (PROGN (command "insert" b )
                            (SETQ SC (GETREAL "\nSCALE ?\t")
                                  SC (IF SC SC 1)
                                  RO (GETORIENT "\nROTATION ?\t")
                                  RO (IF RO RO 0)
                            )
                            (COMMAND "S" SC "R" RO PAUSE)
                                 ))
                   ) )
                   (setq B (princ(READ-LINE FLN)))
                        ); WHILE
          (CLOSE FLN)  (setq *error* olderr)(terpri)
); Defun

It was then I wrote the originals of the post above to put the name and scale of the block next to each.

I suppose someone here could do a fancy rev2k4+ table and everything but that is my Q&D done for r12dos.  :-)

PS Thomas & Cab thanks for the note!