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

Hey @AlexanderMcN @Paolo_Emilio_Serra1

What input are you providing on BlockID?
i am trying to get this working in civl3D2022, but it continuously gives me the error:
image

Hi @dick.elsman_infranea

The BlockID is the object Handle, as shown in image below. its a string value you need to install.

I am still using C3D 2021, i think 2022 and beyond the background APIs and python coding is changing to the newest version of Python, so that might be why its not working? @Paolo_Emilio_Serra1 will know better than me.

EDIT: Meant to say i am using nodes from the Civil3DToolkit package, just FYI

Hope that helps,
Regards,
Alexander

1 Like