Cast BaseObject to Polygon
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/02/2004 at 19:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.100
Platform: Windows ;
Language(s) : C++ ;---------
Hi all
I have a plane currently, have set its containers, Now i wanna get the point count of this object. So, i have to convert it into polygon object. I have read that the way to do that is by using the MCOMMAND_CURRENTSTATETOOBJECT. So i tried this way. My problem is, after i inserted the plane, I have to make it editable. So i have done this code:
BaseObject *ObjGrid = BaseObject::Alloc(Oplane);
BaseContainer *conGrid = ObjGrid->GetDataInstance();
conGrid->SetReal(PRIM_PLANE_SUBW, XNos);
conGrid->SetReal(PRIM_PLANE_SUBH, ZNos);
conGrid->SetReal(PRIM_PLANE_WIDTH, XWidth);conGrid->SetReal(PRIM_PLANE_HEIGHT, ZWidth);
doc->InsertObject(ObjGrid,NULL,NULL,TRUE);
doc->StartUndo();
doc->AddUndo(UNDO_NEW, ObjGrid);
ObjGrid->SetRot(Vector(Rot_H, Rot_P, Rot_B));
ModelingCommandData cd;
cd.flags = MODELINGCOMMANDFLAG_CREATEUNDO;
cd.doc = doc;
cd.bc = conGrid;
cd.op = ObjGrid;
cd.mode = MODIFY_ALL;
if (!SendModelingCommand(MCOMMAND_MAKEEDITABLE,cd)) return NULL;
EventAdd(EVENT_FORCEREDRAW);
ObjGrid = doc->SearchObject(vGridName);
How can I convert it into polygon object. Is that by using this following code:
Modelingcommanddata cd2;
cd2.doc=doc;
cd2.op = ObjGrid;
if(!Sendmodelingcommand(MCOMMAND_CURRENTSTATETOOBJECT, cd2)) return FALSE;
I have tried this but it gave memory leak problem. Anyone has any idea how to solve this?
Thanks for any help
Regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/02/2004 at 17:54, xxxxxxxx wrote:
Once you've used current state to object and have a pointer to the result, then just check that GetType()==Opoly and cast it using
PolygonObject* poly = static_cast<PolygonObject*>(obj).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/02/2004 at 23:02, xxxxxxxx wrote:
I have converted it into polygon object by using this code:
for(i=0; i<=XNos; i++) {
BaseObject *objText = BaseObject::Alloc(Osplinetext);
ModelingCommandData md;
md.doc = doc;
md.op = objText;
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, md)) return FALSE;
PolygonObject *poly = static_cast<PolygonObject*>(md.result1);
But when i wanna get the active point from this object, seems like there is a problem with this following code, so that i could not
Activept = poly->GetPoint();
Activept[i].z = Activept[i].z - 3 + ZMove;
poly->SetPos(Activept[i]);
doc->InsertObject(poly,ObjToPolygon,NULL);
}
Can u plz tell me what's the problem of this?
Thanks and regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/02/2004 at 16:38, xxxxxxxx wrote:
Do you mean that the code doesn't compile or that there's a runtime error or that nothing happens at all? (The term "problem" is too wide I'm afraid.)