GetCount Problem



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

    On 04/12/2006 at 02:49, xxxxxxxx wrote:

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

    ---------
    Hi,
    i select every object which has the same materiall. So all objects with the same material will be selectet step by  step. The right objects get selectet, this works but i need the count of the selectet elements and this doesnt work, as result i only get 0 selectet elements even if the objects are selectet at the  object manager. So my code looks likte this.
    AutoAlloc<Baseselect> bsobs;
    long zaehler = bsobs->GetCount();
    Can you help me? I think i need a reference for the baseselct to the objectmanager....



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

    On 04/12/2006 at 05:03, xxxxxxxx wrote:

    AutoAlloc<Baseselect> bsobs;
    GetActiveDocument()->GetActiveMaterials(bobs);
    long zaehler = bsobs->GetCount();

    AutoAlloc<> only reserves memory for the array, but is not filled (how should it know what to fill it with). GetActiveMaterials fills the array with the currently selected materials.

    :)



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

    On 04/12/2006 at 05:10, xxxxxxxx wrote:

    Thx i know that something like that was missing but i didn't know what exactly it was ^^
    But does this even select the selectet objects, because the count of these i need?



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

    On 04/12/2006 at 05:12, xxxxxxxx wrote:

    arg sorry, for objects of course it must be GetActiveObjects(bobs) instead of GetActiveMaterials(). I just woke up :-)

    But no, it won´t select them. They must be selected already.

    But you cna select objects easily with SetActiveObject(obj,SELECTION_ADD) or SetBit(BIT_ACTIVE);

    Hope that helps



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

    On 04/12/2006 at 05:17, xxxxxxxx wrote:

    Thx.



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

    On 04/12/2006 at 13:37, xxxxxxxx wrote:

    AutoAlloc<Baseselect> bsobs;
    GetActiveDocument()->GetActiveMaterials(bobs);
    long zaehler = bsobs->GetCount();

    This code does not work



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

    On 04/12/2006 at 14:04, xxxxxxxx wrote:

    // To select all of the objects in the current document, you'll need to recursively traverse the document object list
    SelectAllDocObjects(GetActiveDocument()->GetFirstObject());

    // Get the currently selected objects in the current document
    AutoAlloc<AtomArray> bsobs;
    GetActiveDocument()->GetActiveObjects(bsobs, TRUE);
    LONG count = bsobs->GetCount();
    ...
    // Recursive method to make all objects active (i.e.: selected) in document
    void SelectAllDocObjects(BaseObject* obj)
    {
       while (obj)
       {
          if (obj->GetDown()) SelectAllDocObjects(obj->GetDown());
          obj->SetBit(BIT_ACTIVE);
          obj = obj->GetNext();
       }
    }



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

    On 04/12/2006 at 14:10, xxxxxxxx wrote:

    Forgot to mention that if you always want all document objects, a shortcut is this instead:

    // Get the currently selected objects in the current document
    AutoAlloc<AtomArray> bsobs;
    AppendAllDocObjects(bsobs, GetActiveDocument()->GetFirstObject());
    LONG count = bsobs->GetCount();
    ...
    // Recursive method to append all objects in document into atomarray
    void AppendAllDocObjects(AtomArray* array, BaseObject* obj)
    {
       while (obj)
       {
          if (obj->GetDown()) AppendAllDocObjects(array, obj->GetDown());
          array->Append(obj);
          obj = obj->GetNext();
       }
    }

    And, of course, you can add your filtering code to AppnedAllDocObjects() to append conditionally (based on material, for instance).



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

    On 04/12/2006 at 14:43, xxxxxxxx wrote:

    ok, then in the recursive method i chick if the object is selectet and if it so i append it at the array but how do check if the object is slectet or not?



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

    On 04/12/2006 at 16:39, xxxxxxxx wrote:

    GetActiveObjects() fills AtomArray with every selected object in the document. The TRUE argument says to consider selected children as well - otherwise only selected parent objects are appended to the AtomArray. With GetActiveObjects(), you don't have to check whether or not objects are selected.

    I think that you are confusing 'selecting' and 'selected'. Selecting objects in the document requires SetBit(BIT_ACTIVE) or user-interactive selection (PERIOD - there is no other way to select objects). Getting the selected objects into an AtomArray is best done with GetActiveObjects().

    So, you've selected all of the objects in the document with a particular material (either by selection in the Object Manager, Editor, or by obj->SetBit(BIT_ACTIVE)). They are 'selected'. No need for 'selecting' at this stage.

    Now you want to know how many are selected. You do this:

    // Get the currently selected objects in the current document
    AutoAlloc<AtomArray> bsobs;
    GetActiveDocument()->GetActiveObjects(bsobs, TRUE);
    LONG count = bsobs->GetCount();

    GetCount() returns the number of objects added to the AtomArray. This happens to be the same as the number of currently selected objects in the document.

    Now, if your problem is programmatically 'selecting' the objects that meet the same material criteria, then you need to do the recursive method and find the matching material and call SetBit() if it matches. If you want to be thorough, you can call DelBit() for any non-matches to mitigate existing user object selections.



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

    On 05/12/2006 at 02:08, xxxxxxxx wrote:

    Thx this helps me but know these few lines of code let cinema shut downs^^. The hole meshoptimizing plugin is working perfect but in the last bit, the delet method, the bugdevil is in.



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

    On 05/12/2006 at 03:45, xxxxxxxx wrote:

    What are you deleting and how?



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

    On 05/12/2006 at 06:43, xxxxxxxx wrote:

    i am writing a meshoptimizer for our renderfarm www.ia-renderfarm.de, an i generate new optimized objekts, but i am using some intern cinema funktion so i am not able to change their settings, because thei are not public, and this makes trouble because i can't write my code in that i why i would like


Log in to reply