Why does this script crash Blender?


(nerddogs) #1

import Blender
obj = Blender.Object.Get()
print obj
print len(obj)

This is some code I got from a tut on writing Blender/Python scripts and it crashes blender everytime I run it. Error: “Blender has preformed an illegal operation and will shut down…ect…” I’m using Blender 2.23 and Python 2.01. Thanks for any help.

Mike.


(theeth) #2

try “print repr(ob)” instead of “print ob”.

The api in Blender 2.23 has some bugs with implicit string converstion of its objects, so you should use the repr() function or the str() function.

Martin


(nerddogs) #3

Thanks for the reply Theeth. That worked! Also thanks for the reply on the Star Wars script. Is this bug fixed in 2.25? As soon as Ton gets my payment I’ll be able to get that version too! :slight_smile:


(theeth) #4

Thanks for the reply Theeth. That worked! Also thanks for the reply on the Star Wars script.

no prob :slight_smile:

Is this bug fixed in 2.25?

yes, and instead of displaying the usual “<object object class at memory address>”, it displays a much nicer [Object “Object’s Name”].

Martin