-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators_imposition.py
More file actions
39 lines (30 loc) · 1.24 KB
/
Copy pathoperators_imposition.py
File metadata and controls
39 lines (30 loc) · 1.24 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
import bpy
from . import page_manager
from .imposition import impose_booklet, validate_plan, brochure_plan, validate_brochure_plan
class EDITORIALGP_OT_validate_imposition(bpy.types.Operator):
bl_idname = "editorial_gp.validate_imposition"
bl_label = "Check Imposition"
bl_options = {'REGISTER'}
def execute(self, context):
pages = page_manager.page_collections(context.scene)
kind = context.scene.editorial_gp.imposition_type
if kind == 'BOOKLET':
errors = validate_plan(impose_booklet(len(pages)))
else:
width, _ = page_manager.page_dimensions_mm(context.scene)
ratio = max(0.5, (width-context.scene.editorial_gp.fold_inset_mm)/width)
plan = brochure_plan(kind, ratio)
errors = validate_brochure_plan(plan, len(pages))
if errors:
for error in errors:
self.report({'ERROR'}, error)
return {'CANCELLED'}
self.report({'INFO'}, "Imposition is consistent")
return {'FINISHED'}
classes = (EDITORIALGP_OT_validate_imposition,)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)