<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091251#M44734</link>
    <description>&lt;P&gt;I just ran this toolbox and it applies the symbology to the output, what version of Pro are you working with?&lt;/P&gt;</description>
    <pubDate>Mon, 23 Aug 2021 14:55:54 GMT</pubDate>
    <dc:creator>HannesZiegler</dc:creator>
    <dc:date>2021-08-23T14:55:54Z</dc:date>
    <item>
      <title>ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090734#M44679</link>
      <description>&lt;P&gt;Dear esri community,&lt;/P&gt;&lt;P&gt;I am rather new to ArcGIS Pro, but have really good experience with Python.&lt;/P&gt;&lt;P&gt;Now I created my first little toolbox with a script with takes an input feature layer and creates another output feature layer from the input by just taking a random sample of features from it.&lt;/P&gt;&lt;P&gt;This works fine, but now I also want to apply the same symbology from the input feature layer to the new created output feature layer.&lt;/P&gt;&lt;P&gt;Therefore I execute &lt;FONT face="courier new,courier"&gt;ApplySymbologyFromLayer_management&lt;/FONT&gt;&amp;nbsp;at the end of the script.&lt;/P&gt;&lt;P&gt;This runs without an error, but doesn't update/change the&amp;nbsp;symbology of the new created output feature layer.&lt;/P&gt;&lt;P&gt;Interesting is, if I call the same statement (&lt;FONT face="courier new,courier"&gt;ApplySymbologyFromLayer_management&lt;/FONT&gt;) inside the Python command prompt of ArcGIS Pro it works.&lt;/P&gt;&lt;P&gt;I also tried to execute the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ApplySymbologyFromLayer_management&lt;/FONT&gt; command inside a second script of my toolbox, but this also doesn't work.&lt;/P&gt;&lt;P&gt;Anyone has an idea what's the problem?&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090734#M44679</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-08-20T09:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090738#M44681</link>
      <description>&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDExNjUyNw==" target="_blank"&gt;BUG-000116527: ApplySymbologyFromLayer in a Python script in ArcGIS.. (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;perhaps&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:40:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090738#M44681</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-08-20T09:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090742#M44682</link>
      <description>&lt;P&gt;Thanks for your fast reply. Yeah, this could be the reason. Thanks! Than I have to wait until it will be fixed.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090742#M44682</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-08-20T09:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090858#M44694</link>
      <description>&lt;P&gt;Hi dstrigl, could you try using this approach:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

params = arcpy.GetParameterInfo()
inlyr = params[0]
outlyr = params[1]

res = arcpy.management.Copy(inlyr.valueAsText, outlyr.valueAsText)
outlyr.symbology = inlyr.valueAsText&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set your tool's parameters like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HannesZiegler_0-1629479326445.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/21259iA1270A90B5D1C94A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HannesZiegler_0-1629479326445.png" alt="HannesZiegler_0-1629479326445.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above approach is described &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/setting-output-symbology-in-scripts.htm" target="_self"&gt;here&lt;/A&gt; and works in my testing.&lt;/P&gt;&lt;P&gt;Please let me know if this solution works for you!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 17:08:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1090858#M44694</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2021-08-20T17:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091164#M44732</link>
      <description>&lt;P&gt;Hi Hannes,&lt;/P&gt;&lt;P&gt;thanks for your response.&lt;/P&gt;&lt;P&gt;Sorry, but your solution doesn't work in my toolbox script.&lt;/P&gt;&lt;P&gt;Maybe, it's my fault because at the moment I am not so really familiar with the different types of Python scripts in ArcGIS Pro (.tbx and .pyt) and the different data types.&lt;/P&gt;&lt;P&gt;At the moment I have created my own little toolbox with the following Python code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import random
import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "MyToolbox"
        self.alias = ""

        # List of tool classes associated with this toolbox
        self.tools = [SelectSampleByPercent]

class SelectSampleByPercent(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "SelectSampleByPercent"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""

        # First parameter
        param0 = arcpy.Parameter(
            displayName="Input Features",
            name="in_features",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input",
        )

        # Second parameter
        param1 = arcpy.Parameter(
            displayName="Proportion of sample (in %)",
            name="in_range",
            datatype="GPLong",
            parameterType="Required",
            direction="Input",
        )
        param1.filter.type = "Range"
        param1.filter.list = [0, 100]
        param1.value = 10

        # Third parameter
        param2 = arcpy.Parameter(
            displayName="Output Features",
            name="out_features",
            datatype="DEFeatureClass",
            parameterType="Required",
            direction="Output",
        )

        params = [param0, param1, param2]

        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        arcpy.env.overwriteOutput = True

        in_features = parameters[0].value
        percent = parameters[1].value
        out_features = parameters[2].value

        in_catalog_path = arcpy.Describe(in_features).catalogPath

        feature_count = arcpy.GetCount_management(in_catalog_path).getOutput(0)
        count = int(float(feature_count) * float(percent) / 100.0)

        oids = [oid for oid, in arcpy.da.SearchCursor(in_catalog_path, "OID@")]

        oid_field_name = arcpy.Describe(in_catalog_path).OIDFieldName

        random_oids = random.sample(oids, count)
        oids_str = ", ".join(map(str, random_oids))

        sql_exp = f"{arcpy.AddFieldDelimiters(in_catalog_path, oid_field_name)} IN ({oids_str})"

        arcpy.Select_analysis(in_catalog_path, out_features, sql_exp)
        arcpy.management.ApplySymbologyFromLayer(arcpy.Describe(out_features).baseName, in_features)

        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe you see some errors inside the script?!&lt;/P&gt;&lt;P&gt;I would like to pick some samples (randomly from the source feature layer) and write it to another new output layer, together with the original symbology from the source layer.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 10:32:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091164#M44732</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-08-23T10:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091251#M44734</link>
      <description>&lt;P&gt;I just ran this toolbox and it applies the symbology to the output, what version of Pro are you working with?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 14:55:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091251#M44734</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2021-08-23T14:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091253#M44735</link>
      <description>&lt;P&gt;ArcGIS Pro 2.6.5&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 14:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091253#M44735</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-08-23T14:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091259#M44736</link>
      <description>&lt;P&gt;Are you constrained to 2.6.5, or are you able to upgrade to a more recent version?&lt;/P&gt;&lt;P&gt;For 2.7 and greater you may also try &lt;A href="https://pro.arcgis.com/en/pro-app/2.7/arcpy/functions/setparametersymbology.htm" target="_self"&gt;arcpy.setParameterSymbology&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SetParameterSymbology(2, in_features)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 15:11:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1091259#M44736</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2021-08-23T15:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1092574#M44842</link>
      <description>&lt;P&gt;Hi Hannes,&lt;/P&gt;&lt;P&gt;thanks again for your response!&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;I just ran this toolbox and it applies the symbology to the output&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That's great to hear &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;gt;&amp;nbsp;Are you constrained to 2.6.5, or are you able to upgrade to a more recent version?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have to verify and try to get an newer version. Afterwards I will try again and give you feedback.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks and regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Daniel.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 05:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1092574#M44842</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-08-26T05:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management inside toolbox script doesn't work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1110677#M47124</link>
      <description>&lt;P&gt;ApplySmbologyfromLayer is still very buggy even in 2.8.1&lt;BR /&gt;I can get some layers to work if I create the LYRX files from layers with a different name but not all of them&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 03:37:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/applysymbologyfromlayer-management-inside-toolbox/m-p/1110677#M47124</guid>
      <dc:creator>LeandraGordon</dc:creator>
      <dc:date>2021-10-25T03:37:06Z</dc:date>
    </item>
  </channel>
</rss>

