op->Remove(); doesnt remove the object at all
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/01/2011 at 09:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) : C.O.F.F.E.E ;---------
Hi,I'm having some trouble with the Remove-Function of the BaseList2D class.
When i call this function, the object will be removed from the document, as it should be.
But the variable still contains the object.
I want to use this variable again, so it should be overwritten with a new defintion, but anything i do, it won't work.I have an object that should be removed. The new Object is later allocated in the same variable.
But anything i do, its like the old object is kept.var doc = GetActiveDocument(); var op, bc; op = doc->GetActiveObject(); if (op) { op->Remove(); doc->MultiMessage(MSG_UPDATE); } op = AllocObject(Ocube); bc = op->GetContainer(); doc->InsertObject(op,null,null); ///Make Editable doc->SetActiveObject(op); SendModelingCommand(MCOMMAND_MAKEEDITABLE, doc, op, bc, MODIFY_ALL); op = doc->GetActiveObject(); bc = op->GetContainer(); Subdivider(op,true,2,true); //A function i declared to subdive
The result i recieve, is that the old object gets subdivided, not the new cube. And i just don't get why and how i can prevent from this.
The very strange is, if I change the variable for just the active object which gets removed, the result is the same O.o
thanks in advance, nux
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/01/2011 at 12:06, xxxxxxxx wrote:
The variable still contains the object because you may want to insert it somewhere else.
When I use your script without the last line (since you didn't include the method), it works fine: I get an editable cube, and my original object is gone. Looks fine to me. Can't really see an error on first glance either.
But what does your Subdivider method do? Does it perhaps access the original object somehow?
Please post the full code for a check...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/01/2011 at 00:11, xxxxxxxx wrote:
Hm, strange.
Here is the code of the Subdivider Function. It also displaces the polygons and so on.
Subdivider(op,sub,subdivs,round) { var doc = GetActiveDocument(); var bc = new(BaseContainer); var i; for (i=0; i <= op->GetPolygonCount(); i++){ var RockPoly = new(BaseSelect); RockPoly->Select((int(polyrand->Get01() * i))); op->SetPolygonSelection(RockPoly); bc->SetData(MDATA_NORMALMOVE_VALUE , (int(polyrand->Get01() * i))*edt_destruct/100/(edt_subdivs+1)); SendModelingCommand(ID_MODELING_NORMALMOVE_TOOL, NULL, op, bc, MODIFY_POLYGONSELECTION); } bc->SetData(MDATA_SUBDIVIDE_HYPER, round); bc->SetData(MDATA_SUBDIVIDE_ANGLE, PI); bc->SetData(MDATA_SUBDIVIDE_SUB, 1); SendModelingCommand(MCOMMAND_SUBDIVIDE, NULL, op, bc, MODIFY_ALL); if (sub == true && subdivs > 0) { bc->SetData(MDATA_SUBDIVIDE_HYPER, round); bc->SetData(MDATA_SUBDIVIDE_ANGLE, PI); bc->SetData(MDATA_SUBDIVIDE_SUB, subdivs); SendModelingCommand(MCOMMAND_SUBDIVIDE, NULL, op, bc, MODIFY_ALL); } bc->SetData(MDATA_SETVALUE_SETX, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_SETY, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_SETZ, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_VAL, vector(edt_shapesmooth+10,edt_shapesmooth+10,edt_shapesmooth+10)); SendModelingCommand(ID_MODELING_SETVALUE_TOOL, doc, op, bc, MODIFY_ALL); }
cheers, nux
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/01/2011 at 02:31, xxxxxxxx wrote:
Sorry - cannot confirm.
I put it all into a simple script in the script manager, added some initialization and stuff that was not declared, made proper outputs... the object that is assigned to "op" is a cube, stays a cube, is subdivided as a cube. The original (deleted) object is gone. No error so far.
I tried it single, in hierarchies, with nulls, with various objects, no errors. I can't see a coding error either.
Subdivider(op,sub,subdivs,round) { println("Pt4: " + op->GetName()); var polyrand = new(Random); polyrand->Init(8374946); var edt_destruct = 1; var edt_subdivs = 1; var edt_shapesmooth = 1; var doc = GetActiveDocument(); var bc = new(BaseContainer); var i; for (i=0; i <= op->GetPolygonCount(); i++){ var RockPoly = new(BaseSelect); RockPoly->Select((int(polyrand->Get01() * i))); op->SetPolygonSelection(RockPoly); bc->SetData(MDATA_NORMALMOVE_VALUE , (int(polyrand->Get01() * i))*edt_destruct/100/(edt_subdivs+1)); println("Pt5: " + op->GetName()); SendModelingCommand(ID_MODELING_NORMALMOVE_TOOL, NULL, op, bc, MODIFY_POLYGONSELECTION); } bc->SetData(MDATA_SUBDIVIDE_HYPER, round); bc->SetData(MDATA_SUBDIVIDE_ANGLE, PI); bc->SetData(MDATA_SUBDIVIDE_SUB, 1); SendModelingCommand(MCOMMAND_SUBDIVIDE, NULL, op, bc, MODIFY_ALL); if (sub == true && subdivs > 0) { bc->SetData(MDATA_SUBDIVIDE_HYPER, round); bc->SetData(MDATA_SUBDIVIDE_ANGLE, PI); bc->SetData(MDATA_SUBDIVIDE_SUB, subdivs); SendModelingCommand(MCOMMAND_SUBDIVIDE, NULL, op, bc, MODIFY_ALL); } bc->SetData(MDATA_SETVALUE_SETX, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_SETY, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_SETZ, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); bc->SetData(MDATA_SETVALUE_VAL, vector(edt_shapesmooth+10,edt_shapesmooth+10,edt_shapesmooth+10)); SendModelingCommand(ID_MODELING_SETVALUE_TOOL, doc, op, bc, MODIFY_ALL); } main(docA, opA) { var doc = GetActiveDocument(); var op, bc; op = doc->GetActiveObject(); if (op) { println("Pt1: " + op->GetName()); op->Remove(); doc->MultiMessage(MSG_UPDATE); } op = AllocObject(Ocube); bc = op->GetContainer(); doc->InsertObject(op,null,null); println("Pt2: " + op->GetName()); ///Make Editable doc->SetActiveObject(op); SendModelingCommand(MCOMMAND_MAKEEDITABLE, doc, op, bc, MODIFY_ALL); op = doc->GetActiveObject(); bc = op->GetContainer(); println("Pt3: " + op->GetName()); Subdivider(op,true,2,false); //A function i declared to subdive }