61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
import bpy
|
|
from pathlib import Path
|
|
|
|
from ..bioxelutils.utils import get_layer_prop_value
|
|
from .. import __package__ as base_package
|
|
|
|
|
|
def select_object(target_obj):
|
|
for obj in bpy.data.objects:
|
|
obj.select_set(False)
|
|
|
|
target_obj.select_set(True)
|
|
bpy.context.view_layer.objects.active = target_obj
|
|
|
|
|
|
def progress_bar(self, context):
|
|
row = self.layout.row()
|
|
row.progress(
|
|
factor=context.window_manager.bioxelnodes_progress_factor,
|
|
type="BAR",
|
|
text=context.window_manager.bioxelnodes_progress_text
|
|
)
|
|
row.scale_x = 2
|
|
|
|
|
|
def progress_update(context, factor, text=""):
|
|
context.window_manager.bioxelnodes_progress_factor = factor
|
|
context.window_manager.bioxelnodes_progress_text = text
|
|
|
|
|
|
def get_preferences(context):
|
|
return context.preferences.addons[base_package].preferences
|
|
|
|
|
|
def get_cache_dir(context):
|
|
preferences = get_preferences(context)
|
|
cache_path = Path(preferences.cache_dir, 'VDBs')
|
|
cache_path.mkdir(parents=True, exist_ok=True)
|
|
return str(cache_path)
|
|
|
|
|
|
def get_layer_item_label(context, layer_obj):
|
|
label = get_layer_label(layer_obj)
|
|
cache_filepath = Path(bpy.path.abspath(layer_obj.data.filepath)).resolve()
|
|
if cache_filepath.is_file():
|
|
cache_dirpath = Path(get_cache_dir(context))
|
|
if cache_dirpath in cache_filepath.parents:
|
|
label = "* " + label
|
|
|
|
else:
|
|
label = "**MISSING**" + label
|
|
|
|
return label
|
|
|
|
|
|
def get_layer_label(layer_obj):
|
|
name = get_layer_prop_value(layer_obj, "name")
|
|
kind = get_layer_prop_value(layer_obj, "kind")
|
|
|
|
return f"{name}"
|