83 lines
2.2 KiB
Python
83 lines
2.2 KiB
Python
|
import bpy
|
||
|
from . import gen_vlayer, fn
|
||
|
|
||
|
class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||
|
bl_idname = "gp_export.render_auto_build"
|
||
|
bl_label = "Auto-Build"
|
||
|
bl_description = "Trigger all operation to make build render scene with default settings"
|
||
|
bl_options = {"REGISTER"}
|
||
|
|
||
|
@classmethod
|
||
|
def poll(cls, context):
|
||
|
return context.object and context.object.type == 'GPENCIL'
|
||
|
|
||
|
# mode : bpy.props.StringProperty(options={'SKIP_SAVE'})
|
||
|
|
||
|
def execute(self, context):
|
||
|
'''
|
||
|
ob = context.object
|
||
|
layer = ob.data.layers.active
|
||
|
if not layer:
|
||
|
self.report({'ERROR'}, 'No active layer')
|
||
|
return {"CANCELLED"}
|
||
|
|
||
|
ct = 0
|
||
|
# send scene ?
|
||
|
hided = 0
|
||
|
for l in ob.data.layers:
|
||
|
if not l.select:
|
||
|
if not l.viewlayer_render:
|
||
|
l.viewlayer_render = fn.get_view_layer('exclude').name
|
||
|
continue
|
||
|
gen_vlayer.get_set_viewlayer_from_gp(ob, l)
|
||
|
|
||
|
if l.hide:
|
||
|
hided += 1
|
||
|
ct += 1
|
||
|
|
||
|
if hided:
|
||
|
self.report({'WARNING'}, f'{hided}/{ct} layers are hided !')
|
||
|
|
||
|
else:
|
||
|
self.report({'INFO'}, f'{ct} layer(s) added to scene "Render"')
|
||
|
'''
|
||
|
|
||
|
## TODO: add colors to layers (specified in ENV or hardcoded for now...)
|
||
|
## Option: Maybe find a way to create a color from prefix hash ? (wlways give unique color with same prefix on other project!)
|
||
|
|
||
|
|
||
|
## Trigger rename lowercase
|
||
|
bpy.ops.gp.lower_layers_name()
|
||
|
|
||
|
## Trigger renumber by distance
|
||
|
bpy.ops.gp.auto_number_object()
|
||
|
|
||
|
## Export layer infos ?
|
||
|
bpy.ops.gp.export_infos_for_compo()
|
||
|
|
||
|
## Send all GP to render scene
|
||
|
bpy.ops.gp.add_object_to_render(mode="ALL")
|
||
|
|
||
|
## Group all adjacent layer type
|
||
|
|
||
|
## Renumber File outputs
|
||
|
|
||
|
## Trigger check file before finishing ?
|
||
|
|
||
|
|
||
|
## note: After all these operation, a ctrl+Z might crash
|
||
|
|
||
|
return {"FINISHED"}
|
||
|
|
||
|
|
||
|
classes=(
|
||
|
GPEXP_OT_render_auto_build,
|
||
|
)
|
||
|
|
||
|
def register():
|
||
|
for cls in classes:
|
||
|
bpy.utils.register_class(cls)
|
||
|
|
||
|
def unregister():
|
||
|
for cls in reversed(classes):
|
||
|
bpy.utils.unregister_class(cls)
|