Is it possible to change the name of a GDBProjectItem object?
In the code snippet above, you can see that I can grab the Info with GetInfo() and set the Name property on it, but I can't edit the Name property of the GDBProjectItem itself, as it's protected/internal.
Solved! Go to Solution.
So specifically for a file geodatabase the GDB folder's name turns into the name in the catalog browser. You could use a Windows system function to rename the folder name. I will try a snippet and see it that works. Needless to say this won't work if the GDB has been opened in any way.
It looks like the rename function is internal only, even so the API Reference guide shows the Name property's description as a getter/setter (which is not correct). My best guess is that this function is not trivial because depending on GDB type and the state of the GDB (open/closed) renaming might not be allowed. The other issue is that after the GDB project item has been renamed all dependencies have to be refreshed because renaming the GDB Project item will also rename the underlying database location (for example). That's probably the reason this functionality has been kept internal by the Pro developers.
That's what I was noticing too.
I basically just want to be able to add the database and change the label of it that appears in the catalog. So if there are any other solutions that can achieve that, I don't necessarily need to rename the GDBProjectItem itself.
So specifically for a file geodatabase the GDB folder's name turns into the name in the catalog browser. You could use a Windows system function to rename the folder name. I will try a snippet and see it that works. Needless to say this won't work if the GDB has been opened in any way.
I'm actually trying to do this for a database connection to a SQLServer instance. When I programatically add the GDBProjectItem from the connection path, it creates a GUID for the connection file when it adds it. I could probably follow the same logic to rename that through some OS function.