Get polygons from Selection Tag
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/07/2007 at 14:34, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.008
Platform: Windows ;
Language(s) : C++ ;---------
I'm trying to get the polygons from a selection tag so I can write them out (writing an export plugin, based on the stl filter example) -- and with the code below, I can go through all the tags, but instead of pulling the selected polygons from each tag, it's grabbing what's currently selected. (I know that from debugging code that's in mine that I didn't post here -- it shows me which polys are selected, and those numbers line up with the polygon mode of the structure tab...) Now, I'm pretty sure it's because I'm using "GetPolygonS" but I'm not entirely convinced that I'm on the right path and that changing that one thing would fix it all, so I decided to post here. I'm pretty new to c++ so most of what's here is hobbled together from what I've found on this forum or through experimentation (which, I know, isn't really good), so I may have some bad coding in there (if I do, please point that out). Also, while I'm asking once I've got them below in "i" (where it says "do something - i is the selected element") -- what do I do with that polygon number? I know it relates to a poly in the list, but I'm not sure how to create some kind of poly holder (see my noobiness showing through?) to get the data I need from it.Thanks in advance....
BaseTag* tag = op->GetFirstTag(); while (tag) { if (tag->IsInstanceOf(Tpolygonselection)) { BaseObject* obj = op; if (obj && obj->GetType() == Opolygon) { PolygonObject* poly = static_cast<PolygonObject*>(obj); BaseSelect* sel = poly->GetPolygonS(); while(sel->GetRange(seg++,&a;,&b;)) { GePrint("Segment " + LongToString(seg)); for (i=a; i<=b; ++i) { // ... do something - i is the selected element GePrint("Found poly in range: " + LongToString(i)); } } } } tag = tag->GetNext(); }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/07/2007 at 16:02, xxxxxxxx wrote:
You are only getting the selected polygons from the PolygonObject = noooo.
You want to get the polygons from the PolygonSelection tags - you must get the Selection tag and get the BaseSelect from *it*!
Here's some generic code to get at the polygons in a PolygonSelection tag:
PolygonObject* pobj = static_cast<PolygonObject*>(op); if (!op->IsInstanceOf(Opolygon)) // not a polygon object CPolygon* poly = pobj->GetPolygonsW(); // PolygonObject Polygon array (write-only) CPolygon* spoly; // pointer to polygon selected in PolygonSelection tag BaseSelect* select; LONG j, a, b, seg; for (BaseTag* baseTag = op->GetFirstTag(); baseTag; baseTag = baseTag->GetNext()) { if (!baseTag->IsInstanceOf(Tpolygonselection)) continue; select = static_cast<SelectionTag*>(baseTag)->GetBaseSelect(); if (!select) return some error; for (seg = 0; select->GetRange(seg,&a;,&b;); ++seg) { for (j=a; j<=b; ++j) spoly = poly[j]; } }
HTH,
Robert
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/07/2007 at 19:29, xxxxxxxx wrote:
Thanks Robert! That looks tremendously helpful. I'll give it a shot tomorrow and let you know how it goes. I was thinking that I should be doing it more like what you said, but really had no idea how to get from where I was to where it needed to be. I'm still learning my way around the sdk and c++ -- thanks again!