Q about v225 & Object.New()?


(BlendedRace) #1

Hi,

I’m trying to get a python made empty in v225 and am having no luck at all.

I’ve tried both the following:
(as a test of Object.New)


import Blender 
Blender.Object.New(Blender.Object.Types['LAMP']) 
L=Blender.Object.GetSelected()[0] 
lampe=Blender.Lamp.Get(L.data.name) 

from http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_b223new.htm

and my code:


import Blender
import sys

obtype = "EMPTY"
obj = Blender.Object.New(Blender.Object.Types[obtype])
obj.name = 'trackwp'

Blender.Redraw()
sys.stdout.flush()

Please could anyone who’s got it working let me know where I’m going wrong.

Thanks Stephen


(jms) #2

Try this:

import Blender

s=Blender.Scene.getCurrent()
ob=Blender.Object.New('Empty')
ob.link('test')
s.link(ob)

Blender.Window.RedrawAll()


(BlendedRace) #3

Thanks for that - it’s perfect :smiley:

I guess that while I was making the empty, I wasn’t telling Blender to put it in the current scene.

the line

s.link(ob)

links the newly made empty with the current scene.

BUT what does this line do?

ob.link('test')

Does the empty have to become ‘link capable’ before I can link it into the scene?

Thanks Stephen