AnsweredAssumed Answered

Create a graphic with name

Question asked by modybsystematics-co-il-esridist Employee on Oct 6, 2020
Latest reply on Oct 15, 2020 by UHarano-esristaff

Hi All

 

I am trying to create a graphic element with code and then to get the element by the name.

Code example below.

The FindElement does not find anything.

Open the element in Pro show that the name is still the default.

In all the samples of FindElement it looks by default names (Point, Point 1, etc).

Is it a bug??

 

Thanks

Mody

 

QueuedTask.Run(() =>
{
//Place symbol in the center of the map
var extent = MapView.Active.Extent;
var location = extent.Center;

//specify a symbol
var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol(
ColorFactory.Instance.GreenRGB);

//create a CIMGraphic
var graphic = new CIMPointGraphic()
{
Symbol = pt_symbol.MakeSymbolReference(),
Location = location, //center of map
};
graphic.Name = "Mody";
graphicsLayer.AddElement(graphic);
var elems = graphicsLayer.FindElements(new List<string>() { "Mody"})[0];

});

Outcomes