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