generated from stilobique/BlenderTemplate
Compare commits
3 Commits
4852d57ef6
...
57379a0ff6
| Author | SHA1 | Date | |
|---|---|---|---|
| 57379a0ff6 | |||
| c000fae4a8 | |||
| e959960e42 |
@@ -1,6 +1,7 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from ..models import FangeProject
|
from ..models import FangeProject
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class ExportForFange(bpy.types.Operator):
|
class ExportForFange(bpy.types.Operator):
|
||||||
@@ -11,32 +12,41 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.coll_layout = bpy.data.collections.get('Placeholder')
|
self.coll_layout = bpy.data.collections.get('Placeholder')
|
||||||
self.path = FangeProject()
|
self.path = FangeProject()
|
||||||
|
self.asset = self.get_asset_name()
|
||||||
|
self.category = self.get_asset_type()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
col = bpy.data.collections.get('Placeholder')
|
col = bpy.data.collections.get('Placeholder')
|
||||||
|
|
||||||
if col is not None:
|
if col is not None and bpy.data.is_saved:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
print(f'[Pipeline] Start to export the building props.')
|
print(f'[Pipeline] Start to export the building props.')
|
||||||
|
|
||||||
|
# Make a check if the file are saved on the disk
|
||||||
|
if not bpy.data.is_saved:
|
||||||
|
self.report({'ERROR'}, 'Your blend file is not saved.')
|
||||||
|
return {'CANCELLED'}
|
||||||
|
|
||||||
|
if not self.category:
|
||||||
|
self.report({'ERROR'}, 'Can\'t find the asset category.')
|
||||||
|
return {'CANCELLED'}
|
||||||
|
|
||||||
if len(self.coll_layout.collection_children):
|
if len(self.coll_layout.collection_children):
|
||||||
for coll in self.coll_layout.children:
|
for coll in self.coll_layout.children:
|
||||||
print(f'[Pipeline] Update "{coll.name}" mesh')
|
print(f'[Pipeline] Update "{coll.name}" mesh')
|
||||||
child = bpy.data.collections.get(coll.name)
|
child = bpy.data.collections.get(coll.name)
|
||||||
|
|
||||||
print(f'[Pipeline] Select all mesh inside the collection "{child.name}"')
|
|
||||||
for ob in child.all_objects:
|
for ob in child.all_objects:
|
||||||
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
||||||
# TODO Support another type object, not only SM/SK
|
# TODO Support another type object, not only SM/SK
|
||||||
if isinstance(ob.data, bpy.types.Mesh):
|
if ob.type == 'MESH' or 'EMPTY':
|
||||||
ob.select_set(True)
|
ob.select_set(True)
|
||||||
|
|
||||||
# TODO The plugin export only the garden building
|
abs_export = self.category.joinpath(self.asset, "Meshes")
|
||||||
abs_export = self.path.buildings.joinpath("Garden", "Meshes")
|
|
||||||
if not abs_export.exists():
|
if not abs_export.exists():
|
||||||
abs_export.mkdir()
|
abs_export.mkdir()
|
||||||
|
|
||||||
@@ -86,5 +96,33 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
|
|
||||||
# for coll in coll_layout.children:
|
# for coll in coll_layout.children:
|
||||||
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
|
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
|
||||||
|
|
||||||
|
self.report({'INFO'}, 'Placeholder exported')
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def get_asset_type(self) -> Path:
|
||||||
|
"""Look the file path, to understand if the asset are a Character, Buildings or Props"""
|
||||||
|
abs_blend_path = Path(bpy.data.filepath)
|
||||||
|
print(f'[Pipeline] Get blend file path "{abs_blend_path}"')
|
||||||
|
print(f'[Pipeline] Convert to List "{abs_blend_path.parts}"')
|
||||||
|
|
||||||
|
if 'Buildings' in abs_blend_path.parts:
|
||||||
|
print(f'[Pipeline] Export here "{self.path.buildings}"')
|
||||||
|
return self.path.buildings
|
||||||
|
|
||||||
|
elif 'Pros' in abs_blend_path.parts:
|
||||||
|
print(f'[Pipeline] Export here "{self.path.props}"')
|
||||||
|
return self.path.props
|
||||||
|
|
||||||
|
elif 'Characters' in abs_blend_path.parts:
|
||||||
|
print(f'[Pipeline] Export here "{self.path.characters}"')
|
||||||
|
return self.path.characters
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f'[Pipeline] Can\'t find asset category')
|
||||||
|
return Path()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_asset_name():
|
||||||
|
abs_blend_path = Path(bpy.data.filepath)
|
||||||
|
return abs_blend_path.stem
|
||||||
|
|||||||
@@ -24,4 +24,6 @@ class GRAOU_PT_panel(bpy.types.Panel):
|
|||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text='Export scene:')
|
row.label(text='Export scene:')
|
||||||
|
box = layout.box()
|
||||||
|
box.label(text='Sanity Check')
|
||||||
layout.operator('graou.building_export', text='Export all assets', icon='EXPORT')
|
layout.operator('graou.building_export', text='Export all assets', icon='EXPORT')
|
||||||
|
|||||||
Reference in New Issue
Block a user