Python Tag and Area Lights

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

On 18/09/2012 at 23:31, xxxxxxxx wrote:

Hi guys!
I have an area light that I'd like to be set to Object mode and I would like the child to be defined as that object. And, if possible, have a shortcut for this sort of light in the top panel with my other lights.

I understand this can be done using a Python tag but I know nothing about it.

If you could help or at least point me in the right direction where I can learn, I would really appreciate it 😄

Thanks in advance!

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

On 19/09/2012 at 11:34, xxxxxxxx wrote:

Hello.  I think this script will be the button you want, select the objects you want and then when you run it they'll be inserted under a newly created light and put into the objects list.

  
import c4d  
from c4d import gui  
  
  
def main() :  
  objs = doc.GetActiveObjects(True)  
  light = c4d.BaseObject(c4d.Olight)  
  light[c4d.LIGHT_TYPE] = 8  #set type to area  
  inexclude = c4d.InExcludeData()  #Create and inexclude data to set the light's one too.  
   
  doc.InsertObject(light)#insert the object into the scene  
    
  for obj in objs:#if mutliple objects are selected it will insert all of them into the include data  
      inexclude.InsertObject(obj,15)  
      obj.InsertUnder(light) #move the objects under the newly created light  
  light[c4d.LIGHT_EXCLUSION_LIST] = inexclude  
    
  c4d.EventAdd()  
    
if __name__=='__main__':  
  main()  
 

And I think this is the code for a python tag you want:

  
import c4d  
#Welcome to the world of Python  
  
  
def main() :  
  obj = op.GetObject()#Get the object that owns the tag  
  children = obj.GetChildren() #Get the children of that object  
  inexclude = c4d.InExcludeData()  #Create and inexclude data to set the light's one too.  
    
  for child in children:#if mutliple objects are selected it will insert all of them into the include data  
      inexclude.InsertObject(child,15)  
        
  obj[c4d.LIGHT_EXCLUSION_LIST] = inexclude  
  c4d.EventAdd()  

Dan

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

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

Hi Dan! Thanks for the reply! 😄
What I'm looking for is for the first child to be placed as an object in:

Light Attributes > Details > Object (right under Area Shape);

And where did you learn this coding??

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

On 20/09/2012 at 09:11, xxxxxxxx wrote:

No problem, I think this is what you want then.

The script:

  
import c4d  
from c4d import gui  
  
  
def main() :  
  obj = doc.GetActiveObject()#Gets only the first active object  
  if obj != None:  
      light = c4d.BaseObject(c4d.Olight)  
      light[c4d.LIGHT_TYPE] = 8  #set type to area  
        
      doc.InsertObject(light)#insert the object into the scene  
        
        
      obj.InsertUnder(light) #move the objects under the newly created light  
      light[c4d.LIGHT_AREADETAILS_SHAPE] =6  
      light[c4d.LIGHT_AREADETAILS_OBJECT] = obj #set the selected object as the object field  
      c4d.EventAdd()  
    
if __name__=='__main__':  
  main()  

The tag:

  
import c4d  
#Welcome to the world of Python  
  
  
def main() :  
  obj = op.GetObject()#Get the object that owns the tag  
  child = obj.GetDown() #Get the first child of that object  
  obj[c4d.LIGHT_AREADETAILS_SHAPE] = 6 #setting area shape to object  
  obj[c4d.LIGHT_AREADETAILS_OBJECT] = child  #Set the object field to the child  
  c4d.EventAdd()  

I've been doing Python with C4D for a bit now, I started with this tutorial:  http://chicagoc4d.com/videos/python/189-introduction-to-python  I wouldn't worry about the twitter stuff through.  Everyone on the forum has been a huge help as well.

Dan

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

On 21/09/2012 at 02:57, xxxxxxxx wrote:

Dude awesome thanks!
Really appreciate the # explanations! Definitely learned something useful here.

Cheers, dude.
David