This project has moved and is read-only. For the latest updates, please go here.

Programmatically add shape, then move shape by mouse, error happen.

May 7, 2016 at 4:26 AM
Dear sir,

I am trying to add shape in Basic Tour 4 project, like this:

Polyline arrow = (Polyline)project1.ShapeTypes["Polyline"].CreateInstance();

referringShape = (RectangleBase)project1.ShapeTypes["Ellipse"].CreateInstance();

the shape can be added to diagram,
then I select that shape, and try to move it, error happen:
"Shape does not exist in the repository or is already deleted."

hope you can reproduce it.
Which step did I miss for adding shape programming?

May 9, 2016 at 12:13 PM
Do you call
after creating the shapes like shown in Step 3?
This is necessary not only for saving but also when trying to manipulate shapes with tools from the NShape toolbox (like the PointerTool).
May 15, 2016 at 9:04 AM
yes, I found the solution:
after every shape inserted, I call
_project.Repository.InsertAll((Dataweb.NShape.Shape)polyline, CurrentDisplay.Diagram);


What if I have 1000 shapes, do I need call 1000 times
_project.Repository.InsertAll((Dataweb.NShape.Shape)polyline, CurrentDisplay.Diagram);
or I just I call
once ?

Thanks advance.
May 25, 2016 at 8:49 AM
Edited May 25, 2016 at 8:49 AM
InsertAll(polyLine, diagram) will insert the given polyLine only.
InsertAll(diagram) will insert the diagram object itself and all its shapes.

Regarding your question:
Yes, you would have to call InsertAll() 1001 times - one call for each shape and one call for the diagram object.