I'm creating a Python Toolbox using ArcGIS 10.5 that ultimately creates a new feature class and .lyr file from the layers in a current .mxd table of contents. I need the new feature class and .lyr file to take on the metadata from the original layer. I can import the metadata to the feature class using arcpy.ImportMetadata_conversion (i,"FROM_ARCGIS",fc_outname)
, but it isn't working for the .lyr file. The .lyr file metadata remains empty, while the feature class is populated as expected.
Relevant portion of current code:
arcpy.ImportMetadata_conversion (i,"FROM_ARCGIS",feature_class)
if not arcpy.Exists(lyr_outname):
arcpy.AddMessage("Creating .lyr file: {}\n".format(lyr_outname))
lyr = arcpy.MakeFeatureLayer_management(feature_class, lyr_disp)
arcpy.ApplySymbologyFromLayer_management(lyr, v)
arcpy.ImportMetadata_conversion (feature_class,"FROM_ARCGIS",lyr)
arcpy.SaveToLayerFile_management(lyr, lyr_outname)`
Even with the .lyr file created, I can't use any of the import metadata tools in desktop to successfully import the metadata. While they complete successfully, it remains empty. I can however manually import the new feature class, and right click on it, and save to layer file. This saves the metadata.