BlockReference Add Attributes

Does anyone know how to add new Attribute Definitions to an existing block?

I had hoped the BlockReference.SetAttributeByTag would work however it only updates existing tags as far as I can tell.

I have found threads online about doing it with Autocad .NET coding but its not python and I know very little about coding in any language. I have had an attempt at doing it with no success, the code is a bit of a mess of different attempts from different copied code.

Any help appreciated.
I’m using C3D 2020 and Dynamo Core 2.4.1.6394, Dyanmo C3D 2.4.1.2161 if thats of any help

@AlexanderMcN welcome to the forum! first off, yes in Dynamo OOTB we do not have code to add attributes to existing blocks. Second, well done on the Python attempt, you need to uncomment the line with “t.Commit()” to actually see the changes in the document, this is the first thing that comes to mind looking at your code but I haven’t had time to test it.

1 Like

Thanks Paolo, good spot I had turned off some lines when I was trying to figure out what other lines of code where causing issues. If i turn off the lines from the breIds = (about half way down) and turn on the commit, it will run without errors however doesn’t actually do anything to the block, even with Attsync.

I would share the Graph however it wont let me as a new user.

Sorted

1 Like