• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

lisp for legend creation

  • Thread starter Thread starter mirco354
  • Start date Start date

mirco354

Guest
Good morning to all boys,
I would like to ask you if you think it is possible to create a lisp that creates the legend of my design, working like this:
1) start the lisp that will ask me to select an area where blocks are placed
2) within this selected area, only blocks should be taken into account
3) making an example, within the selected rectangle finds the block called "001", "002", "003"
4) if you find the "001" block, you have to enter the "001legenda" block in point 0.0
5) if you find the block "002", you have to enter the block "002legenda" in point 2,0
6) if you find the block "003", you have to enter the block "003legenda" in point 4,0
7) and so on, do you think it is feasible?
8) I should make a sort of mating between the symbol found in the drawing and its relative legend symbol that I have in the bookcases
9) If you find a block in the drawing that is not related to a legend symbol you should not consider it

are in your hands,
Thank you
 
Alternatively, it could work so if possible:
1) start the lisp that will ask me to select an area where blocks are placed
2) within this selected area, only blocks should be taken into account
3) making an example, within the selected rectangle finds the block called "001", "002", "003"
4) then in a certain point it must insert the block "001", with alongside a description I create (standard, if possible insert it directly into the lisp) and so on for the other blocks it finds.
Is it possible for you?
Can you please help me?
Thank you
 
I can't understand why you don't train a dwg with what you want to get, you always have to interpret what you have in your head. :
the description should be placed below, above, side by side, and how many characters? Should the blocks be ordered according to the name? Are names always composed of numbers? if I don't find 002 his place in legend is taken from the next one or remains empty?
 
Sorry, gp.
I'll draw you a drawing where I've described what I need! I hope it's a little clearer! thank you very kind
 

Attachments

the base of departure could be my conblok.lsp:
if you select blocks (other than each other) in a part of the drawing, then the command will count and enter the n. and the name in a table.

in your case you can tell him: if you find the block "001" insert on the drawing the block "10001", if you find the block "002" enter the block "10002" etc.
 

Attachments

Hi, start,
I loaded the lisp. very interesting, it is also convenient to make computi metrici! !
Yes, I could change this to make me insert the reference block. but how to change it? :-d more than my list of blocks with relative answers where should I go to insert it?
thanks for availability
 
bye mirco354,
test with this, copy the folder in > self-support < in > c: <
upload the lisp > table.lsp < and read the information by clicking the > info < button.
 

Attachments

Hello angel,
I tried to load the lisp but from an error (see attachment).
Besides with the lisp creates a table but then the symbol association in the plant with its symbol in legend according to me the first time I have to do it don't you think?
Thank you
 

Attachments

  • Errore_Tabella.webp
    Errore_Tabella.webp
    7.3 KB · Views: 3
I think that of 11start is fine, but instead of inserting the number of blocks should insert the relative block of legend, but I do not know how to change the file:-(







the base of departure could be my conblok.lsp:
if you select blocks (other than each other) in a part of the drawing, then the command will count and enter the n. and the name in a table.

in your case you can tell him: if you find the block "001" insert on the drawing the block "10001", if you find the block "002" enter the block "10002" etc.
 
If I have a moment of time, I put down a list.... now I have to go to the garden to cut the grass!
 
Hello angel,
I tried to load the lisp but from an error (see attachment).
Besides with the lisp creates a table but then the symbol association in the plant with its symbol in legend according to me the first time I have to do it don't you think?
Thank you
Hi, mirco354, I'm sorry, but I forgot to enter some code.
for the operation of the program, you must enter into the lisp (I have it directly in acad.lsp)
These instruments:
Code:
    ;;; @runappp

    (defun runapp (commands$ visible metodo / wscript)
        (if (setq wscript (vlax-get-or-create-object "wscript.shell"))
         (if visible
                (vl-catch-all-apply 'vlax-invoke-method (list wscript "run" commands$ 1 metodo))
            (vl-catch-all-apply 'vlax-invoke-method (list wscript "run" commands$ 6 metodo))
         )
        )
        (princ)
    );;defun


   ;;@setcliptext

    (defun setcliptext(str / html result)
         (if (= 'str (type str))
        (progn
            (setq html (vlax-create-object "htmlfile"))
            (vlax-invoke (vlax-get (vlax-get html 'parentwindow) 'clipboarddata) 'setdata "text" str)
            (vlax-release-object html)
            );;progn
         );;if
    );;defun

    ; ----------------------------------------------------------------------------------------

    ;;@getcliptext

    (defun getcliptext(/ html result)
        (setq html (vlax-create-object "htmlfile"))
        (setq result (vlax-invoke (vlax-get (vlax-get html 'parentwindow) 'clipboarddata) 'getdata "text"))
        (vlax-release-object html)
        result
    );;defun

    ; ----------------------------------------------------------------------------------------

    (defun messaggiox (/ lung)
        (setcliptext stringax)
        (runapp "c:\\autocadsupporto\\libertytre\\alertstandard.exe " "c:\\autocadsupporto\\libertytre\\alertstandard.tkn" :vlax-true)
    );;defun

    ; --------------------------------------------------------------------

    (defun assemblastringhe (/ lung)

        (setq lung (- 12 (strlen stringa1)))
        (repeat lung
        (setq stringa1 (strcat " " stringa1))
        );;repeat

        (setq lung (- 12 (strlen stringa2)))
        (repeat lung
        (setq stringa2 (strcat " " stringa2))
        );;repeat

        (setq lung (- 12 (strlen stringa3)))
        (repeat lung
        (setq stringa3 (strcat " " stringa3))
        );;repeat

        (setq lung (- 12 (strlen stringa4)))
        (repeat lung
        (setq stringa4 (strcat " " stringa4))
        );;repeat

        (setq stringax (strcat stringa1 stringa2 stringa3 stringa4))

    );;defun fine assemblastringhe

    ; --------------------------------------------------------------------
for good operation (for alignment), you should adopt the style > arial <.
if something is missing, do not hesitate to ask.
Bye.
 
.... here is a still hot lisp: freshly baked!
by launching the lisp legend, the selection of blocks is required (e.g. 001 002 023 of your dwg).
the program asks to specify a blank point on the design and to give a value for the interline (by sending uses the value 8); then draws the legend.

the lines of the legend are only blocks whose name is equal to that of the selected blocks, with in front of the value 10 (001 -> 10001 - 002 -> 10002 etc.).

the program makes a gross "scrematura", ignoring the blocks with names that are not numbers (transform the name into a whole number and check if it is greater than 0): then in your example the block "room" is discarded even if selected. as I said the scrematura is coarse, as it does not control or if they are selected blocks that are already part of the legend (10002 considers it valid ... but then it would give the error when trying to put in legend the block 1010002), and even if they are selected names that then do not have a corresponding as legend: 004 is among the blocks of the drawing, but he does not find 10004.
This means that when you create a new design, you have to remember to insert a file that contains all the blocks you need.

Another problem is the interline that I put by default at 8 (by sending) which is the height value of the blocks 10001 and 10002. for 10023 the height would be 12, so there would be an overlap if there were other elements below; therefore the interline should be variable. This complicates things, because I can't know "the encumbrance" of a block I'm going to insert. The only way would be to put in that block a fixed attribute indicating this value... and then adapt the code so that it goes to read that value.

in this regard I ask the " forum guru" if there is an easy and fast way, which allows me to find "the encumbrance" of a block: es la coord. down to left and up to right. would be useful on various occasions. . .
 

Attachments

.... there is an easy and fast way, which allows me to find "the encumbrance" of a block: es la coord. down to left and up to right. would be useful on various occasions. . .
you can use the bounding box method:
(setq obj (car (entsel)))
(vla-getboundingbox (vlax-ename->vla-object obj) 'p1 'p2)
(setq p1 (vlax-safearray->list p1))
(setq p2 (vlax-safearray->list p2))
p1 and p2 result in the bottom left and upper right of the rectangle containing objects.
precision is perfect for almost all objects, while splines and blocks can be approximated.
 
but to program in lisp you studied alone? or I don't know there are books, courses, etc... do you know where I could find something?
 
I speak for myself: I started little by time trying to understand and do very trivial programs... now there are forums like this, but once there was nothing and you put a century even to learn how to draw a line on autocad. then as you see I still have huge gaps and the most experienced members like gp are a valuable resource. I quote him because he helped answer this question... but there are many others!
 
thank you... it's hard unfortunately... I would be willing to pay dear training from 0.. but not found
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top