Newer
Older
sub.levels = self.tmp_level
return {'FINISHED'}
CoDEmanX
committed
CoDEmanX
committed
def invoke(self, context, event):
CoDEmanX
committed
bpy.data.objects['Empty for BProjection']
context.window_manager.modal_handler_add(self)
self.first_mouse.x = event.mouse_region_x
CoDEmanX
committed
self.first_mouse.y = event.mouse_region_y
for sub in context.object.modifiers:
if sub.type in ['SUBSURF', 'MULTIRES']:
self.tmp_level = sub.levels
if sub.levels - self.tmp_level < 0:
CoDEmanX
committed
sub.levels += bpy.context.object.custom_fnlevel
return {'RUNNING_MODAL'}
CoDEmanX
committed
def execute(self, context):
align_to_view(context)
# Operator Class to zoom the view3D
class ZoomView3D(Operator):
bl_idname = "view3d.zoom_view3d"
bl_label = "Zoom View3D"
name="delta",
description="Delta",
min=-1.0, max=1,
default=1.0)
CoDEmanX
committed
def invoke(self, context, event):
ob = context.object
em = bpy.data.objects[BProjection_Empty]
sd = context.space_data
width = context.region.width
CoDEmanX
committed
height = context.region.height
r3d = sd.region_3d
v_init = Vector((0.0, 0.0, 1.0))
pos = [width, height]
vtr_b = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
pos = [0, 0]
vbl_b = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
len_b = vtr_b - vbl_b
CoDEmanX
committed
bpy.ops.view3d.zoom(delta=self.delta)
pos = [width, height]
vtr_a = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
pos = [0, 0]
CoDEmanX
committed
vbl_a = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
CoDEmanX
committed
fac = len_a.length / len_b.length
r3d.view_location -= ob.location
r3d.view_location *= fac
r3d.view_location += ob.location
vres = Vector((em. custom_location. x * fac, em.custom_location. y * fac, em.custom_location.z))
CoDEmanX
committed
Geo Kgeo
committed
if not em.custom_style_clone:
em.custom_location = vres
CoDEmanX
committed
CoDEmanX
committed
CoDEmanX
committed
def execute(self, context):
CoDEmanX
committed
# Operator Class to use numpad shortcut
class PresetView3D(Operator):
bl_idname = "view3d.preset_view3d"
bl_label = "Preset View3D"
view: StringProperty(name="View", description="Select the view", default='TOP')
CoDEmanX
committed
def invoke(self, context, event):
ob = context.object
origine = ob.location
sd = context.space_data
vr_b = sd.region_3d.view_rotation.copy()
vr_b.invert()
pos_init = sd.region_3d.view_location - origine
sd.region_3d.view_location = origine
tmp = context.preferences.view.smooth_view
context.preferences.view.smooth_view = 0
bpy.ops.view3d.viewnumpad(type=self.view)
CoDEmanX
committed
align_to_view(context)
context.preferences.view.smooth_view = tmp
CoDEmanX
committed
vr_a = sd.region_3d.view_rotation.copy()
pos_init.rotate(vr_a * vr_b)
sd.region_3d.view_location = pos_init + origine
CoDEmanX
committed
class Shortcuts_Pref(AddonPreferences):
bl_idname = __name__
def draw(self, context):
layout = self.layout
scene = context.scene
layout.prop(context.scene, "bp_shortcuts", text="Hot Keys", icon="KEYINGSET")
if scene.bp_shortcuts:
row = layout.row()
col = row.column()
col.label(text="Hotkey List:")
col.label(text="Shift + left mouse - Intuitive Scale")
col.label(text="G + mouse move to translate the projection plane")
col.label(text="R + mouse move to rotate the projection plane")
col.label(text="Ctrl + S + mouse move to scale the projection plane")
col.label(text="U + mouse move to scale the projection plane UV")
col.label(text="Y + mouse move to offset the projection plane UV")
col.label(text="C - clear all")
col.label(text="Q - toggle alpha of the projection plane")
@persistent
def load_handler(dummy):
reinitkey()
bpy.types.Scene.bp_shortcuts = BoolProperty(
default=False,
description='Show shortcuts for BP Projection'
)
createcustomprops(bpy.context)
bpy.app.handlers.load_post.append(load_handler)
del bpy.types.Scene.bp_shortcuts
register()