Jump to content

Change multi-selected Nulls display ?


TonyTsao

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.

 

 

 

Link to post

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

Link to post

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!

 


 

 

Link to post

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...