If you select a north arrow in a layout in ArcGIS Pro and go to Symbol>Properties>Halo, you can set the halo property of a north arrow.
Does anyone know how to access this property programmatically in the ArcGIS Pro SDK?
<SPAN class="comment token">//I am assuming the selected item is a north arrow</SPAN> <SPAN class="keyword token">var</SPAN> northArrow <SPAN class="operator token">=</SPAN> LayoutView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetSelectedElements</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">First</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//CIMTopoNorthArrow is a different beast entirely...</SPAN> <SPAN class="keyword token">var</SPAN> cim <SPAN class="operator token">=</SPAN> northArrow<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> CIMMarkerNorthArrow<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//this halo symbol is 50% transparent, no outline (i.e. 0 width)</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>CIMPointSymbol<SPAN class="punctuation token">)</SPAN>cim<SPAN class="punctuation token">.</SPAN>PointSymbol<SPAN class="punctuation token">.</SPAN>Symbol<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>HaloSymbol <SPAN class="operator token">=</SPAN> SymbolFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConstructPolygonSymbol</SPAN><SPAN class="punctuation token">(</SPAN> SymbolFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConstructSolidFill</SPAN><SPAN class="punctuation token">(</SPAN>ColorFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateRGBColor</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">50</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> SymbolFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConstructStroke</SPAN><SPAN class="punctuation token">(</SPAN>ColorFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>BlackRGB<SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>CIMPointSymbol<SPAN class="punctuation token">)</SPAN>cim<SPAN class="punctuation token">.</SPAN>PointSymbol<SPAN class="punctuation token">.</SPAN>Symbol<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>HaloSize <SPAN class="operator token">=</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="comment token">//size of the halo</SPAN> <SPAN class="comment token">//set it back</SPAN> northArrow<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinition</SPAN><SPAN class="punctuation token">(</SPAN>cim<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Works great, thank you! I was casting northArrow.GetDefinition() as CIMNorthArrow which was just the same as accessing the NorthArrow property of NorthArrowStyleItem.
Two things that may help:
1. When working with the CIM, I often set a line like this in my code: var str = cim.ToXML();
Then, in the debugger, I set a breakpoint on that line and now I can hover over "str" and use the text or xml viewer built in to visual studio to examine "str". [I am not sure if you realize but the CIM definition is serializable to XML]. Note that the "type" of each element is shown in the XML as well as the structure.
2. Use the CIM Viewer. It is a utility we (Pro SDK team) wrote for examining the CIM. You can find it here: arcgis-pro-sdk-cim-viewer
It allows you to see the CIM definition of maps, layers, layouts, and layout elements as well as edit their xml.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.