Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Get polygons from Selection Tag

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 332 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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();  
      }  
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post