How to access a polygon selection?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/03/2003 at 14:55, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.012 
    Platform:      Mac OSX  ; 
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    What's the most efficient way in Coffee to access a polygon selection?

    Basically I need to check the following:
    * Is the application in polygon selection mode?
    * if so, how many polygones are selected?
    * og course I may also need the polygones l8r ;-)

    Thanks for any hints and help!

    kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/03/2003 at 07:26, xxxxxxxx wrote:

    Hi Kabe, nice to cu in here... ;-)
    Well, I dunno how to get the status of the prog..
    (Points, Polygons and so on),
    but accessing the polygon-selection is quite simple:
    Access the polygonselection and lookup the IsSelected(index)
    for every polygon. In this way you can be sure to get every
    selected polygon.
    Example code:
    var doc = GetActiveDocument();
    var op = GetActiveObject(doc);
    var polysel = op->GetPolygonSelection();
    var poliescount = op->GetPolygonCount();
    var i;
    for(i=0;i<poliescount;i++)
    {
        if(polysel->IsSelected(i))
        {
            println("Polygon ",i," is selected.");
        }
    }

    regards, Helge Mathee



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/03/2003 at 07:28, xxxxxxxx wrote:

    ah, well, and for "how many polygons are selected" just use:
    (in my code example)
    var polyselcount = polysel->GetCount();



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 07:50, xxxxxxxx wrote:

    Helge,

    thanks a lot! It seems that the knowledge of crucial methods like GetPolygonSelection() is based on personal tradition ;-)

    The mentioned methods of BaseObject are neither listed in BaseObject nor in BaseList4D and BaseList2D. How is anybody supposed to know about them? Beats me.

    Anyway, this case is hopefully solved ;-)

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 08:50, xxxxxxxx wrote:

    OK... meanwhile I got it. I guess that this is *the* cornerstone for understanding how to access objects with C.O.F.F.E.E., so IMO it should be somewhere in the introduction texts.

    GetActiveObject(doc) delivers the object, whatever class / kind of object it is. Selections (if available for that type of object) are requested using the appropiate class methods, which means that a plugin should check if it has got the expected object class first to avoid calling methods that don't exist for that class [For instance: A call to GetPolygonSelection will fail with a "(9) memeber not found" error, if the object you got is a LightObject for instance]

    Maybe some guy or girl from Maxon could try to get some sentence like this into the docs to save some other people a bit of frustration...

    Now I'm a happy camper ;-)

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 09:23, xxxxxxxx wrote:

    1. The mentioned methods of BaseObject are neither listed in BaseObject nor in BaseList4D and BaseList2D. How is anybody supposed to know about them? Beats me.
    2. Maybe some guy or girl from Maxon could try to get some sentence like this into the docs to save some other people a bit of frustration...
    ---------------------------------------
    1. They are listed in the inherited classes. In this case a polygonobject inherited from pointobject (see class). The pointobject class is inherited from BaseObject. Have a closer look next time before screaming ;)
    2. This is basic stuff. Get a C++ book that deals with classes etc. and you would have known (and will next time ;)
    3. SDK doc is like a vocabulary. The description of a word is sometimes not where you´re expecting it to be ;)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 10:51, xxxxxxxx wrote:

    Samir,

    I already understood 1), see my previous posting...

    2. I disagree... of course as soon as you know what GetActiveObject() does and what's he purpose of that method then you know.

    Take a look at the entry in the C.O.F.F.E.E. reference before you point me to a C++ book (I read a few).

    Considered that this is the cornerstone to access anything the description is just a tad short here. An example like the one that Helge provided does provide great insight and is not luxury.

    3. Of course an SDK is *mostly* a vocabulary. However, IMO it should better provide the right starting point for your journey at least. It's in Maxon's interest to make the SDK *accessible*, and this does also mean to point out the basic structure.

    A page like "The C4D environment" talks just about "Scene classes" and "Events and messages". Adding one or two sentences about handling selections would have saved a lot of trouble!

    Cheers

    kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 11:07, xxxxxxxx wrote:

    2. I disagree... of course as soon as you know what GetActiveObject() does and what's he purpose of that method then you know.

    Take a look at the entry in the C.O.F.F.E.E. reference before you point me to a C++ book (I read a few).

    Considered that this is the cornerstone to access anything the description is just a tad short here. An example like the one that Helge provided does provide great insight and is not luxury.
    -------------------
    Sorry, no. The entry is very clear. What else do you want them to write? In front of the function there is the object-classtype that´ll be returned. What else do you need??? You got the returned type, you look into that class, you look into the inhereted classes. There´s nothing to add imo.
    And the description:

        
        
        Returns the currently active object in the document [CODE]doc
    

    , or

    NULL
    

    if there is no active object.
    [/CODE]
    can it be clearer? Please tell me how you would have described it?
    The SDK is a help file. In the coffee docs the first pages deal with classes, files, events & messages, basecontainers, filestructures and even basic syntax.
    There are some tutorials that deal with matrices in the plugincafe. Those are the main things that are needed. I don´t think it´s too hard to click on the inherited class. Then you would have seen that the returned class object is BaseSelect and.....

        
        
        Adding one or two sentences about handling selections would have saved a lot of trouble!
    

    .... there IS even an example of pointselection handling in the COFFEE docs. In the BaseSelect class:

        
        
        // Prints all selected points of an object  
        var obj = doc->FindObject("MyObject");  
        var select = obj->GetPointSelection();  
          
        var i = 0;  
        var found = 0;  
          
        for (i = 0; i < obje->GetPointCount(); i++)  
        {  
          if (found >= select->GetCount()) break;  
          if (select->IsSelected(i))  
          {  
            println(obj->GetPoint(i));  
          found++;  
          }  
        }
    

    I understand if users are new to coding that it is hard to get in and a lotta questions occur (I have a lotta questions about the C++ SDK myself too) and the docs are not 100% complete but sometimes I think people are trying to put all the weight on MAXONs shoulders...
    btw. have found the BaseSelect example within 20 seconds.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 14:32, xxxxxxxx wrote:

    I found the BaseSelect example as well... but the problem is: How to get that object if you don't have the name to select it, but you would like to get the selected object?
    Yeah, you have to use GetActiveObject(), which doesn't give you back a BaseSelect, but a BaseObject. However:

    How do you know?

    GetActiveObject is one of many functions, there's no reference from a type to the methods that are used to create them (otherwise BaseSelect would quickly lead to the seperate selection methods of a number of BaseObject classes).

    C'mon, all I'm asking for is 2 sentences, less than anybody here has written in this thread!!!

    This is not putting all the weight on Maxon's shoulders! Just because you don't need it and I don't need it anymore, doesn't mean that it's stupid.

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2003 at 14:51, xxxxxxxx wrote:

    How do you know?
    Search for it? Trying to find out yourself if such a function exists? And you wouldn´t even need that function. With the descriptions of "The c4d environment" you could have done it too. GetFirstObject() of BaseDocument, then using the inherited function GetNext() and also the inherited function GetBit() to find out if the next object is selected.
    And there are several example plugin codes available in the SDK you could have downloaded and I am almost sure that GetActiveObject() is included in one of those. (afaik provided long ago by Mikael Sterner)

    GetActiveObject is one of many functions,
    exactly! That´s why it should be handled like any other function too! The developer has to search for it. That´s the first step you do for ANY function. Sorry, but I still see no real argument for a further description.
    Just because you don't need it and I don't need it anymore, doesn't mean that it's stupid.
    Nobody said anything is stupid. I just don´t see a lack of description in the docs for this function.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/03/2003 at 04:17, xxxxxxxx wrote:

    You don't even try to understand, do you?

    Nuff said. And in contrast to Helge, who wrote a short, constructive and helpful post, I'm sick of discussing that little suggestion of mine any further.

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/03/2003 at 04:19, xxxxxxxx wrote:

    I don't think this is a discussion forum.
    This is SDK-Help forum.
    Sorry Samir... but this "argueing"-geeks are every where.
    Look in the XSI-forums. Only complaints in there... ;-)
    regards, Helge Mathee



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/03/2003 at 04:21, xxxxxxxx wrote:

    and, well, Kabe, sorry, I also like the SDK. It's quite clear to me.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/03/2003 at 05:18, xxxxxxxx wrote:

    I also like the SDK *now*, and as soon as you're over these first hurdles, it's quite clear and easy. :-D

    However, I just don't forget about obstacles as soon as they are behind me. With only a little information it could have been easier and faster the first place, and much less frustrating.

    Kabe


Log in to reply