Deleting vertices of a polygon that is dynamically added with RigidPolygon() command

amvukovic shared this question 4 years ago

Hm... where to start? ;-)

So, in short: a have a polygon (named "plocica") which I dynamically duplicate using RigidPolygon() command. Here's a GeoGebra code (On Click):


index=index+1; --> a number for tracking the number of dynamically added tiles

ploca=RigidPolygon(plocica, 3, 0);

SetLayer(ploca, 1);

SetColor( ploca, 1, 0, 0);

SetLineThickness( ploca, 2);

SetFilling( ploca, 0.75);

Rename(Vertex(ploca, 1),"P_"+CopyFreeObject(index));

Rename(Vertex(ploca, 2),"R_"+CopyFreeObject(index));

Rename(Vertex(ploca, 3),"S_"+CopyFreeObject(index));

Rename(Vertex(ploca, 4),"T_"+CopyFreeObject(index));



When you make a copy this way, a new polygon is added to construction, four polygon vertices and four polygon sides as well. If I delete a polygon, the sides are automatically deleted, but this is not the case with the vertices. Since I don't know the names that will GeoGebra automatically give to the new vertices...

I've tried to reach them with the Vertex() command. But now I have 8 point for each new added polygon!!! :‑( See pic in attachment.

I want to be able to delete all added objects and the polygon vertices as well. I want to do it with GeoGebra scripting, not using JavaScript.

Basically, I don't have a clue at the moment how to reach the new added polygon's vertices names to be able to delete them afterwards.

Thanks in advance

Best regards

Aleksandra-Maria Vuković

Comments (3)



I have one solution (see ggb attached) but the type of command like : SetColor( ploca, 1, 0, 0); does not work.



I think that's possible (robustly) only with JavaScript, eg


puedes crear una copia de los vertices del poligono y entonces usar rigidpolygon(point..........point)

cuando necesites borrar el poligono rigido te basta con borrar los puntos, de los cuales, ahora, sí sabes el nombre

© 2023 International GeoGebra Institute