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

    Select an inactive object

    Scheduled Pinned Locked Moved SDK Help
    13 Posts 0 Posters 776 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 21/07/2011 at 22:21, xxxxxxxx wrote:

      Note that you don't have to do this in the Draw() method.  You want to do this in the MouseInput() method.  But you should still store the cursor coordinates in GetCursorInfo() to use there. 🙂

      Also, don't forget to call EventAdd() after SetActiveObject()!

      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 21/07/2011 at 22:23, xxxxxxxx wrote:

        Perfect..  Thanks Robert.   I wish I could email you a beer or something.  You really ought to be paid for all the help you give.  🙂

        Thanks again!

        ~Shawn

        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 22/07/2011 at 12:12, xxxxxxxx wrote:

          Hey Robert,  so your method works great.  I am able to select objects and use qualifiers to multi select or deselect.  One more question.   How would i deselect all if the user clicks an area where there is no object behind the cursor?

          Thanks,

          Shawn

          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 22/07/2011 at 12:37, xxxxxxxx wrote:

            Hey Shawn,

            Try it with a RayCollision. 😉

            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 22/07/2011 at 13:23, xxxxxxxx wrote:

              I would check the C4DObjectList for (cnt == 0) or (!cnt) as I do and if this is the case on a mouse click then you call:

              if (!cnt)
              {
              AutoAlloc<AtomArray>  atomArray;
              if (atomArray)
              {
                BaseObject* sobj = NULL;
                doc->GetActiveObjects(*atomArray, FALSE);
                LONG    cnt =            atomArray->GetCount();
                for (LONG i = 0L; i != cnt; ++i)
                {
                static_cast<BaseObject*>(atomArray->GetIndex(i))->DelBit(BIT_ACTIVE);
                }
                EventAdd();
              }
              }

              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 22/07/2011 at 13:57, xxxxxxxx wrote:

                Hmmm..

                Well I added what you mentioned and it still does nothing when I click off an object..   Here's my function..  This function is called directly from MouseInput()  🙂

                  
                //SELECT OBJECT  
                //==============================================//  
                  
                Bool MyClass::SelectObject(BaseDraw *bd)  
                {  
                  //Get the active document  
                  BaseDocument *doc = GetActiveDocument();  
                  if(!doc) return FALSE;  
                  
                  //Check to see if the cursor is in the editor window  
                  if(mouseX < 0.0) return FALSE;  
                  
                  //Add all objects under the cursor to the Object List  
                  AutoAlloc<C4DObjectList> objList;  
                  if (!objList)return FALSE;  
                  
                  if (!SelectionListCreate(doc, NULL, bd, mouseX, mouseY, NULL, objList)) return FALSE;  
                  LONG objectCount    = objList->GetCount();  
                  if (!objectCount)    return FALSE;  
                  
                  BaseObject *obj = NULL;  
                  
                  if (!objectCount)  
                  {  
                      GePrint("NO OBJECT");  
                      AutoAlloc<AtomArray>  atomArray;  
                        
                      if (atomArray)  
                      {  
                          BaseObject* sobj = NULL;  
                          doc->GetActiveObjects(*atomArray, FALSE);  
                          LONG cnt = atomArray->GetCount();  
                  
                          for (int i = 0; i != cnt; ++i)  
                          {  
                              static_cast<BaseObject*>(atomArray->GetIndex(i))->DelBit(BIT_ACTIVE);  
                          }  
                  
                          EventAdd();  
                      }  
                  }  
                  
                  //Loop through objects  
                  for(int i = 0; i < objectCount; ++i)  
                  {  
                      obj = objList->GetObject(i);  
                  
                      BaseContainer state;  
                  
                      if (GetInputEvent(BFM_INPUT_KEYBOARD, state))  
                      {  
                          LONG key = state.GetLong(BFM_INPUT_QUALIFIER);  
                                    
                          if(key & QCTRL)  
                          {  
                              doc->SetActiveObject(obj, SELECTION_SUB);  
                              EventAdd(EVENT_FORCEREDRAW);  
                          }  
                          else if(key & QSHIFT)  
                          {  
                              doc->SetActiveObject(obj, SELECTION_ADD);  
                              EventAdd(EVENT_FORCEREDRAW);  
                          }  
                          else  
                          {  
                              doc->SetActiveObject(obj, SELECTION_NEW);  
                              EventAdd(EVENT_FORCEREDRAW);  
                          }  
                      }  
                  }  
                }  
                
                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 22/07/2011 at 13:59, xxxxxxxx wrote:

                  Interestingly...  the GePrint() that I added never shows up which must mean that objectCount is never = 0.

                  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 22/07/2011 at 14:02, xxxxxxxx wrote:

                    DOH!  That was stupid..

                    This line was the reason...

                    if(!objectCount) return FALSE;

                    LOL

                    Oye..  Tired eyes.

                    Thanks again Robert.

                    ~Shawn

                    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 22/07/2011 at 16:10, xxxxxxxx wrote:

                      Get thee to bed. 🙂

                      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 22/07/2011 at 16:12, xxxxxxxx wrote:

                        And you can get rid of the "BaseObject* sobj = NULL;" since I made the DelBit() a one-liner into atomArray instead of getting the object and then calling DelBit().

                        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 22/07/2011 at 16:16, xxxxxxxx wrote:

                          Already done..  🙂 Thanks.  I got tired of looking at the "Initialized but not referenced "  warning  HAHAHA

                          I'm about to call it a night.  🙂  I've been at it for a while today.  Lots of good progress though.  Thanks a lot for your help.

                          ~Shawn

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