AttributeError: 'NoneType' object has no attribute 'bones'

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
syco
Posts: 0
Joined: Mon Feb 16, 2009 6:39 am

AttributeError: 'NoneType' object has no attribute 'bones'

Post by syco » Mon Feb 16, 2009 6:45 am

hi, i'm not new to blender but I can not really understand why this error in a code copied from the api.

the code is:

Code: Select all

from Blender import *

def test_arm():
	scn = Scene.GetCurrent()
	arm_ob = scn.objects.active
	if not arm_ob or arm_ob.type != "Armature":
		Draw.PupMenu('not an armature object')
		return
	# Deselect all
	for ob in scn.objects:
		if ob != arm_ob:
			ob.sel = 0
	arm_mat = arm_ob.matrixWorld
	arm_data = arm_ob.getData()
	bones= arm_data.bones.values()
	for bone in bones:
		bone_mat = bone.matrix['ARMATURESPACE']
		bone_mat_world = bone_mat*arm_mat
		ob_empty = scn.objects.new('Empty')
		ob_empty.setMatrix(bone_mat_world)
test_arm()
i copied it from these page: http://www.blender.org/documentation/24 ... odule.html
the error is:

Code: Select all

Blender Game Engine Started

Oops - can't get the armature weakref list
Python script error from controller "cont2#CONTR#3": 
Traceback (most recent call last):
  File "braccio.py", line 5, in <module>
AttributeError: 'NoneType' object has no attribute 'bones'
Oops - can't get the armature weakref list
Python script error from controller "cont2#CONTR#3": 
Traceback (most recent call last):
  File "braccio.py", line 5, in <module>
AttributeError: 'NoneType' object has no attribute 'bones'

dfelinto
Posts: 0
Joined: Wed May 17, 2006 8:44 pm
Location: Rio de Janeiro, Brasil

Post by dfelinto » Thu May 21, 2009 10:50 pm

You tried to run it in the Blender Game Engine. However the script example you are looking for is to be used in Blender itself.

So instead of launch BGE (pressing P) go to the Text Editor window and press ALT+P (or RMB+Run Script)
Rio de Janeiro - Brasil
http://blenderecia.orgfree.com

Post Reply