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

insert a block with attributes using "entmake"

  • Thread starter Thread starter teoz
  • Start date Start date

teoz

Guest
Hello everyone,
I would like to insert blocks to which attributes are associated, with relative default values, using the "entmake" command, which I currently cannot perform.

Suppose my block is called "test" to which an attribute is associated, visible and editable, called "given". The code I use for its insertion is:

(entmake (cons 0 "insert") (cons 2 "test") (list 10 0 0 0))

at this point autocad will have inserted the block "test" to the origin of the axes without any attribute. What is missing in my code so that the attribute is also inserted, as happens with "_insert"?

bye and thanks
Matteo.
 
you are making confusion between definition of the block and insertion of the same.
It's the test block that has to contain the attributes, you can't add them in the input phase.

Good dinner, bye
 
I extrapolated this part of code from a lisp that I did to insert topographic points with attributes, see in the help the meanings of the various dxf codes to customize it.
Clearly the block must already be defined.

:smile:


Code:
(entmake (list (cons 0 "insert")(cons 100 "acdbentity")(cons 67 0)(cons 410 "model")
(cons 8 "riga_7")(cons 100 "acdbblockreference")(cons 66 1)(cons 2 num_b)
(Cons 10:bb)(Cons 41(1)(Cons 42(1)(Cons 43(1)))

(entmake (list (cons 0 "attrib")(cons 100 "acdbentity")(cons 8 "riga_7")
(Cons 100 "acdbtext")(Cons 10 (list 0.4 0.5 0))(Cons 40 0.4)(Cons 41 0.85)
(cons 1 r6) (cons 7 "punto") (cons 100 "acdbattribute")
(cons 2 "descr") (cons 70 1) (cons 39 0))

(entmake (list (cons 0 "attrib")(cons 100 "acdbentity")(cons 8 "punto-numero)
(Cons 100 "acdbtext")(Cons 10 (list 0.4 0.5 0))(Cons 40 0.4)(Cons 41 0.85)
(cons 1:r7) (cons 7 "punto") (cons 100 "acdbattribute")
(cons 2 "num_p") (cons 70 1) (cons 39 0))

(entmake (list (cons 0 "seqend")))
 
thanks gp,
Your code comes back useful to prove that it is possible add attributes to a block during his insertion.

Suppose he has already defined a block whose name is "test" and that it is composed of a rectangle and an attribute, visible and
editable, called "given", con valore di default la stringa "prova".

vediamo cosa succede con il tuo codice, adattato al mio blocco "test":


(Cons 100 "acdblockreference")(Cons 67 0)(Cons 410 "model")(Cons 8 "riga_7")(Cons 100 "acdbblockreference")(Cons 66 1)
(cons 2 "test") (cons 10 (list 100 100 0))(cons 41 1) (cons 42 1) (cons 43 1))

(cons 8 "riga_7")(cons 100 "acdbtext")(cons 10 (list 0.4 0.5 0))(cons 40 0.4)(cons 41 0.85)
(cons 1 "value per descr") (cons 7 "punto") (cons 100 "acdbattribute")
(cons 2 "descr") (cons 70 1) (cons 39 0))

(entmake (list (cons 0 "attrib")(cons 100 "acdbentity")(cons 8 "punto-numero")(cons 100 "acdbtext")(cons 10 (list 0.4 0.5 0))(cons 40 0.4)(cons 41
0.85)
(cons 1 "niente dato") (cons 7 "punto") (cons 100 "acdbattribute")
(cons 2 "num_p") (cons 70 1) (cons 39 0))

(entmake (list (cons 0 "seqend")))


the righe who sows so much the inserimento del blocco "test" my dick 2 new attributes, that are not found in
definition of the block itself
, precisely con: decr and num_p. of the attribute "given" there is no trace!




what I would like to understand, instead, is how to insert a block with its attributes, those contained in its definition, using
"entmake" without "insert". in practice as I can "translate" the following line:

(command "_.-insert" "test" "100,100,0" "1" "0")

using "entmake"? (Please note that with the code line above is inserted the "test" block and the attributes contained in its definition).

Thank you for your patience:

Hi.
Matteo.
 
the insertion with entmake, unlike the insertion by command, also involves the calculation of the position of the attributes, is therefore not such an easy operation.
in the example below, adapted to your "test" block, the attribute is inserted in position 100,100.
Code:
(entmake (list (cons 0 "insert")(cons 100 "acdbentity")(cons 67 0)(cons 410 "model")
(cons 8 "riga_7") (cons 100 "acdbblockreference") (cons 66 1) (cons 2 "test")
(Cons 10 (list 100 100 0))(Cons 41 1) (Cons 42 1) (Cons 43 1))

(entmake (list (cons 0 "attrib")(cons 100 "acdbentity")(cons 8 "riga_7")
(Cons 100 "acdbtext")(Cons 10 (list 100 100 0))(Cons 40 0.4)(Cons 41 0.85)
(cons 1 "prov") (cons 7 "arial") (cons 100 "acdbattribute")
(cons 2 "dato") (cons 70 8)(cons 39 0))


(entmake (list (cons 0 "seqend")))
 
the insert command creates a set consisting of a link to the definition of the block + one copy of the definition of each present attribute.
entmake allows you to merge the link to the definition by adding attributes, which are not necessarily contained in the definition of the block itself.
that is why it allows you to insert a block by adding attributes to the flight, operation I had never experienced.
so if you do not add the copy of the attribute contained in the definition of the block, you do not find it in the inserted block.
the problem is that if you want to insert a block with attributes, or you know how they call attributes or you need to scan the definition of the block and search for the necessary info.
the example of gp is how much it serves knowing the definitions of the block, although the position of the insertion point should in any case calculate it or set it as a shift relative to the insertion point of the block.

hello and thank you for the reflection that you "forced" me to do.
 
thanks guys for the help :smile:

unfortunately on the net I found many information on how to insert blocks with entmake and how to add "extra" attributes during the insertion of the block itself, but very little on inserting blocks with the attributes of its definition.
perhaps this is a signal that “entmake” is not the correct tool to insert blocks in my way :frown:

Ultimately if I want to use entmake to insert a block I will have to do as rpor66 says: scan the block def and copy the attributes that I find inside it and then add them to the insertion of the block. in fact it is a little laborious.

I believe that, in the end, I will use the command (vla-insertblock), although, giving an eye to the documentation, it requires more information than "-insert".

Are there other advantages, in addition to efficiency, in the use of the function (vla-insertblock)?
 
Does the entmake function not require an avalanche of information?

However according to me (vla-insertblock) has two fundamental advantages, in addition to its speed, as well as all activex functions.
the first is that you can use the vla-insertblock function also to insert a block inside another block, directly, without using the bedit command.
the second, I have to say marginal for the use that can be done, is the impossibility to use the various commands and entxxx functions and ssget in the so-called "callbacks function" or reactor recall functions, then letting me the most known interfaces and perhaps more "easy". At that point I have to use activex functions.

As for the insertion of attributes in the block you can also use the vla-addattribute function, but here would open another chapter. . .
 

Forum statistics

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

Members online

No members online now.
Back
Top