AnsweredAssumed Answered

Save custom element problem ArcObject Add-in.

Question asked by tkoka3 on Apr 19, 2018
Latest reply on May 4, 2018 by tkoka3

Hi , 

I develope command with ArcObject SDK Add-in for 10.5 ArcMap.I created my own polygon element  (MyElement) inherit PolygonElementClass , IElement, IPersistStream for Index Maping jobs in ArcMap for customers .But I have problem when I save and open document after adding my Element (MyElement)  in GraphicsContainer.

 

Here is below  my class and adding to IGraphicsContainer codes. With below code I can Add my own element on the GraphicsContainer  but but after save this document ArcMap crashes and gives exception like below.

When I Add simple ArcObject Polygon element (IElement element = new PolygonElementClass()) there is not any problem when opening and save document.

 

How can I sove this problem ? Can you help to me ?İs It Add-in support save objects using like IPersistStream ? Here is the codes and pictures below:

 

Codes :

 

public class MyElement : PolygonElementClass , IElement, IPersistStream

{

 

  public IEnvelope Env

  public string Name 

.....

.....properties,functions.etc.

}

 

ICompositeGraphicsLayer cGLayer =  ArcMap.Document.FocusMap.BasicGraphicsLayer as ICompositeGraphicsLayer;
IGraphicsLayer gLayer = cGLayer.AddLayer("Scale_1:1000", null);

...seting scale graphicLayer (ex: 1:1000)

 

IGraphicsContainer gCont = gLayer as IGraphicsContainer;

foreach (MyElement myEl in myElArray)
{

gCont.AddElement(myEl,0);

}

Creating my Element:

Creating own Element

Exception after save and open document in Arcmap:

 

Exception

 

Thanks.

Best Regards.

Outcomes