More Bad Parenting: Import problems?

This is a script to get objects from a file:

import Blender
from Blender import Library
Library.Open("//HumanRig08.blend")
groups = Library.LinkableGroups()
for db in groups:
print “DATABLOCK %s:” % db
for obname in Library.Datablocks(db):
print obname
if ‘Object’ in groups:
for obname in Library.Datablocks(‘Object’):
Library.Load(obname, ‘Object’, 0) # note the 0…
Library.Update()

Library.Close()
Blender.Redraw()

Very simple, basically ripped right from the API. Funny thing though, when running the script, it seems to leave it to Blender to decide, at something that appears to be random, whether or not to bring an object’s parenting information along with it; some objects ar eparented as they should be, some are not. There is no apparent logic behind which are and which are not, but every time the script is run, the same objects are/aren’t parented.

This makes no sense to me. Can someone explain what is wrong?

EDIT: Okay, now Blender is adding insult to injury… It seems that an object’s NAME has major influence on whether or not the script will import it’s parenting data. In my .blend file, there are three objects (there are more, but let’s stick to these three): Chest, Abdomen, and Hip. In the .blend file, Chest is the child of Abdomen, and Abdomen is the child of Hip; moving or rotating Hip affects all.

(remainder deleted due to EDIT2)

EDIT2: I may just have figured out how it works. For some reason, a parenting link only works when the name of the parent is alphabetically after the child; if ‘alpha_ob’ is the parent of ‘beta_ob’, the link does NOT get imported, but if ‘alpha_ob’ is the child, it does.

I cannot see any reason for this in the script. Since I have found several other oddities surrounding Blender’s parenting functions, I am worrying there might be a real problem. If someone can see the flaw in the script, please tell me and put my worries to rest…

interesting, i have no experience with using the Library module of blender, but could the problem be caused since you didn’t import the parents before you import the children? in other words, if you import a child first before its parent is imported, blender may discard the parenting info because it cannot find a parent … anyway, i’m just randomly guessing, your question may be better answered if you put together a simple example and post it here and pm it to ideasman42 (the Library module is his baby).

I was thinking something in that direction, too. It’s just really weird that it is reacting 100% to alphabetical order :eek: I’ll do some sort of example file this week. And if ideasman is on it, I have the utmost confidence that things will be resolved :slight_smile:

khpython has made a new library api

http://members.optusnet.com.au/cjbarton/BPY_API/LibData-module.html

I fixed the problem where appending - unlinked all previously linked data.
could you get a recent build and test with the new API?

I would be honored to test out the new version. Do you have the link to a windows build?

I do need a little more understanding of the new ‘Libraries’ module, though, in particular how I make it list the full contents of a .blend file loaded with load(), so that I can loop it and get all the file’s contents imported without writing each out specifically by name.

Oh, and does the Object data (as opposed to Mesh data, etc.) include parenting? Or where is that information stored?