Argument works in the python console but not in a loop?

by Nburgess   Last Updated August 14, 2019 05:15 AM - source

I can type['hair02']

into the the console and get a return but when it is in this loop it sends back an error. please see image below. I must be calling it improperly but not sure why. any help is appreciated.

Tags : python scripting

Answers 1

You're testing all of the objects that were selected when the script reached the line fbxs = [ ob for ob in bpy.context.selected_objects] One of these objects has no parent, so when the line = True is run, Blender tries to find a parent and raises an error when it doesn't find one.

Try this instead:

if (ob.parent):

or if that doesn't work for some reason, enclose it in a try:/except: block.

Joseph Brandenburg
Joseph Brandenburg
August 14, 2019 04:55 AM

Related Questions

How to create a Folder Dialog?

Updated April 04, 2015 21:06 PM

Mesh's material_index is an index into what?

Updated April 17, 2015 20:06 PM

OS cursor location in Blender Windows

Updated March 29, 2015 06:05 AM