I am trying to retrieve the clipping extent that I defined in the Map Properties > Clip Layers. I found there are a couple properties from CIMMap such as ClippingMode and LayersExcludedFromClipping that indicate that we are clipping layers. GetCustomFullExtent() from the MapView.Map and CIMMap classes only retrieve the custom extent defined in the Extent Map Properties, which may be different than the extent define in Clip Layers. Is there a class or method that can retrieve the actual clipping layer extent?
Thank you in advance,
Greetings. I am a colleague of Hannah, and I believe we have found a solution. The case we are concerned with is when CIMMap.ClippingMode = CustomShape, which occurs when through the UI you go to map properties, Clip Layers, and use one of the custom clipping modes. When in this mode, the CIMMap.CustomClippingShapeURI returns a string of the form:
We found this file residing under %TEMP%. Is there an API call that will assist in constructing the absolute path to this file, or can we simply rely on finding it in a consistent location under %TEMP%?
Our objective is to retrieve the custom clipping shape, and through experimentation we discovered that the contents of the file is the geometry in EsriShape binary format. The code below retrieves the geometry from the URI. Do you see any potential problems with what we're doing here? Thanks!
string path = "C:\\Temp\\61ef717a9e874218e6fcf85c78f9497e.dat";
byte buffer = File.ReadAllBytes(path);
EsriShapeImportFlags importFlags = EsriShapeImportFlags.esriShapeImportDefaults;
Polygon clip_poly = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, SpatialReferences.WGS84) as Polygon;
Hi Jamal. Yes, I've looked through your post. We aren't trying to set the clip shape, but retrieve what was set through the UI. I was hoping the API would just give me the shape.
oh, ok. Yea I doubt there is a way because the file is randomly generated it seems. You could possibly set something to clear that directory everytime you set a clip shape and then read the 1 file generated when you set it. Or just read the last file generated in the Temp directory.