19 lines
1.1 KiB
Python
19 lines
1.1 KiB
Python
import bpy,os
|
|
from mathutils import Matrix,Vector
|
|
OUT=r'C:\roblox\Ornament Generator RNG\shop'
|
|
bpy.ops.wm.open_mainfile(filepath=os.path.join(OUT,'christmas_shop_v2.blend'))
|
|
prefix=('Timber post','Red ribbon','Gold ribbon','Ribbon fishtail','Tail gold','Holly leaf','Bow berry')
|
|
targets={o.name:o for o in bpy.context.scene.objects if o.name.startswith(prefix)}
|
|
with bpy.data.libraries.load(os.path.join(OUT,'christmas_shop.blend'),link=False) as (src,dst):
|
|
names=[n for n in src.objects if n in targets];dst.objects=list(names)
|
|
for name,original in zip(names,dst.objects):
|
|
ob=targets[name];ob.matrix_world=original.matrix_world.copy()
|
|
if name.startswith('Timber post'):ob.scale.x*=1.15;ob.scale.y*=1.15
|
|
else:ob.matrix_world=Matrix.Translation((0,0,6.3))@Matrix.Diagonal((1,1,.85,1))@Matrix.Translation((0,0,-6.3))@ob.matrix_world
|
|
bpy.data.objects.remove(original,do_unlink=True)
|
|
sc=bpy.context.scene
|
|
sc.render.filepath=os.path.join(OUT,'christmas_shop_v2_preview.png')
|
|
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'christmas_shop_v2.blend'))
|
|
bpy.ops.render.render(write_still=True)
|
|
|