Arcpy layer properties returns incorrect workspace path

411
4
01-31-2022 02:04 PM
Labels (1)
JosefBeautrais
New Contributor

Hi,

I have a script which, as part of its logic, takes a map layer from the current map document and gets its source path. Recently it has been returning the wrong path: it returns the path to my default geodatabase instead of the correct path to the layer's data. It used to work fine.

This incorrect behavior occurs with my_layer.workspacePath and with Describe(my_layer).Path. Both of these return the wrong path; if I check the Layer Properties from the Table of Contents in ArcMap I can see the correct path.

Any ideas what might be going wrong? Is anyone else having this issue?

I'm using ArcMap 10.8.0.12790

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

can you confirm that it also doesn't exist in your default geodatabase


... sort of retired...
0 Kudos
JosefBeautrais
New Contributor

Thanks for the quick reply.

It turns out there was indeed a (different) feature class with the same name in my default geodatabase. It was not loaded in the current map document.

Deleting the feature class from the default geodatabase did fix the problem, so thank you for the hint. I am still curious why it gave the result it did.

0 Kudos
KimGarbade
Occasional Contributor III

Could you provide your code so we can take a look? 

0 Kudos
DanPatterson
MVP Esteemed Contributor

Glad it worked out, but I suspect that the code will determine that.  I suspect that somewhere the environment path or something was changed and caused the default gdb to be read


... sort of retired...
0 Kudos