Check canvas alignement
1.6.5 - feat: check canvas alignement of the Gp object compare to chosen draw axis
This commit is contained in:
+35
-4
@@ -2,7 +2,7 @@ import bpy
|
||||
from mathutils import Vector#, Matrix
|
||||
from pathlib import Path
|
||||
from math import radians
|
||||
from .utils import get_gp_objects, set_collection, show_message_box
|
||||
from . import utils
|
||||
|
||||
class GPTB_OT_copy_text(bpy.types.Operator):
|
||||
bl_idname = "wm.copytext"
|
||||
@@ -170,7 +170,7 @@ class GPTB_OT_draw_cam(bpy.types.Operator):
|
||||
|
||||
# dcam_col = bpy.data.collections.get(camcol_name)
|
||||
# if not dcam_col:
|
||||
set_collection(drawcam, camcol_name)
|
||||
utils.set_collection(drawcam, camcol_name)
|
||||
|
||||
# Swap to it, unhide if necessary and hide previous
|
||||
context.scene.camera = maincam
|
||||
@@ -188,7 +188,7 @@ class GPTB_OT_draw_cam(bpy.types.Operator):
|
||||
if not drawcam:
|
||||
created=True
|
||||
drawcam = bpy.data.objects.new(dcam_name, context.scene.camera.data)
|
||||
set_collection(drawcam, 'manip_cams')
|
||||
utils.set_collection(drawcam, 'manip_cams')
|
||||
|
||||
if dcam_name == 'draw_cam':
|
||||
drawcam.parent = maincam
|
||||
@@ -390,7 +390,7 @@ class GPTB_OT_list_disabled_anims(bpy.types.Operator):
|
||||
else:
|
||||
li.append(f'{" "*len(o.name)} - {fcu.data_path} {fcu.array_index}')
|
||||
if li:
|
||||
show_message_box(li)
|
||||
utils.show_message_box(li)
|
||||
else:
|
||||
self.report({'INFO'}, f"No animation disabled on {'selection' if self.selection else 'scene'}")
|
||||
return {'FINISHED'}
|
||||
@@ -485,6 +485,36 @@ class GPTB_OT_clear_active_frame(bpy.types.Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class GPTB_OT_check_canvas_alignement(bpy.types.Operator):
|
||||
bl_idname = "gp.check_canvas_alignement"
|
||||
bl_label = "Check Canvas Alignement"
|
||||
bl_description = "Check if view is aligned to canvas\nWarn if the drawing angle to surface is too high\nThere can be some error margin"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# if lock_axis is 'VIEW' then the draw axis is always aligned
|
||||
return context.object and context.object.type == 'GPENCIL'# and context.scene.tool_settings.gpencil_sculpt.lock_axis != 'VIEW'
|
||||
|
||||
def execute(self, context):
|
||||
if context.scene.tool_settings.gpencil_sculpt.lock_axis == 'VIEW':
|
||||
self.report({'INFO'}, 'Drawing plane use "View" (always aligned)')
|
||||
return {'FINISHED'}
|
||||
|
||||
_angle, ret, message = utils.check_angle_from_view(obj=context.object, context=context)
|
||||
if not ret or not message:
|
||||
self.report({'ERROR'}, 'Could not get view angle infos')
|
||||
return {'CANCELLED'}
|
||||
|
||||
title = 'Aligned \o/' if ret == 'INFO' else "Not aligned !"
|
||||
|
||||
if context.region_data.view_perspective != 'CAMERA':
|
||||
title = title + ' ( not in camera view)'
|
||||
|
||||
utils.show_message_box(_message=message, _title=title, _icon=ret)
|
||||
# self.report({ret}, message)
|
||||
return {'FINISHED'}
|
||||
|
||||
classes = (
|
||||
GPTB_OT_copy_text,
|
||||
GPTB_OT_flipx_view,
|
||||
@@ -495,6 +525,7 @@ GPTB_OT_reset_cam_rot,
|
||||
GPTB_OT_toggle_mute_animation,
|
||||
GPTB_OT_list_disabled_anims,
|
||||
GPTB_OT_clear_active_frame,
|
||||
GPTB_OT_check_canvas_alignement,
|
||||
)
|
||||
|
||||
def register():
|
||||
|
||||
Reference in New Issue
Block a user