Creating a Group with a List of Elements

109
2
02-07-2020 12:27 PM
AdamDavis
Occasional Contributor

Creating a group with a list of Elements works OK. If the group's name is changed then all the elements disappear into thin air.

Layout layout = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault()?.GetLayout();

List<Element> elements = new List<Element>();
for (int i = 0; i < 100; i++)
{
List<Coordinate2D> lineCoordinates = new List<Coordinate2D> { new Coordinate2D { X = i, Y = 0 }, new Coordinate2D { X = i, Y = 100 } };
Polyline polylineTic = PolylineBuilder.CreatePolyline(lineCoordinates);
CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 1.0, SimpleLineStyle.Solid);
GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, polylineTic, lineSym);
CIMElement cimElement = lineElm.GetDefinition();
cimElement.Name = "Line" + i;
lineElm.SetDefinition(cimElement);
elements.Add(lineElm);
}

GroupElement groupElement = LayoutElementFactory.Instance.CreateGroupElement(layout, elements);
CIMElement cimGroupElement = groupElement.GetDefinition();
cimGroupElement.Name = "First Level Group";
groupElement.SetDefinition(cimGroupElement);

Adam

0 Kudos
2 Replies
JeffBarrette
Esri Regular Contributor

Adam,

Thank you for reporting this.  I can also reproduce the crash when I create the command in 2.4 and use in 2.5.  Again, its a regression and we will address it immediately in 2.6 and hopefully address in a 2.5 patch.

In this case, I get slightly different results if I use .SetName().  The elements don't disappear, they get added to the root level. Similar to another scenario you reported.

Jeff - Layout team

0 Kudos
JeffBarrette
Esri Regular Contributor

This issue was addressed in Pro 2.7

0 Kudos