The following code works beautifully the first time the function is called. The second time the function is called, the new second parameter value, Forest_TmbrVol_Source, is ignored while the new first parameter value, Project_TmbrVol_Path, is correctly used.
The result is that in both function calls, the input layer is symbolized by the same Forest_SlopePrc_Source symbology, which in the second call, results in Timber Volume being symbolized with Slope Percentage symbology rather than Timber Volume symbology as coded.
This error is not a result of duplicate names or incorrectly called vars. I coded messages to return the values of what was passed and processed and there are no errors there. The problem appears to be the persistence of the same initial variable used in the ApplySymbologyFromLayer tool for the reference symbology raster.
Reversing the order of the two calls, does not change this behavior. The mismatch in the 2nd call continues, but reversed., such that the input layer is incorrectly symbolized by Forest_TimbVol_Source rather than Forest_SlopePrc_Source symbology as coded.
Image content:
Apply Symbology From Layer (Data Management)—ArcGIS Pro | Documentation
The "optional" parameter describes the situations where symbology won't be updated.
Can you confirm that this doesn't apply?
Update_symbology
(Optional)
Specifies whether symbology ranges will be updated.
DEFAULT—Symbology ranges will be updated, except in the following situations:
When the input layer is empty
When the symbology layer uses class breaks (for example, graduated colors or graduated symbols) and the classification method is manual or defined interval
When the symbology layer uses unique values and the Show all other values option is checked
UPDATE—Symbology ranges will be updated.
MAINTAIN—Symbology ranges will not be updated; they will be maintained.
As for code formatting to facilitate reading and line number referencing, have a look at...
Code formatting ... the Community Version - Esri Community
The code works without issue if I run the code for only one call.
The problem occurs when I run the code for multiple calls in a row.
def applysymbology(inlayer, outlayer):
some code
applysymbology(xy,yy)
applysymbology(ss,tt)
The first call works without issue.
The second call applies symbology from yy instead of tt!
What's tempSymbRaster? it seems to be defined outside of your function. I think that's the culprit.
Miscopy of actual code on my part. I corrected the mis-identified var name in my post. Thanks
something is persisting then between runs. At this point all I can suggest is adding a Save Project between the two runs to see if it "clears".
If that doesn't work, then Tech Support is your best bet
As soon as I can get the VDI to run (it's very temperamental today), I will try adding a Save Project.
Update:
If anyone knows of a better workaround. Please advise!!
I could not find a workaround, other than to separate my code into 2 files, and apply the symbology manually in-between. The first file contains the code up to apply symbology and the second file containing the code after I manually apply symbology. Not happy. Hope ESRI will fix the tool soon.
Not the solution!My workaround was to simply delete the parameter variables at the end of the code and then there was no issue with persistence.
def applysymbology(in, out): some code del in del out
applysymbology(xy,yy)applysymbology(ss,tt)