Setting multiple block attribute values

Topic split from:

Friends, my doubts are increasing in level lol… a sign that I’m making progress! haha

I searched about python code, but I didn’t find anything about it either.

If you observe each insertion of a value in an attribute, the process ends and gives “continuity” in the attribute values, instead of inserting all the values ​​at once in a block.

And in practice, I need that to happen…

I noticed that every time I run the code the block has the following attributes

But the block originally has a lot more attribute fields… I’m finding it a bit confusing…

Could anyone help me with this step further?

~ translated by google translator ~


Maybe this help you

Amiginho Rafita @gabrielrafaeln buenas, this is complicated and it is easy to get lost I will try to explain correctly, each Block Reference has a list of Attributes, each time you insert a Block you create an element or instance and each block can have its own value in each Attribute, what you have to pay attention to is the depth of the lists you are working with so if you give the same list the names of the attributes and you give a list with the same depth of values it will insert each value in each attribute. example:

  1. ATT1 → [List of Values for each block in ATT1]

My advice for you to fully understand it, fill 2 or 3 Blocks manually and ask dynamo for a query of the values stored in the attributes of the Blocks!

1 Like

my friend @gilberto.arechigaiba so, I did it kkk. Maybe it wasn’t clear in my post.

This code circled in green, these tags are the tags of my block that I insert manually, precisely to read all the tags of the block and insert it in the next blocks that are created (the idea is this kk)

this red arrow is the positions that are the attributes

and these blue arrows are the attribute values.

My friend, the code was already 95% the same as in this example… but I left it 100% the same, in this part of the code in question and, even so, it is causing me an error.

in other words, to further exemplify, I need:


in the first block I need to insert:

in the second block I need to insert:

And in practice, this is happening:

in the first block I need to insert:
the other attributes disappear

in the second block I need to insert:
the other attributes disappear

~translated by google translator~

Amigo @gabrielrafaeln buenas, there is a couple very usefull old command that i used a lot before begin whit Dynamo Attin / Attout, they alows you in out the data from autocad to an .txt file, then you can use excel to modify the information, check a little bit how this works to better understand how Autocad manage the information, here’s what an export time of a block looks like!!

Friend @gilberto.arechigaiba , I do it manually this way. I insert the blocks manually at the desired points, then I insert the unique name of the block (which in this case would be the name of the drillhole), I export txt through the command “export attribute”, then I take it to excel and, in excel, I insert the information I need in each block and I import it back into my drawing using the “import attribute” command.

The idea is to further automate this process…

Amigo, try this: Use List.GetItemAtIndex to split your list of Tags (attributes) and use 1 node BlockReference.SetAttributeByTag for each Tag, and feed the values whit the list of values corresponding to the tag.

@gilberto.arechigaiba , your solution solved my problem! Thank you very much in advance!

This way my code works, but I need to think of a way to optimize it… because there are more than 100 tags (attributes) kkkk… it will become an extremely large code… I’ll see if I can find a solution about it and post it here!

~transleted by google~

1 Like

Amigo @gabrielrafaeln buenas, I am glad to hear that you are improving and that my tips are working, if you work if you have a very long list of attributes with this method you will have to use multiple instances of nodes and it is true it will become complicated to handle, try the following: use the List. Chop node with Length = 1, to transform your list of Attributes (Tags) of N elements in a list of N lists, so you assign to each Attribute (Tag) its own list of Values, your SetAttributeByTag node must work with levels and that is quite complicated you must go very deep into the dark side :rofl: , good luck.!!

1 Like

I thank you for your help, Gilberto!

Sorry for the delay in getting back to you, but every day that passed I studied the code in order to make progress.

I even downloaded some extensions (packages) in order to help me in this study, but without much success…

I did as you instructed me, it worked more or less right for me, but I am not able to relate the attribute values ​​to each tags of their respective blocks (polls)


1st - I am generating two blocks in the profile, according to coordinates and stake and in the correct dimension.
2nd - in my excel there are values ​​(attributes) for the polls that are in my profile
3rd - I am not able to relate the value (attribute) 01 of tag 01 of poll 01, in the same way I am not able to relate the value (attribute) 02 of tag 02 of block 01.

just as I am not able to relate the value (attribute) 01 of tag 01 of poll 02, in the same way I am not able to relate the value (attribute) 02 of tag 02 of block 02.

the way you guided it makes sense, because each list would be a tag, but I did the same with the attribute values ​​and it didn’t work very well… they didn’t “talk”.

I don’t know if I can be clear on my question.

Amigo @gabrielrafaeln buenas. Congratulations you almost made it, I told you that you need to use levels in your node, try to activate both parameters tag and value to work in level 2 (@2), I haven’t tried it yet, but i think will work, I still don’t know how to use levels 100 % but once you understand it you are on the other side, good luck!

I ACHIEVED! @gilberto.arechigaiba

Thanks a lot, man! This level tip was the solution, I read through this whole article you gave me, I understood the idea of the level functionality a little and managed to complete my code!

Thanks a lot, man!

Now I’m just going to finish it, insert all the necessary functions and it’s ready!

Thank you so much again!


Hi, how do you solve it?
i have the same issue
can you send me your dyn file? just for understand the script


Amigo @EdwinG_HMV, srry for the delay, long story short is that Attributes Belongs to Block so Each Block that you insert needs a sublist of Attributes and each Attribute needs a sublist of Values, I let you an example, you will have read all the topic of list of list in dynamo Primer, make attention in lacing and levels topics, But as i said before Levels are the path to the dark side, good luck!!

Hi @gilberto.arechigaiba, i appreciatte yout help, i just tried to add 3 Attibutes to a large number of blocks but it not works, cpuld you help me? thanks

@gilberto.arechigaiba this is my dyn file and the dwg with de block, could you take a look?, thanks!

Block Insert.dwg (3.2 MB)
BlockByCoordinates1.dyn (1.2 MB)
FileCordinatesBlock.txt (40.2 KB)

Amigo @EdwinG_HMV, This could be considered a Professional Consultation? :stuck_out_tongue_winking_eye: Voila here are your mistakes:

  1. The data type for the “Values” only admits String type be careful with that.
  2. The way Autocad manages blocks with attributes is Block - Attribute list, so the list of values must have the same structure.
    Hope this helps you!!
1 Like

Amigo @gilberto.arechigaiba
thanks i got it!!
but for some reason the list of blocks looks different

Amigo @EdwinG_HMV Take a closer look to the levels and lacing, i strongly sugest to explore and understand about this topics is very easy to lost and frustrate using those if you don’t understands quite enough!!