Code Red > AutoLISP (Vanilla / Visual)

Create a legend from block in the DWG?

<< < (3/3)

RbtDanforth:
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: ---(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  )
)

--- End code ---

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: ---(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 )
)
)

--- End code ---

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:

--- Quote from: Kerry Brown on March 31, 2006, 09:08:38 PM ---Yep, Rusty Gesner , Tony Tanzillo and Reni Urban have a lot to answer for  :lol:

--- End quote ---

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

hornet 103:
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:

--- Quote from: RbtDanforth on March 31, 2006, 11:32:32 PM ---I haven't worked out how to post an image here ,
--- End quote ---

See the "Additional Options" at the bottom of the edit window when you are posting your message.
Simply Browse for you picture, HTH.

RbtDanforth:
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: ---(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
--- End code ---

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!

Navigation

[0] Message Index

[*] Previous page

Go to full version