<?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 Trying to change the fill color of a graphicelement... in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1505192#M11870</link>
    <description>&lt;P&gt;using following to change the fill color of graphicelement:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;// Access the CIM definition of the graphic element&lt;BR /&gt;var cimElement = graphicElement.GetDefinition() as CIMElement;&lt;BR /&gt;if (cimElement == null)&lt;BR /&gt;return;&lt;/P&gt;&lt;P&gt;// Get the current background symbol&lt;BR /&gt;var currentSymbol = graphicElement.GetGraphic().Symbol;&lt;/P&gt;&lt;P&gt;// Check if the symbol is a fill symbol&lt;BR /&gt;if (currentSymbol is CIMSymbolReference polygonSymbol)&lt;BR /&gt;{&lt;BR /&gt;// Change the fill color&lt;BR /&gt;polygonSymbol.Symbol = SymbolFactory.Instance&lt;BR /&gt;.ConstructPolygonSymbol(ColorFactory.Instance.CreateColor(newColor));&lt;/P&gt;&lt;P&gt;// Apply the modified symbol back to the GraphicElement&lt;BR /&gt;graphicElement.GetGraphic().Symbol = polygonSymbol;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Apply the changes back to the graphic element&lt;BR /&gt;graphicElement.SetDefinition(cimElement);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No compile/runtime error, but the color does not change on UI...&lt;BR /&gt;Any inputs..?&lt;BR /&gt;&lt;BR /&gt;Is there another way to change the color or flash/highlight a given graphicelement on a graphicslayer?&lt;/P&gt;</description>
    <pubDate>Sun, 14 Jul 2024 17:15:38 GMT</pubDate>
    <dc:creator>Gurunara</dc:creator>
    <dc:date>2024-07-14T17:15:38Z</dc:date>
    <item>
      <title>Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1505192#M11870</link>
      <description>&lt;P&gt;using following to change the fill color of graphicelement:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;// Access the CIM definition of the graphic element&lt;BR /&gt;var cimElement = graphicElement.GetDefinition() as CIMElement;&lt;BR /&gt;if (cimElement == null)&lt;BR /&gt;return;&lt;/P&gt;&lt;P&gt;// Get the current background symbol&lt;BR /&gt;var currentSymbol = graphicElement.GetGraphic().Symbol;&lt;/P&gt;&lt;P&gt;// Check if the symbol is a fill symbol&lt;BR /&gt;if (currentSymbol is CIMSymbolReference polygonSymbol)&lt;BR /&gt;{&lt;BR /&gt;// Change the fill color&lt;BR /&gt;polygonSymbol.Symbol = SymbolFactory.Instance&lt;BR /&gt;.ConstructPolygonSymbol(ColorFactory.Instance.CreateColor(newColor));&lt;/P&gt;&lt;P&gt;// Apply the modified symbol back to the GraphicElement&lt;BR /&gt;graphicElement.GetGraphic().Symbol = polygonSymbol;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Apply the changes back to the graphic element&lt;BR /&gt;graphicElement.SetDefinition(cimElement);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No compile/runtime error, but the color does not change on UI...&lt;BR /&gt;Any inputs..?&lt;BR /&gt;&lt;BR /&gt;Is there another way to change the color or flash/highlight a given graphicelement on a graphicslayer?&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2024 17:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1505192#M11870</guid>
      <dc:creator>Gurunara</dc:creator>
      <dc:date>2024-07-14T17:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1505204#M11871</link>
      <description>&lt;P&gt;You are close, - almost there. Use &lt;SPAN&gt;graphicElement.&lt;/SPAN&gt;SetGraphic(...) - &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11077.html" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11077.html&lt;/A&gt; - to apply the changes to the graphic symbol _back_ to the element. There is a code snippet there u can use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2024 20:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1505204#M11871</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2024-07-14T20:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1506782#M11888</link>
      <description>&lt;P&gt;Do the following?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;// Access the CIM definition of the graphic element&lt;BR /&gt;var cimElement = graphicElement.GetDefinition() as CIMElement;&lt;BR /&gt;if (cimElement == null)&lt;BR /&gt;return;&lt;/P&gt;&lt;P&gt;// Get the current background symbol&lt;BR /&gt;var currentSymbol = graphicElement.GetGraphic().Symbol;&lt;/P&gt;&lt;P&gt;// Check if the symbol is a fill symbol&lt;BR /&gt;if (currentSymbol is CIMSymbolReference polygonSymbol)&lt;BR /&gt;{&lt;BR /&gt;// Change the fill color&lt;BR /&gt;polygonSymbol.Symbol = SymbolFactory.Instance&lt;BR /&gt;.ConstructPolygonSymbol(ColorFactory.Instance.CreateColor(newColor));&lt;/P&gt;&lt;P&gt;// Apply the modified symbol back to the GraphicElement&lt;BR /&gt;graphicElement.GetGraphic().Symbol = polygonSymbol;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;graphicElement.SetGraphic(graphicElement.GetGraphic());&lt;/STRONG&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Apply the changes back to the graphic element&lt;BR /&gt;graphicElement.SetDefinition(cimElement);&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 18:12:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1506782#M11888</guid>
      <dc:creator>Gurunara</dc:creator>
      <dc:date>2024-07-18T18:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1506903#M11889</link>
      <description>&lt;P&gt;&lt;U&gt;No&lt;/U&gt;. This is the problem:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;graphicElement.GetGraphic().Symbol = polygonSymbol;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The CIM uses a transactional pattern. You get a local copy, &lt;U&gt;not&lt;/U&gt; a reference, of the deserialized state that u can modify (as needed) Changes must be _applied_ back via a commit. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, get the graphic (local copy) and &lt;STRONG&gt;_hold_&lt;/STRONG&gt; a reference (to that copy).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var graphic =&amp;nbsp;graphicElement.GetGraphic();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Next, apply your change to the copy whose reference you are holding:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;graphic.Symbol = polySymbol [or polySymbol.MakeSymbolReference() if u hv a symbol]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now, commit the change(s) made to the local copy &lt;STRONG&gt;&lt;EM&gt;_back_&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;graphicElement.SetGraphic(graphic);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 19:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1506903#M11889</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2024-07-18T19:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1507422#M11897</link>
      <description>&lt;P&gt;Gurunara, if this answers your question please mark this post as the solution, thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 19:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1507422#M11897</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2024-07-19T19:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to change the fill color of a graphicelement...</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1514160#M11930</link>
      <description>&lt;P&gt;Got it to work (based on feedback):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;// Check if the symbol is a fill symbol&lt;BR /&gt;if (currentSymbol is CIMSymbolReference polygonSymbol)&lt;BR /&gt;{&lt;BR /&gt;// Change the fill color&lt;BR /&gt;polygonSymbol.Symbol = SymbolFactory.Instance&lt;BR /&gt;.ConstructPolygonSymbol(ColorFactory.Instance.CreateColor(newColor));&lt;/P&gt;&lt;P&gt;var graphic = graphicElement.GetGraphic();&lt;/P&gt;&lt;P&gt;graphic.Symbol = polygonSymbol;&lt;/P&gt;&lt;P&gt;// Apply the changes back to the graphic element&lt;BR /&gt;graphicElement.SetGraphic(graphic);&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 13:57:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/trying-to-change-the-fill-color-of-a/m-p/1514160#M11930</guid>
      <dc:creator>Gurunara</dc:creator>
      <dc:date>2024-08-02T13:57:52Z</dc:date>
    </item>
  </channel>
</rss>

