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
    • Recent
    • Tags
    • Users
    • Login

    Using SelectionChanger

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 387 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 28/01/2010 at 08:42, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.5 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      I'm doing something wrong here, or misinterpreting how the SelectionChanger works. What I want to do is get the points corresponding to a selected polygon or polygons. The code snippet looks like this:

      // obj is a valid pointer to a PolygonObject
      // I'm in polygon mode
      BaseSelect *selPolys, *convPoints;

      selPolys = obj->GetPolygonS();   // get selected polygons
      AutoAlloc<SelectionChanger> sc;
      sc->InitFromSelection(selPolys, Mpolygons, obj);
      convPoints = sc->GetPointS();    // convert polygon selection to points

      This compiles and runs but if the polygon object has one selected polygon, convPoints->GetCount() returns 1 - but I thought it would return 4, one for each point in the polygon. Also, the one point it contains is not actually in the selected polygon.

      I'm sure I've misunderstood how this works - can anyone enlighten me?

      Many thanks,

      Steve

      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 01/02/2010 at 03:52, xxxxxxxx wrote:

        Sorry to bump this but does anyone have any thoughts on this? I still can't get it to work, but it would be nice to know if at least I've got the underlying concept right.

        Steve

        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 02/02/2010 at 02:51, xxxxxxxx wrote:

          I am not sure what's going wrong. Your code looks ok. Here is my test code which gave me correct results.

            
          Bool MenuTest::Execute(BaseDocument *doc)  
          {  
            BaseObject *op = doc->GetActiveObject();  
            if (!op || op->GetType() != Opolygon) return FALSE;  
            
            BaseSelect *polysel = ToPoly(op)->GetPolygonS();  
            
            AutoAlloc<SelectionChanger> sc;  
            if (!sc) return FALSE;  
            
            if (sc->InitFromSelection(polysel, Mpolygons, ToPoly(op)))  
            {  
                BaseSelect *pointsel = sc->GetPointS();  
            
                LONG seg=0,a,b,i;  
            
                while (pointsel->GetRange(seg++,&a,&b))  
                {  
                    for (i=a; i<=b; ++i)  
                    {  
                        // i is the selected point  
                        GePrint(LongToString(i));  
                    }  
                }  
            }  
              
            return TRUE;  
          }  
          

          cheers,
          Matthias

          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 02/02/2010 at 09:23, xxxxxxxx wrote:

            Thanks Matthias. I now know that what I was doing was correct, and I think I know where the problem is.

            Where possible I start developing my plugins in R10.111, partly so I can support older versions of Cinema, but mostly because I use R11.5 for most of my work, so I can have R10 stripped down to loading nothing other than my developing plugins.

            Basically, I think the selection changer doesn't work correctly in R10. It works as expected in R11 and R11.5, but in R10 the code you showed does the same as mine - returns one selected point. R11 upwards returns 4 points, as expected.

            I had a quick look in the R10 and R10.5 SDKs but I couldn't see anything about this in the changes section. I guess for this plugin it'll have to be R11 upwards as a requirement.

            Many thanks for your help with this.

            Steve

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