-2
$\begingroup$

I run 2.78 blender version and have this error says:

ImportError: cannot import name 'Scene'

script below:

import bpy
from bpy import Scene, Text3d, Window

helloText = Text3d.new("Hello World")
helloText.setText("Hello World!")

scn = Scene.GetCurrent()
ob = scn.objects.new(helloText)

Window.RedrawAll()
$\endgroup$
  • 3
    $\begingroup$ I can't see your error message, you only posted your script. Please edito you question and provide the missing info. $\endgroup$ – Duarte Farrajota Ramos Nov 1 '16 at 18:29
  • $\begingroup$ I put all info that I know, also blender fails to run others script $\endgroup$ – Deividas Kiznis Nov 1 '16 at 18:35
  • $\begingroup$ I don't really know much about bpy but do know Python. Line 5 looks quite suspect; should it be "hello.setText(...)" instead of "hello = setText(...)"? $\endgroup$ – Rich Sedman Nov 1 '16 at 18:36
  • $\begingroup$ I still get error message in 2nd line $\endgroup$ – Deividas Kiznis Nov 1 '16 at 18:39
  • 1
    $\begingroup$ Please post the error. View the consule under the menu "Window" -> "Toggle System Console" then microsoft.com/resources/documentation/windows/xp/all/proddocs/… (minus #1) $\endgroup$ – JTxt Nov 1 '16 at 19:11
0
$\begingroup$

It appears you are using the old 2.49 (and prior) API bpy is far different from the old Blender

Here is one way to add a hello world text object using the new API.

import bpy

from bpy import context

scene = context.scene
# add a new font curve and set text
font3d = bpy.data.curves.new("Text", 'FONT')
font3d.body = "Hello World"
# add a new text object
text3d = bpy.data.objects.new("Text", font3d)

# link it to the scene
scene.objects.link(text3d)
$\endgroup$
2
$\begingroup$

Well, when Blender says "look in the console now", you should look in the console window...

The "console window" here is not your text editor, and also not the "Python Console", but a separate window, see this question: Where does console output go

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.