Jump to content

Sign in to follow this  
TonyTsao

Change multi-selected Nulls display ?

Recommended Posts

Hi guys, just learned python in C4D recently

 

I'm trying to make a few scripts that can change the selected null objects turn ON color & Cube display & orientation to XZ

 

The coding below is my approach to make these changes, but it can only change one null at a time
-----------------------------------------------------------------------------------------------------------------------------------------------------------

def main():
    selObj = doc.GetActiveObject()

    dis = selObj[c4d.NULLOBJECT_DISPLAY]
    ori = selObj[c4d.NULLOBJECT_ORIENTATION]
    col = selObj[c4d.ID_BASEOBJECT_USECOLOR]

    print selObj
    print dis
    print ori
    print col

    selObj[c4d.NULLOBJECT_DISPLAY] = 11                  #Cube display
    selObj[c4d.NULLOBJECT_ORIENTATION] = 3        #XZ orientation
    selObj[c4d.ID_BASEOBJECT_USECOLOR] = 1        #turn ON color display

    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

-----------------------------------------------------------------------------------------------------------------------------------------------------------

I also tried  doc.GetActiveObject(c4d.GETACTIVEOBJECTFLAGS_0), but it didn't work though.

 

Could someone point out what did I do wrong in the code?

 

Thanks in advance.

 

 

 

Share this post


Link to post
Share on other sites

Here is an example for setting just one parameter (for easier reading)

 

def main():
  
    selObj = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
        
    for obj in selObj:
        obj[c4d.NULLOBJECT_DISPLAY] = 11
   
    c4d.EventAdd() 

# Execute main()
if __name__=='__main__':
    main()

 

btw you can embedd code by using </> button in the reply interface (top area) and choose which language to use for formatting :)


Free C4D trainings from MAXON professional on our youtube channel

 

https://www.youtube.com/c4dcafe

Share this post


Link to post
Share on other sites
  • Topic Author
  • Oh Thanks you so much, you are a life saver

     

    If I may ask, do you know any resources where I can learn to some of the function for python (didn't know how some of the code work)

     

    Really appreciate it!

     


     

     

    Share this post


    Link to post
    Share on other sites

    Your best bet are sdk documentation and picking up from examples :)


    Free C4D trainings from MAXON professional on our youtube channel

     

    https://www.youtube.com/c4dcafe

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...