Trouble Adding an Object to an in-exclude-list



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

    On 20/06/2011 at 14:34, xxxxxxxx wrote:

    So as the title says I can't seem to add objects to a an InExcludeData list. Specifically to a tracer object 'Trace Link' list but for simplicities sake I'm testing with an Object Selection list.  I've worked through the CG Rebel P4D 102 tutorial which gets me tantalizingly close, but I can't seem to seal the deal.

    http://cgrebel.com/2011/01/p4d102-selected-objects/

    I'm a novice to the C4DSDK and know just enough Python to be a little dangerous so I'm figuring things out as I go.  This is the code I've got currently, which yields no errors but doesn't do what I want it to do.  It's stripped down to it's bare bones, just working with two selected objects, the top an Object Selection object and the bottom just a Cube:

    import c4d
    from c4d import documents
      
    def main() :
    	doc = c4d.documents.GetActiveDocument()
    	
    	selected = doc.GetActiveObjects(0)
    	
    	obj_list = selected[0][c4d.SELECTIONOBJECT_LIST]
    	
    	obj = selected[1]
      
    	obj_list.InsertObject(obj,0)
    	
    	c4d.EventAdd()
      
    if __name__=='__main__':
    	main()
    


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

    On 20/06/2011 at 15:41, xxxxxxxx wrote:

    I can't test it right now.
    But maybe theese 2 links can help you.

    1. Python Tag Example, More about getting data from a InExclude
    2. An example where I used an InExclude Data, about adding objects to inexclude

    cheers



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

    On 21/06/2011 at 08:36, xxxxxxxx wrote:

    That second example is the one that I essentially reverse engineered to get where I am now.  It gets me close but it seems that I can't fully manipulate an existing InExcludeList.  I can accurately look at the list but I can't add anything to it.  In that second example objects are added to the list before the list is added to the scene.  Here is a more complete set of code that I hopefully can make do what I want:

    import c4d
    from c4d import documents
      
    doc = c4d.documents.GetActiveDocument()                 # Establishes variable for the document (the project) itself
    selected_object = op.GetClone()                         # Gets copy of currently selected object
      
    def dupe() :
        '''Duplicates currently selected object and returns duplicated objects name'''
        # Add line to check if it is a cloner object
        selected_object[c4d.ID_BASELIST_NAME] += '.copy'
        doc.InsertObject(selected_object)                   # Duplicates currently selected object
        c4d.EventAdd()                                      # Refresh the managers to show the new object
      
    def addTracer() :
        '''Adds a tracer object with the currently selected object as its focus'''
        tracer = c4d.BaseObject(1018655)                    # Allocate a new Tracer object
        doc.SetActiveObject(tracer, 1)                      # Adds new Tracer object to current selection
        obj_list = tracer[c4d.MGTRACEROBJECT_OBJECTLIST]    # Assigns InExcludeData list in tracer object to variable
        obj_list.InsertObject(selected_object,0)            # Inserts the cloned object into the tracer list
        doc.InsertObject(tracer)                            # Insert the object into the documents object list
        c4d.EventAdd()                                      # Refresh the managers to show the new object
                
        
    def main() :
        dupe()
        addTracer()
      
    if __name__ == "__main__":
        main()
      
    
    

    It seems like I need to 'complete' that InsertObject() method somehow.  The problem is semantic, I wish it gave me some kind of error.  I've been trying to do variations in the console and haven't been able to add or remove anything from an InExcludeData list that was already established.  I can however make all of the other methods in that class work for me. 
    < ="utf-8">



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

    On 21/06/2011 at 09:12, xxxxxxxx wrote:

    Try this:

    import c4d  
    from c4d import gui, documents  
      
    def main() :  
      
      tracer = c4d.BaseObject(1018655)                  #Create a tracer in memory                     
      obj_list = tracer[c4d.MGTRACEROBJECT_OBJECTLIST]  #Get the object list attribute and assign to a variable    
      doc.InsertObject(tracer)                          #Insert the tracer to the OM from memory   
      
      targetobj = doc.SearchObject("Cube")               #The object to be moved into the tracer's object list   
      obj_list.InsertObject(targetobj,0)                 #Insert the object into the list in memory only  
      tracer[c4d.MGTRACEROBJECT_OBJECTLIST,0] = obj_list #Update the changes made to the list from memory    
      
      c4d.EventAdd()              
      
    if __name__ == "__main__":  
      main()
    

    -ScottA



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

    On 21/06/2011 at 09:34, xxxxxxxx wrote:

       
       
           tracer[c4d.MGTRACEROBJECT_OBJECTLIST,0] = obj_list #Update the changes made to the list from memory  
    
    Ah, did not spot that issue. You have to set the obj_list back again to the tracerobject.  
    But,delete the ",0" at the end. I don't know why it does work, but it is unnecessary.  
      
    Cheers,  
    


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

    On 21/06/2011 at 12:02, xxxxxxxx wrote:

    Very cool, Scott that solution worked like a charm.

    Thank you very much Scott and Nux, you've both been a huge help.

    One thing though Nux, I'm not sure what you mean in the previous post, if I pull that ", 0" at the end it throws an error looking for the flag, which makes sense relative to the SDK.



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

    On 21/06/2011 at 13:25, xxxxxxxx wrote:

    Don't understand you right, I think.
    What solution works ?

    tracer[c4d.MGTRACEROBJECT_OBJECTLIST,0]
    

    or

    tracer[c4d.MGTRACEROBJECT_OBJECTLIST]
    

    ?
    Actually the last one should only work.

    Cheers



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

    On 22/06/2011 at 08:21, xxxxxxxx wrote:

    Ah y'know what?  I misread your post, I was looking at the '0' in the line above.  You are correct.  Thanks again to both of you, not only for this reply but for a bunch of the other ones I've read on this forum.  Your efforts are very much appreciated.



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

    On 04/09/2012 at 09:07, xxxxxxxx wrote:

    I know that this is an old thread, but I thought I'd ask my question here because it's the same topic.

    I'm using the above-mentioned technique to add an effector to a cloner object's effector list. While it now appears on the list, it is deactivated. How do I access that little checkbox within the cloner's effector list that activates or deactivates the effector?

    Thanks,
    Luke



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

    On 04/09/2012 at 11:58, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I'm using the above-mentioned technique to add an effector to a cloner object's effector list. While it now appears on the list, it is deactivated. How do I access that little checkbox within the cloner's effector list that activates or deactivates the effector?

    It's not well documented but you can activate/deactivate an object in an in-/exclude list when inserting it by calling:

    list.InsertObject(effector, 1)
    

    As you can see, just pass 1 as second parameter instead of 0.



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

    On 04/09/2012 at 12:15, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    It's not well documented but you can activate/deactivate an object in an in-/exclude list when inserting it by calling:

    list.InsertObject(effector, 1)
    

    As you can see, just pass 1 as second parameter instead of 0.

    Fantastic. Thanks!


Log in to reply