[Bf-python] Library module (2.49 series)
Toni Alatalo
antont at kyperjokki.fi
Mon Sep 21 09:41:20 CEST 2009
Goat Man kirjoitti:
> As far as i know (i've been looking), Append-or-Link is not available
> from Python, i wish it were. Or a way to simply merge all objects
> from a .blend into the current scene (from Python).
I experimented with this early on at Orange for Elephants Dream, and
seemed that 'junkster.blend' where the idea was to populate a hand-made
floor mesh with random items from a library has been archived at
http://wiki.blender.org/index.php/Extensions:Py/Scripts/Manual/Add/Junkster
Here are the relevant sources from junkster.blend LibAppend.py and
CreateTest.py
import Blender
from Blender import Library, Scene
scene = Scene.GetCurrent()
elephantdir = '/home/antont/elephant'
junklib = elephantdir + '/production/lib/machine/pieces/randomjunk.blend'
print Library.Open(junklib)
#Blender.Lib_Open(junklib)
groups = Library.LinkableGroups()
#for db in groups:
# print "DATABLOCK %s", db
# for obname in Library.Datablocks(db):
# print obname
scene.layers = [20]
if 'Object' in groups:
appends = [Library.Load(obname, 'Object', 0) for obname in
Library.Datablocks('Object')]
Library.Update()
else:
print "no junk objects?"
print len(appends), "added"
scene.layers = [1]
Library.Close()
---
junknames = ['suikero', 'purikka', 'tikkaat']
junks = [Object.Get(name) for name in junknames]
for v in mesh.verts:
new = Object.New('Mesh', 'gen')
new.loc = variate(v.co, 0.2)
source = random.choice(junks)
new.link(source.data)
scene.link(new)
new.size = tuple(variate(new.size))
#new.setSize(variate(new.size))
> -brett
~Toni
> On Sun, Sep 20, 2009 at 10:46 PM, Bassam Kurdali <bkurdali at freefac.org
> <mailto:bkurdali at freefac.org>> wrote:
>
> Can you append the scene? or if that is not feasible, group all
> inter-related objects and append that group?
> cheers
> Bassam
>
> On Sun, 2009-09-20 at 19:55 +0800, Goat Man wrote:
> > I'm having a hard time using the Library module to append
> objects to a
> > scene, for some objects i get cyclic dependencies errors, these only
> > go away if i load objects in their proper order (root, branches,
> then
> > leaves). But how can i peek into a .blend file to see the
> > relationships so the load order can be found before using
> > Library.load(..) ?
> >
> > Actually i just want to append the entire .blend file to the current
> > one (and keep my script running), problem i had trying to use the
> > other Blender.Load function is that when the new file is loaded it
> > stops the current script.
> >
> > -brett
> > _______________________________________________
> > Bf-python mailing list
> > Bf-python at blender.org <mailto:Bf-python at blender.org>
> > http://lists.blender.org/mailman/listinfo/bf-python
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org <mailto:Bf-python at blender.org>
> http://lists.blender.org/mailman/listinfo/bf-python
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
More information about the Bf-python
mailing list