19 lines
1.1 KiB
Python
19 lines
1.1 KiB
Python
import bpy,os,json
|
|
s=bpy.context.scene
|
|
old=next((c for c in s.collection.children if c.name.startswith('Gloved Arms')),None)
|
|
if old:
|
|
for o in list(old.objects):bpy.data.objects.remove(o,do_unlink=True)
|
|
bpy.data.collections.remove(old)
|
|
path=r'C:\roblox\hunter\3D models\hand\source\HandWithGloves.blend'
|
|
with bpy.data.libraries.load(path,link=False) as (src,dst):dst.objects=src.objects
|
|
c=bpy.data.collections.new('User Gloved Hands');s.collection.children.link(c)
|
|
for o in dst.objects:
|
|
if o:c.objects.link(o)
|
|
texdir=r'C:\roblox\hunter\3D models\hand\textures'
|
|
for im in bpy.data.images:
|
|
filename=os.path.basename(im.filepath.replace('\\','/'))
|
|
candidate=os.path.join(texdir,filename)
|
|
if filename and os.path.isfile(candidate):im.filepath=candidate;im.reload();im.pack()
|
|
bpy.context.view_layer.update()
|
|
print(json.dumps([{'name':o.name,'type':o.type,'location':list(o.location),'dimensions':list(o.dimensions),'parent':o.parent.name if o.parent else None,'bones':[(b.name,list(b.head_local),list(b.tail_local)) for b in o.data.bones] if o.type=='ARMATURE' else []} for o in c.objects]))
|