I just tried it, your right Martin, thanks!<br><br><div class="gmail_quote">On Fri, Dec 18, 2009 at 9:05 AM, Martin Poirier <span dir="ltr"><<a href="mailto:theeth@yahoo.com">theeth@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Can't you append the scene itself (all objects will follow automatically), than link all objects in it to the destination scene and unlink the appended scene?<br>
<br>
Martin<br>
<br>
--- On Thu, 12/17/09, Goat Man <<a href="mailto:goatman.py@gmail.com">goatman.py@gmail.com</a>> wrote:<br>
<br>
> From: Goat Man <<a href="mailto:goatman.py@gmail.com">goatman.py@gmail.com</a>><br>
> Subject: [Bf-python] cyclic dependency errors using Blender.Library<br>
> To: "Blender Foundation Python list" <<a href="mailto:bf-python@blender.org">bf-python@blender.org</a>><br>
> Received: Thursday, December 17, 2009, 6:51 PM<br>
<div><div></div><div class="h5">> I can not find any documentation how to<br>
> append an entire scene using Blender.Library or the newer<br>
> libData module that will always avoid cyclic dependency<br>
> errors. The cyclic errors are caused when a dependent<br>
> object is loaded before the object it needs to reference. <br>
> For example the object may be the child of the other, or a<br>
> modifier might reference it.<br>
><br>
><br>
> Library.Datablocks('Object')this<br>
> function seems to return object names in random order, not<br>
> their order of dependence.<br>
> so simply iterating through the names, and calling:<br>
> Library.Load(obname, 'Object',0) will cause the<br>
> cyclic dependency errors.<br>
><br>
><br>
> Currently i am using this very ugly workaround to peek into<br>
> a blend file before loading it, checking every object in the<br>
> scene and finding the dependency order, this gets saved to a<br>
> pickled file, which is then read and gives Library.Load the<br>
> proper order. There must be a better way.<br>
><br>
><br>
> import Blender, bpy, random, pickle<br>
><br>
> def inspect():<br>
> r = {}<br>
> order = []<br>
> objects = {}<br>
> for bo in bpy.data.scenes.active.objects:<br>
> r[ <a href="http://bo.name" target="_blank">bo.name</a> ] = []<br>
><br>
> order.append( <a href="http://bo.name" target="_blank">bo.name</a> )<br>
> objects[ <a href="http://bo.name" target="_blank">bo.name</a> ] = bo<br>
><br>
> ##################################<br>
> for bo in bpy.data.scenes.active.objects:<br>
><br>
><br>
> if bo.parent:<br>
> deps = r[ <a href="http://bo.parent.name" target="_blank">bo.parent.name</a> ]<br>
> if <a href="http://bo.name" target="_blank">bo.name</a> not in deps:<br>
> deps.append( <a href="http://bo.name" target="_blank">bo.name</a> )<br>
><br>
> #print 'parent-dependent<br>
> ->', <a href="http://bo.parent.name" target="_blank">bo.parent.name</a>, <a href="http://bo.name" target="_blank">bo.name</a><br>
><br>
> for mod in bo.modifiers:<br>
> print mod<br>
> try:<br>
><br>
> mbo =<br>
> mod[Blender.Modifier.Settings.OBJECT]<br>
> deps = r[ <a href="http://mbo.name" target="_blank">mbo.name</a> ]<br>
> if <a href="http://bo.name" target="_blank">bo.name</a> not in<br>
> deps:<br>
> deps.append( <a href="http://bo.name" target="_blank">bo.name</a> )<br>
><br>
> #print<br>
> 'mod-dependent ->', <a href="http://mbo.name" target="_blank">mbo.name</a>, <a href="http://bo.name" target="_blank">bo.name</a><br>
><br>
> except: pass<br>
><br>
> for cns in bo.constraints:<br>
> print cns<br>
><br>
> target = None<br>
> try: target = cns[<br>
> Blender.Constraint.Settings.TARGET ]<br>
> except: pass<br>
> if target:<br>
> deps = r[ <a href="http://target.name" target="_blank">target.name</a> ]<br>
><br>
> if <a href="http://bo.name" target="_blank">bo.name</a> not in<br>
> deps:<br>
> deps.append( <a href="http://bo.name" target="_blank">bo.name</a> )<br>
> print 'cns-dependent<br>
> ->', <a href="http://target.name" target="_blank">target.name</a>, <a href="http://bo.name" target="_blank">bo.name</a><br>
><br>
><br>
> #if bo.type == 'Mesh': print <a href="http://bo.name" target="_blank">bo.name</a>; print bo.modifiers[0]<br>
><br>
> #random.shuffle( order )<br>
> while True:<br>
> #for p in range(4):<br>
> stop = True<br>
><br>
> for n1 in r:<br>
> curidx = order.index( n1 )<br>
> for n2 in r:<br>
> if n1 != n2:<br>
> deps = r[n2]<br>
> if n1 in deps:<br>
> idx =<br>
> order.index( n2 )<br>
><br>
> if curidx <<br>
> idx:<br>
> stop =<br>
> False<br>
> curidx =<br>
> idx+1<br>
> <br>
> order.remove( n1 )<br>
> <br>
> order.insert( idx+1, n1 )<br>
><br>
> #print<br>
> 'new idxs', order.index(n1), order.index(n2)<br>
> elif curidx ==<br>
> idx: print 'this is a bug'<br>
><br>
> #print order<br>
> if stop: break<br>
><br>
> #print order<br>
><br>
> preempties = []<br>
> postempties = []<br>
> empties = []<br>
> armatures = []<br>
> meshes = []<br>
> lattices = []<br>
> lights = []<br>
> cameras = []<br>
> others = []<br>
> for n in order:<br>
><br>
> ob = objects[n]<br>
> t = ob.type<br>
> if t == 'Armature': armatures.append(<br>
> n )<br>
> elif t == 'Empty':<br>
> empties.append( n )<br>
> if ob.emptyShape == 4: #<br>
> single arrow<br>
><br>
> postempties.append( n )<br>
> else: preempties.append( n )<br>
> elif t == 'Lattice': lattices.append(<br>
> n )<br>
> elif t == 'Lamp': lights.append( n )<br>
> elif t == 'Camera': cameras.append( n<br>
> )<br>
><br>
> elif t == 'Mesh': meshes.append( n )<br>
> else: others.append( n )<br>
><br>
> ## this simple rule works ##<br>
> loadorder = preempties + armatures + postempties +<br>
> lattices + lights + meshes + others<br>
><br>
> dump = {<br>
> 'load-order' : loadorder,<br>
> 'empties' : empties,<br>
> 'armatures' : armatures,<br>
> 'meshes' : meshes,<br>
> 'lattices' : lattices,<br>
><br>
> 'lights' : lights,<br>
> 'cameras' : cameras<br>
> }<br>
> return dump<br>
> pickle.dump( inspect(),<br>
> open('/tmp/blend-inspection','wb'), -1 )<br>
> Blender.Quit()<br>
><br>
><br>
><br>
><br>
</div></div>> -----Inline Attachment Follows-----<br>
><br>
> _______________________________________________<br>
> Bf-python mailing list<br>
> <a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
> <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
><br>
<br>
<br>
__________________________________________________________________<br>
Looking for the perfect gift? Give the gift of Flickr!<br>
<br>
<a href="http://www.flickr.com/gift/" target="_blank">http://www.flickr.com/gift/</a><br>
_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
</blockquote></div><br>