
//Remo: 24.11.2013
{
	BaseDocument *doc = GetActiveDocument();	if(!doc)  return false;
	BaseObject *obj = doc->GetActiveObject();	
	if(!obj) obj = doc->GetFirstObject();
	if(!obj) return false;

	if(obj->IsInstanceOf(Opolygon)){
		PolygonObject* pob = ToPoly(obj);
		const LONG pcnt = pob->GetPointCount();
		const Vector *padr = pob->GetPointR();

		doc->StartUndo();

		AutoAlloc<BaseObject> nop(Onull); if(!nop)  return false;
		doc->AddUndo(UNDOTYPE_NEW,nop);

		nop->SetName("NULL "+pob->GetName());

		for(LONG i=0; i<pcnt; ++i)
		{
			AutoAlloc<BaseObject> sop(Osphere); if(!sop)  return false;
			doc->AddUndo(UNDOTYPE_NEW,sop);

			sop->SetPhong(true,true,Rad(80.0));
			sop->SetRelPos(padr[i]);
			sop->SetParameter(DescID(PRIM_SPHERE_RAD),GeData(10.0),DESCFLAGS_SET_0);
			sop->SetParameter(DescID(PRIM_SPHERE_TYPE),GeData(4),DESCFLAGS_SET_0);
			sop->SetName("Sphere_"+LongToString(i));

			doc->InsertObject(sop.Release(),nop,nullptr);
		}
		doc->InsertObject(nop.Release(),nullptr,nullptr);

		doc->EndUndo();
		EventAdd();
	}
}