Hey,
I am currently looking into the possibilty of accessing a ArcGIS Pro Project from the "outside" using the ArcGIS Pro SDK.
What I mean by that is that is that I don't want to access the "current" project using an AddIn, but instead use the Core-Assembly to access the content of a project from the outside, similar to what arcpy does by using soemthing like this:
aprx = arcpy.mp.ArcGISProject(r"Path_to_my_project\project.aprx")
During my own research I could not find anything about it, so I wanted to make sure that its not possible by posting my question here.
Many thanks in advance!
Solved! Go to Solution.
The aprx file is a zip file containing xml which can be deserialized as CIM objects. Last I checked this is also "core" in the sense that it can be run with dotnet core (apparently no license initialization required).
private static void Test()
{
string aprxFile = @"D:\ArcPro_Projects\Naperville\Naperville.aprx";
using (ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(aprxFile))
{
foreach (var entry in archive.Entries
.Where(e => !e.FullName.StartsWith("Metadata/"))
.Where(e => e.FullName.EndsWith(".xml")))
{
try
{
using (var strm = new StreamReader(entry.Open()))
{
var xml = strm.ReadToEnd();
var obj = CIMObject.FromXml(xml);
Debug.Print($"type: {obj}");
}
}
catch(Exception ex)
{
Debug.Print($"error {entry.FullName} : {ex.Message}");
}
}
}
}
The aprx file is a zip file containing xml which can be deserialized as CIM objects. Last I checked this is also "core" in the sense that it can be run with dotnet core (apparently no license initialization required).
private static void Test()
{
string aprxFile = @"D:\ArcPro_Projects\Naperville\Naperville.aprx";
using (ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(aprxFile))
{
foreach (var entry in archive.Entries
.Where(e => !e.FullName.StartsWith("Metadata/"))
.Where(e => e.FullName.EndsWith(".xml")))
{
try
{
using (var strm = new StreamReader(entry.Open()))
{
var xml = strm.ReadToEnd();
var obj = CIMObject.FromXml(xml);
Debug.Print($"type: {obj}");
}
}
catch(Exception ex)
{
Debug.Print($"error {entry.FullName} : {ex.Message}");
}
}
}
}