public void SetDefinition( CIMElement cimElement )
Public Sub SetDefinition( _ ByVal cimElement As CIMElement _ )
Parameters
- cimElement
- CIMElement
public void SetDefinition( CIMElement cimElement )
Public Sub SetDefinition( _ ByVal cimElement As CIMElement _ )
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method must be called within the lambda passed to QueuedTask.Run. |
//Modify an element's CIM properties. //Perform on the worker thread await QueuedTask.Run(() => { CIMElement CIMElm = element.GetDefinition(); //Modify a CIM value element.SetDefinition(CIMElm); });
//Modify an existing tableframe using CIM properties. //Reference the active layout Layout layout = LayoutView.Active.Layout; //Perform on the worker thread await QueuedTask.Run(() => { //Reference table frame TableFrame TF = layout.FindElement("Table Frame") as TableFrame; //Modify CIM properties CIMTableFrame cimTF = TF.GetDefinition() as CIMTableFrame; cimTF.Alternate1RowBackgroundCount = 1; cimTF.Alternate2RowBackgroundCount = 1; //Apply the changes TF.SetDefinition(cimTF); });
//Set the CIM halo properties of a north arrow. //Reference the first selected element (assumption is it is a north arrow) Element northArrow = LayoutView.Active.GetSelectedElements().First(); //Perform on the worker thread QueuedTask.Run(() => { //Get definition of north arrow... var cim = northArrow.GetDefinition() as CIMMarkerNorthArrow; //this halo symbol is 50% transparent, no outline (i.e. 0 width) //First construct a polygon symbol to use in the Halo //Polygon symbol will need a fill and a stroke var polyFill = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0, 0, 0, 50)); var polyStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 0); var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(polyFill, polyStroke); //Set the north arrow definition of HaloSymbol and HaloSize ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSymbol = haloPoly; ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSize = 3;//size of the halo //Apply the CIM changes back to the element northArrow.SetDefinition(cim); });
//Apply a background color to the map frame element using the CIM. //Perform on the worker thread QueuedTask.Run(() => { //Get the layout var myLayout = Project.Current.GetItems<LayoutProjectItem>()?.First().GetLayout(); if (myLayout == null) return; //Get the map frame in the layout MapFrame mapFrame = myLayout.FindElement("New Map Frame") as MapFrame; if (mapFrame == null) { //TODO Handle null mapframe return; } //Get the map frame's definition in order to modify the background. var mapFrameDefn = mapFrame.GetDefinition() as CIMMapFrame; //Construct the polygon symbol to use to create a background var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.BlueRGB, SimpleFillStyle.Solid); //Set the background mapFrameDefn.GraphicFrame.BackgroundSymbol = polySymbol.MakeSymbolReference(); //Set the map frame definition mapFrame.SetDefinition(mapFrameDefn); });
// The Locked property is displayed in the TOC as a lock symbol next // to each element. If locked the element can't be selected in the layout // using the graphic selection tools. //Perform on the worker thread QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { //Reference an element by name Element element = layout.FindElement("MyElement"); if (element != null) { // Modify the Locked property via the CIM CIMElement CIMElement = element.GetDefinition() as CIMElement; CIMElement.Locked = true; element.SetDefinition(CIMElement); } } });
Target Platforms: Windows 11, Windows 10