Can ArcGIS Pro Layer (.lyrx) names have spaces in them?

3423
14
04-24-2017 07:00 AM
by Anonymous User
Not applicable

Can ArcGIS Pro Layer (.lyrx) names have spaces in them? 

I ask because when attempting to save 'layer file spaces.lyrx' I receive the 'Invalid Path' error. Replace this with 'layer_file_spaces.lyrx' and it saves without a problem.

Anyone else experienced this issue?

Regards,

Danny.

(ArcGIS Pro 1.4.1)

14 Replies
by Anonymous User
Not applicable

Hi Marco, I'm not sure what to say, both Esri UK and Esri Inc have tested this and accepted it as a defect, including some of the system architects at the UC.

I have tested this again writing to the C:\ drive and avoiding network drives as you suggest. Please could you provide some screen shots or a video of the steps you take to overcome this problem please?

My steps = right click feature class > Save As Layer File > select a location (network or local) > Save the .LYRX as a filename with spaces i.e. "file name with spaces" = invalid path error, "file_name_without_spaces" = saves the .LYRX as expected.

This was the response from Esri "Unfortunately,  the limitation is there to stay.  So to answer your query, no, blanks are not supported, currently, for layer files in ArcGIS Pro.  I know this is a discrepancy with ArcMap, but that is how it has been designed in Pro."

It would be great to know how you do this.

P.S. the original test was with ArcGIS Pro 1.4.1, today's test was with ArcGIS Pro 2.0.0 and the result was the same.

0 Kudos
MarcoBoeringa
MVP Regular Contributor

Hmmm.... I have to admit something now: I can reproduce your issue! It staggeringly fails from within the Pro interface with the error message you show. ;-() This is one h*l of a bug.

What were my remarks based on, you are asking? Well, I have been debugging an arcpy based application that needs to run in both ArcMap and Pro. That application routinely saves layer files with spaces in the filename through arcpy, using the following statement:

*** This works in Pro for saving layer files with spaces! ***

inputLayer.saveACopy(newLyrFilename)

I have never seen this command fail, and have run it in batch on hundreds of layer files... I can save and load layer files with spaces fine through arcpy using this and other arcpy statements. Loading a layer file with spaces manually from the catalog window by drag-and-drop is also no problem, I have done that dozens of times in Pro.

For some reason though, I just didn't save them from within Pro manually, as my main focus for the development of the layer files has been ArcMap, and I simply upgrade them to Pro using the above shown command in an automated fashion. That is why I totally missed this issue, despite regularly having tested stuff in Pro!

0 Kudos
by Anonymous User
Not applicable

Likewise you can save them as 'CamelCase' and retrospectively add the spaces back in, or with 'Under_scores' and then replace them with spaces (in ArcCatalog or Windows Explorer) - these can then be brought back into ArcGIS Pro, but that isn't really a solution to a very simple requirement which represents quite an oversight on Esri's part.

0 Kudos
MarcoBoeringa
MVP Regular Contributor

Well, certainly, even if this was "as designed", as you were told through at least one of your contacts, then the fact that I can save them with spaces through arcpy, and that we can load manually edited layer files with spaces from the catalog window, would represent a serious discrepancy as well to this "as designed" feature.

I actually think that from a programming perspective, this may be a relatively minor issue. Many parts of Pro seem to already accept the layer files with spaces, it may just be that save routine behind the Save As Layer File menu option that is in error.

by Anonymous User
Not applicable

This will also allow spaces to be saved (courtesy of colleague Ben Holmes):

p = arcpy.mp.ArcGISProject("CURRENT")

m = p.listMaps("Map")[0]

for lyr in m.listLayers():   

    if "SampleText" in lyr.name:       

    print(lyr)       

    lyr.saveACopy(r"C:\temp\Layer has Spaces.lyrx")

Change “Map” to the name of your map and “SampleText” to some text contained in the feature class name, as seen in the map.

Again, a work around to a relatively simple 'missing' function.