-2

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()
batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • 3
    I can't see your error message, you only posted your script. Please edito you question and provide the missing info. – Duarte Farrajota Ramos Nov 01 '16 at 18:29
  • I put all info that I know, also blender fails to run others script – Deividas Kiznis Nov 01 '16 at 18:35
  • 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(...)"? – Rich Sedman Nov 01 '16 at 18:36
  • I still get error message in 2nd line – Deividas Kiznis Nov 01 '16 at 18:39
  • 1
    Please post the error. View the consule under the menu "Window" -> "Toggle System Console" then https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/windows_dos_copy.mspx?mfr=true (minus #1) – JTxt Nov 01 '16 at 19:11
  • Run blender from through the terminal, run the script, and post the error it gives you. We can't tell you what is wrong if we have no way of finding out. – krypticbit Nov 01 '16 at 21:10
  • You shouldn't need the second line anyway since the first line already imports the whole of the bpy package so Scene, Text3d and Window should be already imported. – Rich Sedman Nov 01 '16 at 23:28
  • C'mon guys, (s)he posted the script, and from that it's darn easy to determine the error message... it appears to be a 2.49 or prior script with Blender replaced by bpy. – batFINGER Nov 02 '16 at 06:30

2 Answers2

2

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

lbalazscs
  • 3,599
  • 22
  • 24
0

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)
batFINGER
  • 84,216
  • 10
  • 108
  • 233