-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators_document.py
More file actions
56 lines (42 loc) · 1.79 KB
/
Copy pathoperators_document.py
File metadata and controls
56 lines (42 loc) · 1.79 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import bpy
from bpy.props import IntProperty
from . import page_manager
from .guides import rebuild_guides
class EDITORIALGP_OT_create_document(bpy.types.Operator):
bl_idname = "editorial_gp.create_document"
bl_label = "Create Editorial Document"
bl_options = {'REGISTER', 'UNDO'}
page_count: IntProperty(name="Page Count", default=4, min=1, max=100)
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def execute(self, context):
scene = context.scene
existing = page_manager.page_collections(scene)
if existing:
self.report({'ERROR'}, "An editorial document already exists in the scene")
return {'CANCELLED'}
page_manager.ensure_root(scene)
page_manager.ensure_guides_collection(scene)
for _ in range(self.page_count):
page_manager.create_page(scene)
scene.editorial_gp.initialized = True
scene.editorial_gp.current_page_index = 0
page_manager.set_active_page(scene, 0, context.view_layer)
rebuild_guides(scene)
self.report({'INFO'}, f"Document created with {self.page_count} pages")
return {'FINISHED'}
class EDITORIALGP_OT_apply_document_settings(bpy.types.Operator):
bl_idname = "editorial_gp.apply_document_settings"
bl_label = "Apply Format and Guides"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
rebuild_guides(context.scene)
self.report({'INFO'}, "Format and guides updated")
return {'FINISHED'}
classes = (EDITORIALGP_OT_create_document, EDITORIALGP_OT_apply_document_settings)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)