THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/05/2011 at 15:48, xxxxxxxx wrote:
Cinema 4D Version: R12
Language(s) : C++ ;
here my first question:
How to split a PolgonObject with multiple PolygonSelection-Tags (for Materials) into multiple PolygonObjects?
Here my start.
void Walk(BaseObject *object)
if(object->GetType() == Tpolygon)
BaseTag *tag = object->GetFirstTag();
if (tag->GetType() == Tpolygonselection)
SelectionTag *selectionTag = (SelectionTag * )tag;
BaseSelect *select = selectionTag->GetBaseSelect();
alloc new PolygonObjects, fill given data
tag = tag->GetNext();
object = object->GetNext();
On 17/05/2011 at 17:00, xxxxxxxx wrote:
Select the polygons of the PolygonSelection and then use SendModelingCommand() to do a split. Here is a convenience method which does it for you:
PolygonObject* SplitObject(PolygonObject* op, SelectionTag* pstag)
// BaseSelect of Polygon Selection Tag
BaseSelect* pbs = pstag->GetBaseSelect();
if (!pbs) return NULL;
// BaseSelect of Polygon Object
BaseSelect* bs = op->GetPolygonS();
if (!bs) return NULL;
// Select Polygons on Polygon Object belonging to Polygon Selection Tag
if (!pbs->CopyTo(bs)) return NULL;
// Split selected polygons (tops) into new object
mcd.doc = NULL;
mcd.bc = NULL;
mcd.mode = MODELINGCOMMANDMODE_POLYGONSELECTION;
mcd.flags = MODELINGCOMMANDFLAGS_0;
mcd.op = op;
if (!(SendModelingCommand(MCOMMAND_SPLIT, mcd) && mcd.result)) return NULL;
PolygonObject* top = ToPoly(mcd.result->GetIndex(0L));
// - it is your responsibility to free the 'result' AtomArray returned in 'mcd'!
On 18/05/2011 at 01:14, xxxxxxxx wrote:
Just btw: If a non-polygonobject is parsed, you will never ever leave the while-loop.
On 18/05/2011 at 01:34, xxxxxxxx wrote:
Very cool, thank you. Clever idea to use the modeling command.
a yeah, thats right. thanks.
On 18/05/2011 at 08:21, xxxxxxxx wrote:
To avoid the infinite while-loop just move the line "object = object->GetNext();" outside of the if() block.
SendModelingCommand() is your friend ... most of the time but depending upon its mood.