Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    GetCount Problem

    SDK Help
    0
    13
    1.1k
    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
      Helper
      last edited by

      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....

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

        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.

        🙂

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

          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?

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

            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

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

              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.

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

                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

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

                  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();
                     }
                  }

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

                    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).

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

                      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?

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

                        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.

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

                          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.

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

                            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?

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

                              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

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