<?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 Setting Source URI on PictureElement not working in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/setting-source-uri-on-pictureelement-not-working/m-p/1259334#M65670</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Today I was trying to programatically set the source uri (local filepath) of a&amp;nbsp;ArcGIS.Desktop.Layouts.PictureElement with the provided SetSourcePath() SDK method. Unfortunately this seems to have no effect at all. The PictureElement on the layout remains empty without any feedback.&lt;/P&gt;&lt;P&gt;After I looked at the implementation of the SetSourcePath() Method, I could implement it by myself.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void SetPictureSource(string uri)
{
    // SDK call '_pictureElement.SetSourcePath(uri)' not working
    _pictureElement.SetSourcePath(uri);

    // manually setting source url over cim definition working
    QueuedTask.Run(() =&amp;gt;
    {
        var definition = _pictureElement.GetDefinition();
        if (definition is CIMGraphicElement graphicElement &amp;amp;&amp;amp;
            graphicElement.Graphic is CIMPictureGraphic pictureGraphic)
        {
            pictureGraphic.SourceURL = uri;
            graphicElement.Graphic = pictureGraphic;
            _pictureElement.SetDefinition(graphicElement);
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SDK implementation almost looks the same but its setting&amp;nbsp;PictureURL instead of SourceURL.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// SDK Implementation
public void SetSourcePath(string URI)
{
    LayoutUtil.EnsureWorkerThread();
    string fullPath = Path.GetFullPath(URI);
    if (!File.Exists(fullPath))
    {
        throw new Exception("Invalid Picture path");
    }

    ElementUtil.UpdateElement(_container, base.Name, Resources.OperationUpdatePictures, delegate (CIMElement cimElement)
    {
        CIMPictureGraphic cIMPictureGraphic = (cimElement as 
        CIMGraphicElement).Graphic as CIMPictureGraphic;
        if (cIMPictureGraphic != null)
        {
             cIMPictureGraphic.PictureURL = fullPath;
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a SDK Bug or do I use the method the wrong way? Would appreciate any response.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2023 14:59:04 GMT</pubDate>
    <dc:creator>marco_vertigis</dc:creator>
    <dc:date>2023-02-17T14:59:04Z</dc:date>
    <item>
      <title>Setting Source URI on PictureElement not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/setting-source-uri-on-pictureelement-not-working/m-p/1259334#M65670</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Today I was trying to programatically set the source uri (local filepath) of a&amp;nbsp;ArcGIS.Desktop.Layouts.PictureElement with the provided SetSourcePath() SDK method. Unfortunately this seems to have no effect at all. The PictureElement on the layout remains empty without any feedback.&lt;/P&gt;&lt;P&gt;After I looked at the implementation of the SetSourcePath() Method, I could implement it by myself.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void SetPictureSource(string uri)
{
    // SDK call '_pictureElement.SetSourcePath(uri)' not working
    _pictureElement.SetSourcePath(uri);

    // manually setting source url over cim definition working
    QueuedTask.Run(() =&amp;gt;
    {
        var definition = _pictureElement.GetDefinition();
        if (definition is CIMGraphicElement graphicElement &amp;amp;&amp;amp;
            graphicElement.Graphic is CIMPictureGraphic pictureGraphic)
        {
            pictureGraphic.SourceURL = uri;
            graphicElement.Graphic = pictureGraphic;
            _pictureElement.SetDefinition(graphicElement);
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SDK implementation almost looks the same but its setting&amp;nbsp;PictureURL instead of SourceURL.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// SDK Implementation
public void SetSourcePath(string URI)
{
    LayoutUtil.EnsureWorkerThread();
    string fullPath = Path.GetFullPath(URI);
    if (!File.Exists(fullPath))
    {
        throw new Exception("Invalid Picture path");
    }

    ElementUtil.UpdateElement(_container, base.Name, Resources.OperationUpdatePictures, delegate (CIMElement cimElement)
    {
        CIMPictureGraphic cIMPictureGraphic = (cimElement as 
        CIMGraphicElement).Graphic as CIMPictureGraphic;
        if (cIMPictureGraphic != null)
        {
             cIMPictureGraphic.PictureURL = fullPath;
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a SDK Bug or do I use the method the wrong way? Would appreciate any response.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 14:59:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/setting-source-uri-on-pictureelement-not-working/m-p/1259334#M65670</guid>
      <dc:creator>marco_vertigis</dc:creator>
      <dc:date>2023-02-17T14:59:04Z</dc:date>
    </item>
  </channel>
</rss>

