How to set block attribute values from Grasshopper

Hi,

I am using Rhino 8 + Grasshopper + Rhino.Inside.AutoCAD.

I have an AutoCAD block definition named:

ETICHETTA_DUE_RIGHE

The block contains two AutoCAD attributes:

RIGA_1
RIGA_2

My goal is to place one block reference for each room/space and fill the two attributes with two different text values:

RIGA_1 = room code / label
RIGA_2 = area / perimeter data

Current Grasshopper workflow

I am doing this:

Get AutoCAD Block Table Records
→ AutoCAD Block Table Record
→ filter block by name: ETICHETTA_DUE_RIGHE
→ Create AutoCAD Block Reference
→ Bake to AutoCAD
→ Get By Id
→ AutoCAD Block Reference
→ Block Attributes / Set Block Attributes

Before baking, the created block references show:

AutoCAD BlockReference [Id: No Database Id]

After baking, I can retrieve them with Get By Id, and they are real AutoCAD block references with valid IDs.

The inserted block references are placed at the correct points in AutoCAD, but I only see small insertion points/dots. The attribute texts are not visible / not populated.

Data structure

I have two text lists:

List 1:
D1.S.FF01
D1.S.FF02
D1.S.FF03
D1.S.FF04

List 2:
(P23.164351 A23.4)
(P14.68604 A12.6)
(P18.563222 A17.3)
(P23.290614 A32.5)

I tried to combine them with Entwine, and also tried Flip Matrix, because I am not sure whether Set Block Attributes expects the values as:

{0}
RIGA_1 value for block 0
RIGA_2 value for block 0

{1}
RIGA_1 value for block 1
RIGA_2 value for block 1

or as two separate branches:

{0}
all RIGA_1 values

{1}
all RIGA_2 values

Questions

  1. What is the correct workflow to create AutoCAD block references and set their attribute values from Grasshopper?

  2. Does Set Block Attributes work only after the block references have been baked and have a valid AutoCAD database ID?

  3. What exact data tree structure should the Value input of Set Block Attributes receive when each block has two attributes?

  4. Why are the inserted blocks visible only as points/dots, without showing the default attribute text?

Screenshot attached.

Thanks.

Hi @AmicoCAD

This looks like a bug in the Create Block Reference Component, you should get a valid id as the output if not then it is a bug. Block References do not need to be baked as they exist only in the AutoCADDatabase.

Are you able to share the AutoCAD/GH file for us to have a look?

Regarding your questions:

  1. What is the correct workflow to create AutoCAD block references and set their attribute values from Grasshopper?

Use the Create Block Reference component and then use the output id from that component into a Block Reference Component which exposes the attributes which can then be set with the Set Block Attributes.

  1. Does Set Block Attributes work only after the block references have been baked and have a valid AutoCAD database ID?

It only works after the object is in the AutoCAD Database, but creating the block reference should add it into the database, no baking required.

  1. What exact data tree structure should the Value input of Set Block Attributes receive when each block has two attributes?

Attribute values are set as Items 1 for 1 Attribute. So it depends on if you are setting more than one attribute.

  1. Why are the inserted blocks visible only as points/dots, without showing the default attribute text?

This looks like a second bug, the baking should just skip the block references but it looks like it is extracting the insertion point and baking that- ill have a look at this as well.

Edit: there is defiantly a bug, ill have a look and see if we cant get a new release asap. When its fixed it should be like this (but attributes not properties):

Hi @AmicoCAD

These we should now be working in V1.0.22, let me know if you notice anything else!

Are you using the GH I sent?
If so note the the GH Create component has a scale of 500. The block is in Meter units which means the scale become 0.5 in AutoCAD which is in mm?

Great work. I really appreciate your work, Tom; it’s invaluable.
I noticed that the two lines in AutoCAD are written backwards, line 1 below and line 2 above. Why?

It doesn’t bake.

Grazie

I notice that AutoCAD is very unstable. It crashes frequently.

The order will be based on the order of the attributes coming out of GH Attributes component, so have a look at the tags and they should tell what order you need to add the data:

The block references exist already in the AutoCAD database so they do not need to be baked, and they are now correctly skipped by the bake component?

I notice that AutoCAD is very unstable. It crashes frequently.

Are you able to give more details about what you are doing when it crashes?

Could Ypu set the block to default to inheriting the color of its parent layer?

Of course. It almost always happens if I open another DWG.

I specified the layer in the Attributes settings, but the preview (before creating the blocks in AutoCAD) shows a different layer. Am I doing something wrong?

Your screenshot makes it look like you are still baking it?

Are you setting it here on the Create Block Reference Component?


(The layer id will also take layer)