-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathasset_loader.py
More file actions
36 lines (29 loc) · 1.29 KB
/
asset_loader.py
File metadata and controls
36 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import bpy
import os
class AssetLoader(object):
overteDomainModels = {}
@staticmethod
def find_all_models():
for library in bpy.context.preferences.filepaths.asset_libraries:
for root, dir, files in os.walk(library.path):
basePath = root.replace(library.path, "")
for fileName in files:
if fileName.startswith("Model"):
continue
if (fileName.endswith(".obj") or fileName.endswith(".fbx") or fileName.endswith(".gltf") or fileName.endswith(".glb")):
modelName=os.path.splitext(fileName)[0]
AssetLoader.overteDomainModels[modelName] = basePath + "/" + fileName
@staticmethod
def getOverteModelUrl(obj):
entityBaseName = obj.name.partition(".")[0]
if entityBaseName in AssetLoader.overteDomainModels:
return AssetLoader.overteDomainModels[entityBaseName]
return None
class AssetLoaderOperator(bpy.types.Operator):
"""Refreshes the list of available models in the asset path"""
bl_idname = "world.overte_refresh_library"
bl_label = "Refresh models library"
bl_options = {'REGISTER'}
def execute(self, context):
AssetLoader.find_all_models()
return {'FINISHED'}