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.
@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.
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.
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
I had similar issues with running old python code, and new python code which is using c3d api.
The Solution was to install IronPython v2.7 package (its the 2.5 version in package manager- but iron python 2.7) as mentioned to me by @zachri.jensen.
Once you install this create anew python node and change engine to ironpython and code should work.
cjm