<?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 How to reference asset in Assets folder via Uri? in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222255#M2677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to read a local asset (.glb file) as a symbol into a SceneView in a Xamarin.Android AR project?&amp;nbsp; I'm using the Android template from here -&amp;nbsp;&lt;A class="link-titled" href="https://marketplace.visualstudio.com/items?itemName=Esri.EsriArcGISRuntimeARTemplates" title="https://marketplace.visualstudio.com/items?itemName=Esri.EsriArcGISRuntimeARTemplates"&gt;ArcGIS Runtime SDK for .NET - AR Templates - Visual Studio Marketplace&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the code, I get a File Not Found error on the ModelSceneSymbol.CreateAsync() line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;GraphicsOverlay planeOverlay = new GraphicsOverlay();&lt;BR /&gt; planeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;&lt;BR /&gt; arSceneView.GraphicsOverlays.Add(planeOverlay);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Uri modelSourceUri = new Uri(@"ms-appx:///Assets/Duck.glb");&lt;BR /&gt; var modelSymbol = await ModelSceneSymbol.CreateAsync(modelSourceUri, 1000);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;MapPoint location = new MapPoint(-71.0096, 42.3656, 20, SpatialReferences.Wgs84);&lt;BR /&gt; Graphic modelGraphic = new Graphic(location, modelSymbol);&lt;BR /&gt; planeOverlay.Graphics.Add(modelGraphic);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;The asset is in the Assets folder in the project.&amp;nbsp; I've tried different BuildActions on the file (AndroidAsset, Content), no luck.&amp;nbsp; I've tried different Uri schemes (&lt;A&gt;file:///&lt;/A&gt;) without luck.&amp;nbsp; I've also tried loading the asset from a url.&amp;nbsp; In this case I don't get an error, but the model doesn't render.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model I'm trying to load is this (also attached) -&amp;nbsp;&lt;A class="link-titled" href="https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Duck/glTF-Binary/Duck.glb" title="https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Duck/glTF-Binary/Duck.glb"&gt;glTF-Sample-Models/Duck.glb at master · KhronosGroup/glTF-Sample-Models · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference, in a WPF app I was able to do the same thing successfully with more or less the same code.&amp;nbsp; So essentially if its possible, what is the correct way to create a Uri to an asset?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Aug 2020 22:13:28 GMT</pubDate>
    <dc:creator>James_C_Dorsey</dc:creator>
    <dc:date>2020-08-20T22:13:28Z</dc:date>
    <item>
      <title>How to reference asset in Assets folder via Uri?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222255#M2677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to read a local asset (.glb file) as a symbol into a SceneView in a Xamarin.Android AR project?&amp;nbsp; I'm using the Android template from here -&amp;nbsp;&lt;A class="link-titled" href="https://marketplace.visualstudio.com/items?itemName=Esri.EsriArcGISRuntimeARTemplates" title="https://marketplace.visualstudio.com/items?itemName=Esri.EsriArcGISRuntimeARTemplates"&gt;ArcGIS Runtime SDK for .NET - AR Templates - Visual Studio Marketplace&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the code, I get a File Not Found error on the ModelSceneSymbol.CreateAsync() line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;GraphicsOverlay planeOverlay = new GraphicsOverlay();&lt;BR /&gt; planeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;&lt;BR /&gt; arSceneView.GraphicsOverlays.Add(planeOverlay);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Uri modelSourceUri = new Uri(@"ms-appx:///Assets/Duck.glb");&lt;BR /&gt; var modelSymbol = await ModelSceneSymbol.CreateAsync(modelSourceUri, 1000);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;MapPoint location = new MapPoint(-71.0096, 42.3656, 20, SpatialReferences.Wgs84);&lt;BR /&gt; Graphic modelGraphic = new Graphic(location, modelSymbol);&lt;BR /&gt; planeOverlay.Graphics.Add(modelGraphic);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;The asset is in the Assets folder in the project.&amp;nbsp; I've tried different BuildActions on the file (AndroidAsset, Content), no luck.&amp;nbsp; I've tried different Uri schemes (&lt;A&gt;file:///&lt;/A&gt;) without luck.&amp;nbsp; I've also tried loading the asset from a url.&amp;nbsp; In this case I don't get an error, but the model doesn't render.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model I'm trying to load is this (also attached) -&amp;nbsp;&lt;A class="link-titled" href="https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Duck/glTF-Binary/Duck.glb" title="https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Duck/glTF-Binary/Duck.glb"&gt;glTF-Sample-Models/Duck.glb at master · KhronosGroup/glTF-Sample-Models · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference, in a WPF app I was able to do the same thing successfully with more or less the same code.&amp;nbsp; So essentially if its possible, what is the correct way to create a Uri to an asset?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2020 22:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222255#M2677</guid>
      <dc:creator>James_C_Dorsey</dc:creator>
      <dc:date>2020-08-20T22:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference asset in Assets folder via Uri?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222256#M2678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ms-appx:/// path is a UWP type of path. It won't work in Android.&lt;/P&gt;&lt;P&gt;Android Assets are packaged with the app and can't be read directly. Typically you'll have to use the Android APIs to unpack the file to disk first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2020 23:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222256#M2678</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2020-08-20T23:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference asset in Assets folder via Uri?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222257#M2679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/3050"&gt;Morten Nielsen&lt;/A&gt;‌, you set me on the right path.&amp;nbsp; Ultimately I had to read the asset, write it back to internal storage, then use that path to create the Uri.&amp;nbsp; Also make sure your asset has a BuildAction of AndroidAsset. Here's what I used:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;GraphicsOverlay planeOverlay = new GraphicsOverlay();&lt;BR /&gt; planeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;&lt;BR /&gt; arSceneView.GraphicsOverlays.Add(planeOverlay);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// open stream from asset manager&lt;BR /&gt; Stream stream = Assets.Open("Duck.glb");&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// save back to data folder&lt;BR /&gt; var backingFile = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Duck.glb");&lt;BR /&gt; var fileStream = File.Create(backingFile);&lt;BR /&gt; stream.CopyTo(fileStream);&lt;BR /&gt; fileStream.Close();&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// create uri from newly saved file&lt;BR /&gt; Uri modelSourceUri = new Uri(backingFile, UriKind.Absolute);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;var modelSymbol = await ModelSceneSymbol.CreateAsync(modelSourceUri, 1000);&lt;BR /&gt; MapPoint location = new MapPoint(-71.0096, 42.3656, 20, SpatialReferences.Wgs84);&lt;BR /&gt; Graphic modelGraphic = new Graphic(location, modelSymbol);&lt;BR /&gt; planeOverlay.Graphics.Add(modelGraphic);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Aug 2020 03:48:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-reference-asset-in-assets-folder-via-uri/m-p/222257#M2679</guid>
      <dc:creator>James_C_Dorsey</dc:creator>
      <dc:date>2020-08-21T03:48:47Z</dc:date>
    </item>
  </channel>
</rss>

