Hello, Eduard!
Generally, functions presentation.add() and presentation.remove() work correctly for all presentation shapes. I thnik in
your case the problem is the following.
You placed code:
ShapeLine A=new ShapeLine();
presentation.add(A);
somewhere in the model (for example, into [button1.onClick] callback), and code:
presentation.remove(A);
in diffrerent place (for example, into [button2.onClick] callback). So, variable [A] is not visible in second procedure,
because it was created in the first one. What I recommend you is:
Make the variable visible for both procedures, for example, create a variable of type [Shape] in [Main] object so that
you can refer to it from any place of the [Main] code.
But, in case you need multiple lines to be dynamically created and removed, it is strongly recommended to use replicated
[Line] objects. See "Shape Replication" chapter of AnyLogic 6 Help.

