GetActiveObjects



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

    On 11/11/2004 at 17:27, xxxxxxxx wrote:

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

    ---------
    Hi Guys,
    Really new to C++ and the Cinema SDK. But I want to get all the selected objects in the document. This I belive can be done by doing this:

        
        
         
        
        
        
        
        AutoAlloc<AtomArray> objects; if (!objects) break;
        
        
        
        
        GetActiveDocument()->GetActiveObjects(objects, TRUE);
        
        
        
        
        
    
    To me this means that all the selected elements will be stored in 'objects'. My question is how can I access the individual elements of the AtomArray so I can get the position of each object in the selection? Thanks in advance for any help
    
    
    
    
     
    


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

    On 11/11/2004 at 19:03, xxxxxxxx wrote:

    Hi, try this: 
    cnt= objects->GetCount(); // To get selected objects count
    for(i=0;i<cnt;i++)
    {
      Obj =(BaseObject* )objects->GetIndex(i); // Get the first object
     // you can proceed with 'Obj' to get position 
    }



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

    On 12/11/2004 at 13:14, xxxxxxxx wrote:

    Thanks for the reply Charles, it helped a lot. My other question now is the GetIndex() returns the index of type long for each object. So Obj would have to be declared as a long such as:

        
        
        
        
        for(int i=0; i<cnt; i++)
        
        
        
        
        {
        
        
        
        
        long Obj=(BaseObject* )objects->GetIndex(i);
        
        
        
        
        }
        
        
        
        
        How could I return each object to Obj from the provided index in the for loop? Thanks in advance.
        
        
        
        
        -Josh-
    


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

    On 12/11/2004 at 13:20, xxxxxxxx wrote:

    Hi Josh,

    no GetIndex(i) returns already the object (pointer) and not a LONG value. That´s why the old cast is there.

    BaseObject* Obj = static_cast<BaseObject*>(objects->GetIndex(i));
    

Log in to reply