Select to view content in your preferred language

Changing the name of a GDBProjectItem?

1589
5
Jump to solution
06-15-2021 02:14 PM
by Anonymous User
Not applicable

Is it possible to change the name of a GDBProjectItem object?

JKing_Esri_0-1623791626213.png

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.

Tags (2)
0 Kudos
2 Solutions

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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.

View solution in original post

by Anonymous User
Not applicable

@Wolf Thank you for the idea of renaming the file at the OS level, this worked beautifully!!

JKing_Esri_0-1623946494327.png

 

View solution in original post

0 Kudos
5 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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.

by Anonymous User
Not applicable

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.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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.

by Anonymous User
Not applicable

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.

0 Kudos
by Anonymous User
Not applicable

@Wolf Thank you for the idea of renaming the file at the OS level, this worked beautifully!!

JKing_Esri_0-1623946494327.png

 

0 Kudos