AnsweredAssumed Answered

Building proper syntax for importing .lyr symbology for Feature Layer

Question asked by tomas1 on Feb 10, 2017
Latest reply on Nov 29, 2018 by gkmieliauskas_cellexp

I hesitate to throw another syntax question out so quickly following a recent similar syntax request. Up until this week I had been able to pretty well navigate syntax required by the various pro tools. However, I am struggling with applying symbology from a manually classified .lyr file to a feature layer. Through the sdk I am attempting to use the tool “ApplySymbologyFromLayer_management”. 

I have successfully used this tool in code to apply symbology to a raster layer using the following:

var gpresult = await Geoprocessing.ExecuteToolAsync("ApplySymbologyFromLayer_management", new string[] { rasterLayer.Name, strPathToLyrFile });

I have interactively used the tool in the Pro session without issue for the feature layer.  I noticed that when I specify the target .lyr file interactively, the Type field, the Source Field, and the Target Field are automatically assigned to the correct values. (Displayed in Attachment).  This initially led me to believe that I might not need to provide the symbology field arguments. However, when I used the same approach for the feature layer with the classified .lyr file, I received the error:

      {<msg code="309" type="100">ERROR 000309: The value is not a field
      ERROR 000309: The value is not a field</msg>}

 

I have looked at various documentation pages such as:

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/apply-symbology-from-layer.htm, which provides python syntax examples.   Based off the help page, I started by building this:

string strTestArgs = "[VALUE_FIELD, gridcode, gridcode]";

var gpresult = await Geoprocessing.ExecuteToolAsync("ApplySymbologyFromLayer_management", new string[] { rasterLayer.Name, strPathToLyrFile, strTestArgs });

I have tried numerous sytax versions of the argument string to pass to the tool in code but can’t seem to find the proper format.  All the versions of the argument string I have passed produced either:

{<msg code="309" type="100">ERROR 000309: The value is not a field

or

{<msg code="800" type="100">ERROR 000800: The value is not a member of VALUE_FIELD | NORMALIZATION_FIELD | EXCLUSION_CLAUSE_FIELD | CHART_RENDERER_PIE_SIZE_FIELD | ROTATION_XEXPRESSION_FIELD | ROTATION_YEXPRESSION_FIELD | ROTATION_ZEXPRESSION_FIELD | TRANSPARENCY_EXPRESSION_FIELD | TRANSPARENCY_NORMALIZATION_FIELD | SIZE_EXPRESSION_FIELD | COLOR_EXPRESSION_FIELD | PRIMITIVE_OVERRIDE_EXPRESSION_FIELD.
ERROR 000309: The value is not a field

Any assistance of how to construct the string for the symbology field arguments would be appreciated.

 

 

 

 

Attachments

Outcomes