From a4e7c60ac814847686341230118c732594c15992 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 5 Dec 2018 16:40:29 +0100 Subject: MeasureIt: First steps to migrate to 2.8 (WIP) Migrate add-on to 2.8 with new API. Still problems in render --- measureit/__init__.py | 88 ++++---- measureit/measureit_geometry.py | 175 ++++++++-------- measureit/measureit_main.py | 454 ++++++++++++++++++---------------------- measureit/measureit_render.py | 30 +-- 4 files changed, 340 insertions(+), 407 deletions(-) diff --git a/measureit/__init__.py b/measureit/__init__.py index a030fe73..fc5252a3 100644 --- a/measureit/__init__.py +++ b/measureit/__init__.py @@ -29,8 +29,8 @@ bl_info = { "name": "MeasureIt", "author": "Antonio Vazquez (antonioya)", "location": "View3D > Tools Panel /Properties panel", - "version": (1, 7, 1), - "blender": (2, 79, 0), + "version": (1, 8, 0), + "blender": (2, 80, 0), "description": "Tools for measuring objects.", "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/" "Py/Scripts/3D_interaction/Measureit", @@ -74,10 +74,10 @@ from bpy.props import ( # Define Panel classes for updating panels = ( - measureit_main.MeasureitEditPanel, - measureit_main.MeasureitMainPanel, - measureit_main.MeasureitConfPanel, - measureit_main.MeasureitRenderPanel, + measureit_main.MEASUREIT_PT_Edit, + measureit_main.MEASUREIT_PT_Main, + measureit_main.MEASUREIT_PT_Conf, + measureit_main.MEASUREIT_PT_Render, ) @@ -120,29 +120,35 @@ class Measure_Pref(AddonPreferences): # Define menu # noinspection PyUnusedLocal +classes = ( + measureit_main.MEASUREIT_OT_RunHintDisplay, + measureit_main.MEASUREIT_OT_AddSegment, + measureit_main.MEASUREIT_OT_AddArea, + measureit_main.MEASUREIT_OT_AddSegmentOrto, + measureit_main.MEASUREIT_OT_AddAngle, + measureit_main.MEASUREIT_OT_AddArc, + measureit_main.MEASUREIT_OT_AddLabel, + measureit_main.MEASUREIT_OT_AddNote, + measureit_main.MEASUREIT_OT_AddLink, + measureit_main.MEASUREIT_OT_AddOrigin, + measureit_main.MEASUREIT_OT_DeleteSegment, + measureit_main.MEASUREIT_OT_DeleteAllSegment, + measureit_main.MEASUREIT_OT_DeleteAllSum, + measureit_main.MEASUREIT_OT_RenderSegment, + measureit_main.MEASUREIT_OT_ExpandAllSegment, + measureit_main.MEASUREIT_OT_CollapseAllSegment, + measureit_main.MEASUREIT_PT_Main, + measureit_main.MEASUREIT_PT_Edit, + measureit_main.MEASUREIT_PT_Conf, + measureit_main.MEASUREIT_PT_Render, +# Measure_Pref, +) + def register(): - bpy.utils.register_class(measureit_main.RunHintDisplayButton) - bpy.utils.register_class(measureit_main.AddSegmentButton) - bpy.utils.register_class(measureit_main.AddAreaButton) - bpy.utils.register_class(measureit_main.AddSegmentOrtoButton) - bpy.utils.register_class(measureit_main.AddAngleButton) - bpy.utils.register_class(measureit_main.AddArcButton) - bpy.utils.register_class(measureit_main.AddLabelButton) - bpy.utils.register_class(measureit_main.AddNoteButton) - bpy.utils.register_class(measureit_main.AddLinkButton) - bpy.utils.register_class(measureit_main.AddOriginButton) - bpy.utils.register_class(measureit_main.DeleteSegmentButton) - bpy.utils.register_class(measureit_main.DeleteAllSegmentButton) - bpy.utils.register_class(measureit_main.DeleteAllSumButton) - bpy.utils.register_class(measureit_main.MeasureitEditPanel) - bpy.utils.register_class(measureit_main.MeasureitMainPanel) - bpy.utils.register_class(measureit_main.MeasureitConfPanel) - bpy.utils.register_class(measureit_main.MeasureitRenderPanel) - bpy.utils.register_class(measureit_main.RenderSegmentButton) - bpy.utils.register_class(measureit_main.ExpandAllSegmentButton) - bpy.utils.register_class(measureit_main.CollapseAllSegmentButton) - bpy.utils.register_class(Measure_Pref) - update_panel(None, bpy.context) + from bpy.utils import register_class + for cls in classes: + register_class(cls) + # Define properties Scene.measureit_default_color = FloatVectorProperty( name="Default color", @@ -420,27 +426,9 @@ def register(): def unregister(): - bpy.utils.unregister_class(measureit_main.RunHintDisplayButton) - bpy.utils.unregister_class(measureit_main.AddSegmentButton) - bpy.utils.unregister_class(measureit_main.AddAreaButton) - bpy.utils.unregister_class(measureit_main.AddSegmentOrtoButton) - bpy.utils.unregister_class(measureit_main.AddAngleButton) - bpy.utils.unregister_class(measureit_main.AddArcButton) - bpy.utils.unregister_class(measureit_main.AddLabelButton) - bpy.utils.unregister_class(measureit_main.AddNoteButton) - bpy.utils.unregister_class(measureit_main.AddLinkButton) - bpy.utils.unregister_class(measureit_main.AddOriginButton) - bpy.utils.unregister_class(measureit_main.DeleteSegmentButton) - bpy.utils.unregister_class(measureit_main.DeleteAllSegmentButton) - bpy.utils.unregister_class(measureit_main.DeleteAllSumButton) - bpy.utils.unregister_class(measureit_main.MeasureitEditPanel) - bpy.utils.unregister_class(measureit_main.MeasureitMainPanel) - bpy.utils.unregister_class(measureit_main.MeasureitConfPanel) - bpy.utils.unregister_class(measureit_main.MeasureitRenderPanel) - bpy.utils.unregister_class(measureit_main.RenderSegmentButton) - bpy.utils.unregister_class(measureit_main.ExpandAllSegmentButton) - bpy.utils.unregister_class(measureit_main.CollapseAllSegmentButton) - bpy.utils.unregister_class(Measure_Pref) + from bpy.utils import unregister_class + for cls in reversed(classes): + unregister_class(cls) # Remove properties del Scene.measureit_default_color @@ -501,7 +489,7 @@ def unregister(): del Scene.measureit_font_align # remove OpenGL data - measureit_main.RunHintDisplayButton.handle_remove(measureit_main.RunHintDisplayButton, bpy.context) + measureit_main.MEASUREIT_OT_RunHintDisplay.handle_remove(measureit_main.MEASUREIT_OT_RunHintDisplay, bpy.context) wm = bpy.context.window_manager p = 'measureit_run_opengl' if p in wm: diff --git a/measureit/measureit_geometry.py b/measureit/measureit_geometry.py index 3b2e0186..191f981b 100644 --- a/measureit/measureit_geometry.py +++ b/measureit/measureit_geometry.py @@ -26,8 +26,6 @@ # noinspection PyUnresolvedReferences import bpy # noinspection PyUnresolvedReferences -import bgl -# noinspection PyUnresolvedReferences import blf from blf import ROTATION from math import fabs, degrees, radians, sqrt, cos, sin, pi @@ -36,13 +34,16 @@ from bmesh import from_edit_mesh from bpy_extras import view3d_utils, mesh_utils import bpy_extras.object_utils as object_utils from sys import exc_info +# GPU +import bgl +import gpu +from gpu_extras.batch import batch_for_shader +shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') # ------------------------------------------------------------- # Draw segments # -# rgb: Color -# fsize: Font size # ------------------------------------------------------------- # noinspection PyUnresolvedReferences,PyUnboundLocalVariable def draw_segments(context, myobj, op, region, rv3d): @@ -60,6 +61,7 @@ def draw_segments(context, myobj, op, region, rv3d): ovrline = scene.measureit_ovr_width units = scene.measureit_units fang = get_angle_in_rad(scene.measureit_font_rotation) + # -------------------- # Scene Scale # -------------------- @@ -72,6 +74,7 @@ def draw_segments(context, myobj, op, region, rv3d): draw_text(myobj, pos_2d, tx_scale, scene.measureit_scale_color, scene.measureit_scale_font, text_rot=fang) + # -------------------- # Loop # -------------------- @@ -96,9 +99,10 @@ def draw_segments(context, myobj, op, region, rv3d): # noinspection PyBroadException try: if ovr is False: - rgb = ms.glcolor + rgba = ms.glcolor else: - rgb = ovrcolor + rgba = ovrcolor + # ---------------------- # Segment or Label # ---------------------- @@ -108,6 +112,7 @@ def draw_segments(context, myobj, op, region, rv3d): if ms.glpointa <= len(obverts) and ms.glpointb <= len(obverts): a_p1 = get_point(obverts[ms.glpointa].co, myobj) b_p1 = get_point(obverts[ms.glpointb].co, myobj) + # ---------------------- # Segment or Label # ---------------------- @@ -326,8 +331,6 @@ def draw_segments(context, myobj, op, region, rv3d): else: bgl.glLineWidth(ovrline) - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) - # ------------------------------------ # Text (distance) # ------------------------------------ @@ -366,7 +369,7 @@ def draw_segments(context, myobj, op, region, rv3d): if scene.measureit_gl_show_n is True and ms.glnames is True: msg += ms.gltxt if scene.measureit_gl_show_d is True or scene.measureit_gl_show_n is True: - draw_text(myobj, txtpoint2d, msg, rgb, fsize, faln, fang) + draw_text(myobj, txtpoint2d, msg, rgba, fsize, faln, fang) # ------------------------------ # if axis loc, show a indicator @@ -381,7 +384,7 @@ def draw_segments(context, myobj, op, region, rv3d): if ms.glocz is True: txt += "Z" txt += "]" - draw_text(myobj, txtpoint2d, txt, rgb, fsize - 1, text_rot=fang) + draw_text(myobj, txtpoint2d, txt, rgba, fsize - 1, text_rot=fang) except: pass @@ -445,7 +448,7 @@ def draw_segments(context, myobj, op, region, rv3d): tmp_point = get_2d_point(region, rv3d, gap3d) if tmp_point is not None: txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty - draw_text(myobj, txtpoint2d, msg, rgb, fsize, faln, fang) + draw_text(myobj, txtpoint2d, msg, rgba, fsize, faln, fang) # Radius if scene.measureit_gl_show_d is True and ms.gldist is True and \ ms.glarc_rad is True: @@ -461,7 +464,7 @@ def draw_segments(context, myobj, op, region, rv3d): tmp_point = get_2d_point(region, rv3d, gap3d) if tmp_point is not None: txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty - draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize, faln, fang) + draw_text(myobj, txtpoint2d, tx_dist, rgba, fsize, faln, fang) except: pass # ------------------------------------ @@ -475,31 +478,30 @@ def draw_segments(context, myobj, op, region, rv3d): tmp_point = get_2d_point(region, rv3d, gap3d) if tmp_point is not None: txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty - draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize, faln, fang) + draw_text(myobj, txtpoint2d, tx_dist, rgba, fsize, faln, fang) # ------------------------------------ # Draw lines # ------------------------------------ bgl.glEnable(bgl.GL_BLEND) - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) if ms.gltype == 1: # Segment - draw_line(screen_point_ap1, screen_point_v11) - draw_line(screen_point_bp1, screen_point_v22) - draw_arrow(screen_point_v1, screen_point_v2, a_size, a_type, b_type) + draw_line(screen_point_ap1, screen_point_v11, rgba) + draw_line(screen_point_bp1, screen_point_v22, rgba) + draw_arrow(screen_point_v1, screen_point_v2, rgba, a_size, a_type, b_type) if ms.gltype == 12 or ms.gltype == 13 or ms.gltype == 14: # Segment to origin - draw_line(screen_point_ap1, screen_point_v11) - draw_line(screen_point_bp1, screen_point_v22) - draw_arrow(screen_point_v1, screen_point_v2, a_size, a_type, b_type) + draw_line(screen_point_ap1, screen_point_v11, rgba) + draw_line(screen_point_bp1, screen_point_v22, rgba) + draw_arrow(screen_point_v1, screen_point_v2, rgba, a_size, a_type, b_type) if ms.gltype == 2: # Label - draw_line(screen_point_v11a, screen_point_v11b) - draw_arrow(screen_point_ap1, screen_point_v11, a_size, a_type, b_type) + draw_line(screen_point_v11a, screen_point_v11b, rgba) + draw_arrow(screen_point_ap1, screen_point_v11, rgba, a_size, a_type, b_type) if ms.gltype == 3 or ms.gltype == 4 or ms.gltype == 5 or ms.gltype == 8 \ or ms.gltype == 6 or ms.gltype == 7: # Origin and Links - draw_arrow(screen_point_ap1, screen_point_bp1, a_size, a_type, b_type) + draw_arrow(screen_point_ap1, screen_point_bp1, rgba, a_size, a_type, b_type) if ms.gltype == 9: # Angle dist, distloc = distance(an_p1, an_p2) @@ -512,16 +514,16 @@ def draw_segments(context, myobj, op, region, rv3d): screen_point_an_p2 = get_2d_point(region, rv3d, an_p2) screen_point_an_p3 = get_2d_point(region, rv3d, mp2) - draw_line(screen_point_an_p1, screen_point_an_p2) - draw_line(screen_point_an_p2, screen_point_an_p3) - draw_line(screen_point_an_p1, screen_point_an_p3) + draw_line(screen_point_an_p1, screen_point_an_p2, rgba) + draw_line(screen_point_an_p2, screen_point_an_p3, rgba) + draw_line(screen_point_an_p1, screen_point_an_p3, rgba) if ms.gltype == 11: # arc # draw line from center of arc second point c = Vector(a_p1) if ms.glarc_rad is True: if ms.glarc_extrad is False: - draw_arrow(screen_point_ap1, screen_point_bp1, a_size, a_type, b_type) + draw_arrow(screen_point_ap1, screen_point_bp1, rgba, a_size, a_type, b_type) else: vne = Vector((b_p1[0] - a_p1[0], b_p1[1] - a_p1[1], @@ -530,7 +532,7 @@ def draw_segments(context, myobj, op, region, rv3d): vie = vne * ms.glspace pe = (b_p1[0] + vie[0], b_p1[1] + vie[1], b_p1[2] + vie[2]) screen_point_pe = get_2d_point(region, rv3d, pe) - draw_arrow(screen_point_ap1, screen_point_pe, a_size, a_type, b_type) + draw_arrow(screen_point_ap1, screen_point_pe, rgba, a_size, a_type, b_type) # create arc around the centerpoint # rotation matrix around normal vector at center point @@ -558,7 +560,7 @@ def draw_segments(context, myobj, op, region, rv3d): p_02b = None # draw the arc for i in range(int(n_step)): - p2 = mat_trans2 * mat_rot1 * mat_trans1 * p1 + p2 = mat_trans2 @ mat_rot1 @ mat_trans1 @ p1 p1_ = (p1[0] + vi[0], p1[1] + vi[1], p1[2] + vi[2]) # First Point if i == 0: @@ -577,11 +579,11 @@ def draw_segments(context, myobj, op, region, rv3d): screen_point_p1 = get_2d_point(region, rv3d, p1_) screen_point_p2 = get_2d_point(region, rv3d, p2_) if i == 0: - draw_arrow(screen_point_p1, screen_point_p2, ms.glarc_s, ms.glarc_a, "99") + draw_arrow(screen_point_p1, screen_point_p2, rgba, ms.glarc_s, ms.glarc_a, "99") elif i == int(n_step) - 1: - draw_arrow(screen_point_p1, screen_point_p2, ms.glarc_s, "99", ms.glarc_b) + draw_arrow(screen_point_p1, screen_point_p2, rgba, ms.glarc_s, "99", ms.glarc_b) else: - draw_line(screen_point_p1, screen_point_p2) + draw_line(screen_point_p1, screen_point_p2, rgba) p1 = p2.copy() @@ -597,8 +599,8 @@ def draw_segments(context, myobj, op, region, rv3d): screen_point_p2a = get_2d_point(region, rv3d, p_02a) screen_point_p2b = get_2d_point(region, rv3d, p_02b) - draw_line(screen_point_p1a, screen_point_p1b) - draw_line(screen_point_p2a, screen_point_p2b) + draw_line(screen_point_p1a, screen_point_p1b, rgba) + draw_line(screen_point_p2a, screen_point_p2b, rgba) if ms.gltype == 20: # Area obverts = get_mesh_vertices(myobj) @@ -608,7 +610,7 @@ def draw_segments(context, myobj, op, region, rv3d): for v in face.measureit_index: myvertices.append(v.glidx) - area = get_area_and_paint(myvertices, myobj, obverts, region, rv3d) + area = get_area_and_paint(myvertices, myobj, obverts, region, rv3d, rgba) tot += area # Draw Area number over first face if len(ms.measureit_faces) > 0: @@ -657,7 +659,7 @@ def draw_segments(context, myobj, op, region, rv3d): # Get polygon area and paint area # # ------------------------------------------ -def get_area_and_paint(myvertices, myobj, obverts, region, rv3d): +def get_area_and_paint(myvertices, myobj, obverts, region, rv3d, rgba): mymesh = myobj.data totarea = 0 if len(myvertices) > 3: @@ -680,9 +682,11 @@ def get_area_and_paint(myvertices, myobj, obverts, region, rv3d): screen_point_p1 = get_2d_point(region, rv3d, p1) screen_point_p2 = get_2d_point(region, rv3d, p2) screen_point_p3 = get_2d_point(region, rv3d, p3) - draw_triangle(screen_point_p1, screen_point_p2, screen_point_p3) + + draw_triangle(screen_point_p1, screen_point_p2, screen_point_p3, rgba) # Area + area = get_triangle_area(p1, p2, p3) totarea += area @@ -695,7 +699,7 @@ def get_area_and_paint(myvertices, myobj, obverts, region, rv3d): screen_point_p1 = get_2d_point(region, rv3d, p1) screen_point_p2 = get_2d_point(region, rv3d, p2) screen_point_p3 = get_2d_point(region, rv3d, p3) - draw_triangle(screen_point_p1, screen_point_p2, screen_point_p3) + draw_triangle(screen_point_p1, screen_point_p2, screen_point_p3, rgba) # Area area = get_triangle_area(p1, p2, p3) @@ -798,7 +802,7 @@ def get_group_sum(myobj, tag): # Create OpenGL text # # ------------------------------------------------------------- -def draw_text(myobj, pos2d, display_text, rgb, fsize, align='L', text_rot=0.0): +def draw_text(myobj, pos2d, display_text, rgba, fsize, align='L', text_rot=0.0): if pos2d is None: return @@ -843,7 +847,7 @@ def draw_text(myobj, pos2d, display_text, rgb, fsize, align='L', text_rot=0.0): new_y = y_pos + (mheight * idx) # Draw blf.position(font_id, newx, new_y, 0) - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) + blf.color(font_id, rgba[0], rgba[1], rgba[2], rgba[3]) blf.draw(font_id, " " + line) # sub line idx -= 1 @@ -861,14 +865,16 @@ def draw_text(myobj, pos2d, display_text, rgb, fsize, align='L', text_rot=0.0): # Draw an OpenGL line # # ------------------------------------------------------------- -def draw_line(v1, v2): +def draw_line(v1, v2, rgba): + coords = [(v1[0], v1[1]), (v2[0], v2[1])] + batch = batch_for_shader(shader, 'LINES', {"pos": coords}) + # noinspection PyBroadException try: if v1 is not None and v2 is not None: - bgl.glBegin(bgl.GL_LINES) - bgl.glVertex2f(*v1) - bgl.glVertex2f(*v2) - bgl.glEnd() + shader.bind() + shader.uniform_float("color", rgba) + batch.draw(shader) except: pass @@ -877,15 +883,16 @@ def draw_line(v1, v2): # Draw an OpenGL triangle # # ------------------------------------------------------------- -def draw_triangle(v1, v2, v3): +def draw_triangle(v1, v2, v3, rgba): + coords = [(v1[0], v1[1]), (v2[0], v2[1]), (v3[0], v3[1])] + batch = batch_for_shader(shader, 'TRIS', {"pos": coords}) + # noinspection PyBroadException try: if v1 is not None and v2 is not None and v3 is not None: - bgl.glBegin(bgl.GL_TRIANGLES) - bgl.glVertex2f(*v1) - bgl.glVertex2f(*v2) - bgl.glVertex2f(*v3) - bgl.glEnd() + shader.bind() + shader.uniform_float("color", rgba) + batch.draw(shader) except: pass @@ -894,7 +901,7 @@ def draw_triangle(v1, v2, v3): # Draw an Arrow # # ------------------------------------------------------------- -def draw_arrow(v1, v2, size=20, a_typ="1", b_typ="1"): +def draw_arrow(v1, v2, rgba, size=20, a_typ="1", b_typ="1"): if v1 is None or v2 is None: return @@ -938,19 +945,19 @@ def draw_arrow(v1, v2, size=20, a_typ="1", b_typ="1"): # Triangle o Lines if a_typ == "1" or a_typ == "3": - draw_line(v1, v1a) - draw_line(v1, v1b) + draw_line(v1, v1a, rgba) + draw_line(v1, v1b, rgba) if b_typ == "1" or b_typ == "3": - draw_line(v2, v2a) - draw_line(v2, v2b) + draw_line(v2, v2a, rgba) + draw_line(v2, v2b, rgba) if a_typ == "2": - draw_triangle(v1, v1a, v1b) + draw_triangle(v1, v1a, v1b, rgba) if b_typ == "2": - draw_triangle(v2, v2a, v2b) + draw_triangle(v2, v2a, v2b, rgba) - draw_line(v1, v2) + draw_line(v1, v2, rgba) # ------------------------------------------------------------- @@ -958,16 +965,16 @@ def draw_arrow(v1, v2, size=20, a_typ="1", b_typ="1"): # # v1, v2 are corners (bottom left / top right) # ------------------------------------------------------------- -def draw_rectangle(v1, v2): +def draw_rectangle(v1, v2, rgba): # noinspection PyBroadException try: if v1 is not None and v2 is not None: v1b = (v2[0], v1[1]) v2b = (v1[0], v2[1]) - draw_line(v1, v1b) - draw_line(v1b, v2) - draw_line(v2, v2b) - draw_line(v2b, v1) + draw_line(v1, v1b, rgba) + draw_line(v1b, v2, rgba) + draw_line(v2, v2b, rgba) + draw_line(v2b, v1, rgba) except: pass @@ -996,7 +1003,7 @@ def format_point(mypoint, pr): # noinspection PyUnresolvedReferences,PyUnboundLocalVariable,PyUnusedLocal def draw_object(context, myobj, region, rv3d): scene = bpy.context.scene - rgb = scene.measureit_debug_obj_color + rgba = scene.measureit_debug_obj_color fsize = scene.measureit_debug_font precision = scene.measureit_debug_precision # -------------------- @@ -1010,8 +1017,6 @@ def draw_object(context, myobj, region, rv3d): if objs[o].select is False: continue a_p1 = Vector(get_location(objs[o])) - # colour - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) # Text txt = '' if scene.measureit_debug_objects is True: @@ -1020,7 +1025,7 @@ def draw_object(context, myobj, region, rv3d): txt += format_point(a_p1, precision) # converting to screen coordinates txtpoint2d = get_2d_point(region, rv3d, a_p1) - draw_text(myobj, txtpoint2d, txt, rgb, fsize) + draw_text(myobj, txtpoint2d, txt, rgba, fsize) return @@ -1035,7 +1040,7 @@ def draw_vertices(context, myobj, region, rv3d): return scene = bpy.context.scene - rgb = scene.measureit_debug_vert_color + rgba = scene.measureit_debug_vert_color fsize = scene.measureit_debug_font precision = scene.measureit_debug_precision # -------------------- @@ -1044,7 +1049,7 @@ def draw_vertices(context, myobj, region, rv3d): if scene.measureit_debug_vert_loc_toggle == '1': co_mult = lambda c: c else: # if global, convert local c to global - co_mult = lambda c: myobj.matrix_world * c + co_mult = lambda c: myobj.matrix_world @ c if myobj.mode == 'EDIT': bm = from_edit_mesh(myobj.data) @@ -1060,8 +1065,6 @@ def draw_vertices(context, myobj, region, rv3d): # noinspection PyBroadException # try: a_p1 = get_point(v.co, myobj) - # colour - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) # converting to screen coordinates txtpoint2d = get_2d_point(region, rv3d, a_p1) # Text @@ -1070,7 +1073,7 @@ def draw_vertices(context, myobj, region, rv3d): txt += str(v.index) if scene.measureit_debug_vert_loc is True: txt += format_point(co_mult(v.co), precision) - draw_text(myobj, txtpoint2d, txt, rgb, fsize) + draw_text(myobj, txtpoint2d, txt, rgba, fsize) # except: # print("Unexpected error:" + str(exc_info())) # pass @@ -1089,7 +1092,7 @@ def draw_edges(context, myobj, region, rv3d): return scene = bpy.context.scene - rgb = scene.measureit_debug_edge_color + rgba = scene.measureit_debug_edge_color fsize = scene.measureit_debug_font precision = scene.measureit_debug_precision # -------------------- @@ -1115,11 +1118,9 @@ def draw_edges(context, myobj, region, rv3d): continue a_mp = midf(e, obverts) a_p1 = get_point(a_mp, myobj) - # colour - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) # converting to screen coordinates txtpoint2d = get_2d_point(region, rv3d, a_p1) - draw_text(myobj, txtpoint2d, str(e.index), rgb, fsize) + draw_text(myobj, txtpoint2d, str(e.index), rgba, fsize) return @@ -1134,8 +1135,8 @@ def draw_faces(context, myobj, region, rv3d): return scene = bpy.context.scene - rgb = scene.measureit_debug_face_color - rgb2 = scene.measureit_debug_norm_color + rgba = scene.measureit_debug_face_color + rgba2 = scene.measureit_debug_norm_color fsize = scene.measureit_debug_font ln = scene.measureit_debug_normal_size th = scene.measureit_debug_width @@ -1166,21 +1167,19 @@ def draw_faces(context, myobj, region, rv3d): a_p1 = get_point(f.center, myobj) a_p2 = (a_p1[0] + normal[0] * ln, a_p1[1] + normal[1] * ln, a_p1[2] + normal[2] * ln) - # colour + line setup + # line setup bgl.glEnable(bgl.GL_BLEND) bgl.glLineWidth(th) - bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3]) # converting to screen coordinates txtpoint2d = get_2d_point(region, rv3d, a_p1) point2 = get_2d_point(region, rv3d, a_p2) # Text if scene.measureit_debug_faces is True: - draw_text(myobj, txtpoint2d, str(f.index), rgb, fsize) + draw_text(myobj, txtpoint2d, str(f.index), rgba, fsize) # Draw Normal if scene.measureit_debug_normals is True: bgl.glEnable(bgl.GL_BLEND) - bgl.glColor4f(rgb2[0], rgb2[1], rgb2[2], rgb2[3]) - draw_arrow(txtpoint2d, point2, 10, "99", "1") + draw_arrow(txtpoint2d, point2, rgba, 10, "99", "1") if len(obverts) > 2 and scene.measureit_debug_normal_details is True: if myobj.mode == 'EDIT': @@ -1200,11 +1199,11 @@ def draw_faces(context, myobj, region, rv3d): b2d = get_2d_point(region, rv3d, a_p2) c2d = get_2d_point(region, rv3d, a_p3) # draw vectors - draw_arrow(a2d, b2d, 10, "99", "1") - draw_arrow(b2d, c2d, 10, "99", "1") + draw_arrow(a2d, b2d, rgba, 10, "99", "1") + draw_arrow(b2d, c2d, rgba, 10, "99", "1") # Normal vector data txt = format_point(normal, precision) - draw_text(myobj, point2, txt, rgb2, fsize) + draw_text(myobj, point2, txt, rgba2, fsize) except: print("Unexpected error:" + str(exc_info())) @@ -1271,7 +1270,7 @@ def get_point(v1, mainobject): # Using World Matrix vt = Vector((v1[0], v1[1], v1[2], 1)) m4 = mainobject.matrix_world - vt2 = m4 * vt + vt2 = m4 @ vt v2 = [vt2[0], vt2[1], vt2[2]] return v2 diff --git a/measureit/measureit_main.py b/measureit/measureit_main.py index 91d57ce8..82f269ac 100644 --- a/measureit/measureit_main.py +++ b/measureit/measureit_main.py @@ -46,7 +46,7 @@ from .measureit_render import * # noinspection PyUnusedLocal @persistent def load_handler(dummy): - RunHintDisplayButton.handle_remove(None, bpy.context) + MEASUREIT_OT_RunHintDisplay.handle_remove(None, bpy.context) # ------------------------------------------------------ @@ -88,8 +88,7 @@ bpy.app.handlers.save_pre.append(save_handler) # Define property group class for measureit faces index # ------------------------------------------------------------------ class MeasureitIndex(PropertyGroup): - glidx = IntProperty(name="index", - description="vertex index") + glidx: IntProperty(name="index", description="vertex index") # Register @@ -100,10 +99,9 @@ bpy.utils.register_class(MeasureitIndex) # Define property group class for measureit faces # ------------------------------------------------------------------ class MeasureitFaces(PropertyGroup): - glface = IntProperty(name="glface", - description="Face number") + glface: IntProperty(name="glface", description="Face number") # Array of index - measureit_index = CollectionProperty(type=MeasureitIndex) + measureit_index: CollectionProperty(type=MeasureitIndex) # Register @@ -114,86 +112,86 @@ bpy.utils.register_class(MeasureitFaces) # Define property group class for measureit data # ------------------------------------------------------------------ class MeasureitProperties(PropertyGroup): - gltype = IntProperty(name="gltype", - description="Measure type (1-Segment, 2-Label, etc..)", default=1) - glpointa = IntProperty(name="glpointa", - description="Hidden property for opengl") - glpointb = IntProperty(name="glpointb", - description="Hidden property for opengl") - glpointc = IntProperty(name="glpointc", - description="Hidden property for opengl") - glcolor = FloatVectorProperty(name="glcolor", + gltype: IntProperty(name="gltype", + description="Measure type (1-Segment, 2-Label, etc..)", default=1) + glpointa: IntProperty(name="glpointa", + description="Hidden property for opengl") + glpointb: IntProperty(name="glpointb", + description="Hidden property for opengl") + glpointc: IntProperty(name="glpointc", + description="Hidden property for opengl") + glcolor: FloatVectorProperty(name="glcolor", description="Color for the measure", default=(0.173, 0.545, 1.0, 1.0), min=0.1, max=1, subtype='COLOR', size=4) - glview = BoolProperty(name="glview", + glview: BoolProperty(name="glview", description="Measure visible/hide", default=True) - glspace = FloatProperty(name='glspace', min=-100, max=100, default=0.1, + glspace: FloatProperty(name='glspace', min=-100, max=100, default=0.1, precision=3, description='Distance to display measure') - glwidth = IntProperty(name='glwidth', min=1, max=10, default=1, + glwidth: IntProperty(name='glwidth', min=1, max=10, default=1, description='line width') - glfree = BoolProperty(name="glfree", + glfree: BoolProperty(name="glfree", description="This measure is free and can be deleted", default=False) - gltxt = StringProperty(name="gltxt", maxlen=256, + gltxt: StringProperty(name="gltxt", maxlen=256, description="Short description (use | for line break)") - gladvance = BoolProperty(name="gladvance", + gladvance: BoolProperty(name="gladvance", description="Advanced options as line width or position", default=False) - gldefault = BoolProperty(name="gldefault", + gldefault: BoolProperty(name="gldefault", description="Display measure in position calculated by default", default=True) - glnormalx = FloatProperty(name="glnormalx", + glnormalx: FloatProperty(name="glnormalx", description="Change orientation in X axis", default=1, min=-1, max=1, precision=2) - glnormaly = FloatProperty(name="glnormaly", + glnormaly: FloatProperty(name="glnormaly", description="Change orientation in Y axis", default=0, min=-1, max=1, precision=2) - glnormalz = FloatProperty(name="glnormalz", + glnormalz: FloatProperty(name="glnormalz", description="Change orientation in Z axis", default=0, min=-1, max=1, precision=2) - glfont_size = IntProperty(name="Text Size", + glfont_size: IntProperty(name="Text Size", description="Text size", default=14, min=6, max=150) - glfont_align = EnumProperty(items=(('L', "Left Align", ""), + glfont_align: EnumProperty(items=(('L', "Left Align", ""), ('C', "Center Align", ""), ('R', "Right Align", "")), name="Align Font", description="Set Font Alignment") - glfont_rotat = IntProperty(name='Rotate', min=0, max=360, default=0, + glfont_rotat: IntProperty(name='Rotate', min=0, max=360, default=0, description="Text rotation in degrees") - gllink = StringProperty(name="gllink", + gllink: StringProperty(name="gllink", description="linked object for linked measures") - glocwarning = BoolProperty(name="glocwarning", + glocwarning: BoolProperty(name="glocwarning", description="Display a warning if some axis is not used in distance", default=True) - glocx = BoolProperty(name="glocx", + glocx: BoolProperty(name="glocx", description="Include changes in X axis for calculating the distance", default=True) - glocy = BoolProperty(name="glocy", + glocy: BoolProperty(name="glocy", description="Include changes in Y axis for calculating the distance", default=True) - glocz = BoolProperty(name="glocz", + glocz: BoolProperty(name="glocz", description="Include changes in Z axis for calculating the distance", default=True) - glfontx = IntProperty(name="glfontx", + glfontx: IntProperty(name="glfontx", description="Change font position in X axis", default=0, min=-3000, max=3000) - glfonty = IntProperty(name="glfonty", + glfonty: IntProperty(name="glfonty", description="Change font position in Y axis", default=0, min=-3000, max=3000) - gldist = BoolProperty(name="gldist", + gldist: BoolProperty(name="gldist", description="Display distance for this measure", default=True) - glnames = BoolProperty(name="glnames", + glnames: BoolProperty(name="glnames", description="Display text for this measure", default=True) - gltot = EnumProperty(items=(('99', "-", "Select a group for sum"), + gltot: EnumProperty(items=(('99', "-", "Select a group for sum"), ('0', "A", ""), ('1', "B", ""), ('2', "C", ""), @@ -222,74 +220,74 @@ class MeasureitProperties(PropertyGroup): ('25', "Z", "")), name="Sum in Group", description="Add segment length in selected group") - glorto = EnumProperty(items=(('99', "None", ""), + glorto: EnumProperty(items=(('99', "None", ""), ('0', "A", "Point A must use selected point B location"), ('1', "B", "Point B must use selected point A location")), name="Orthogonal", description="Display point selected as orthogonal (select axis to copy)") - glorto_x = BoolProperty(name="ox", + glorto_x: BoolProperty(name="ox", description="Copy X location", default=False) - glorto_y = BoolProperty(name="oy", + glorto_y: BoolProperty(name="oy", description="Copy Y location", default=False) - glorto_z = BoolProperty(name="oz", + glorto_z: BoolProperty(name="oz", description="Copy Z location", default=False) - glarrow_a = EnumProperty(items=(('99', "--", "No arrow"), + glarrow_a: EnumProperty(items=(('99', "--", "No arrow"), ('1', "Line", "The point of the arrow are lines"), ('2', "Triangle", "The point of the arrow is triangle"), ('3', "TShape", "The point of the arrow is a T")), name="A end", description="Add arrows to point A") - glarrow_b = EnumProperty(items=(('99', "--", "No arrow"), + glarrow_b: EnumProperty(items=(('99', "--", "No arrow"), ('1', "Line", "The point of the arrow are lines"), ('2', "Triangle", "The point of the arrow is triangle"), ('3', "TShape", "The point of the arrow is a T")), name="B end", description="Add arrows to point B") - glarrow_s = IntProperty(name="Size", + glarrow_s: IntProperty(name="Size", description="Arrow size", default=15, min=6, max=500) - glarc_full = BoolProperty(name="arcfull", + glarc_full: BoolProperty(name="arcfull", description="Create full circunference", default=False) - glarc_extrad = BoolProperty(name="arcextrad", + glarc_extrad: BoolProperty(name="arcextrad", description="Adapt radio length to arc line", default=True) - glarc_rad = BoolProperty(name="arc rad", + glarc_rad: BoolProperty(name="arc rad", description="Show arc radius", default=True) - glarc_len = BoolProperty(name="arc len", + glarc_len: BoolProperty(name="arc len", description="Show arc length", default=True) - glarc_ang = BoolProperty(name="arc ang", + glarc_ang: BoolProperty(name="arc ang", description="Show arc angle", default=True) - glarc_a = EnumProperty(items=(('99', "--", "No arrow"), + glarc_a: EnumProperty(items=(('99', "--", "No arrow"), ('1', "Line", "The point of the arrow are lines"), ('2', "Triangle", "The point of the arrow is triangle"), ('3', "TShape", "The point of the arrow is a T")), name="Ar end", description="Add arrows to point A") - glarc_b = EnumProperty(items=(('99', "--", "No arrow"), + glarc_b: EnumProperty(items=(('99', "--", "No arrow"), ('1', "Line", "The point of the arrow are lines"), ('2', "Triangle", "The point of the arrow is triangle"), ('3', "TShape", "The point of the arrow is a T")), name="Br end", description="Add arrows to point B") - glarc_s = IntProperty(name="Size", + glarc_s: IntProperty(name="Size", description="Arrow size", default=15, min=6, max=500) - glarc_txradio = StringProperty(name="txradio", + glarc_txradio: StringProperty(name="txradio", description="Text for radius", default="r=") - glarc_txlen = StringProperty(name="txlen", + glarc_txlen: StringProperty(name="txlen", description="Text for length", default="L=") - glarc_txang = StringProperty(name="txang", + glarc_txang: StringProperty(name="txang", description="Text for angle", default="A=") - glcolorarea = FloatVectorProperty(name="glcolorarea", + glcolorarea: FloatVectorProperty(name="glcolorarea", description="Color for the measure of area", default=(0.1, 0.1, 0.1, 1.0), min=0.1, @@ -298,7 +296,7 @@ class MeasureitProperties(PropertyGroup): size=4) # Array of faces - measureit_faces = CollectionProperty(type=MeasureitFaces) + measureit_faces: CollectionProperty(type=MeasureitFaces) # Register @@ -310,10 +308,10 @@ bpy.utils.register_class(MeasureitProperties) # Measureit # ------------------------------------------------------------------ class MeasureContainer(PropertyGroup): - measureit_num = IntProperty(name='Number of measures', min=0, max=1000, default=0, + measureit_num: IntProperty(name='Number of measures', min=0, max=1000, default=0, description='Number total of measureit elements') # Array of segments - measureit_segments = CollectionProperty(type=MeasureitProperties) + measureit_segments: CollectionProperty(type=MeasureitProperties) bpy.utils.register_class(MeasureContainer) @@ -324,12 +322,13 @@ Object.MeasureGenerator = CollectionProperty(type=MeasureContainer) # Define UI class # Measureit # ------------------------------------------------------------------ -class MeasureitEditPanel(Panel): - bl_idname = "measureit.editpanel" - bl_label = "Measureit" +class MEASUREIT_PT_Edit(Panel): + bl_idname = "MEASUREIT_PT_Edit" + bl_label = "Items" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' - bl_category = 'MeasureIt' + bl_category= 'View' + bl_parent_id = 'measureit_main_panel' # ----------------------------------------------------- # Verify if visible @@ -359,12 +358,12 @@ class MeasureitEditPanel(Panel): if 'MeasureGenerator' in context.object: box = layout.box() row = box.row() - row.label(context.object.name) + row.label(text=context.object.name) row = box.row() row.prop(scene, 'measureit_gl_precision', text="Precision") row.prop(scene, 'measureit_units') row = box.row() - row.prop(scene, 'measureit_gl_show_d', text="Distances", toggle=True, icon="ALIGN") + row.prop(scene, 'measureit_gl_show_d', text="Distances", toggle=True, icon="ALIGN_CENTER") row.prop(scene, 'measureit_gl_show_n', text="Texts", toggle=True, icon="FONT_DATA") row = box.row() row.prop(scene, 'measureit_hide_units', text="Hide measurement unit") @@ -372,7 +371,7 @@ class MeasureitEditPanel(Panel): row = box.row() row.prop(scene, 'measureit_scale', text="Scale") if scene.measureit_scale is True: - split = row.split(percentage=0.25, align=False) + split = row.split(factor=0.25, align=False) split.prop(scene, 'measureit_scale_color', text="") split.prop(scene, 'measureit_scale_factor', text="1") row = box.row() @@ -389,7 +388,7 @@ class MeasureitEditPanel(Panel): row = box.row() row.prop(scene, 'measureit_ovr', text="Override") if scene.measureit_ovr is True: - split = row.split(percentage=0.25, align=False) + split = row.split(factor=0.25, align=False) split.prop(scene, 'measureit_ovr_color', text="") split.prop(scene, 'measureit_ovr_width', text="Width") row = box.row() @@ -405,15 +404,15 @@ class MeasureitEditPanel(Panel): # ----------------- if mp.measureit_num > 0: box = layout.box() - row = box.row(True) - row.operator("measureit.expandallsegmentbutton", text="Expand all", icon="ZOOMIN") - row.operator("measureit.collapseallsegmentbutton", text="Collapse all", icon="ZOOMOUT") + row = box.row(align=True) + row.operator("measureit.expandallsegment", text="Expand all", icon="ZOOM_IN") + row.operator("measureit.collapseallsegment", text="Collapse all", icon="ZOOM_OUT") for idx in range(mp.measureit_num): if mp.measureit_segments[idx].glfree is False: add_item(box, idx, mp.measureit_segments[idx]) row = box.row() - row.operator("measureit.deleteallsegmentbutton", text="Delete all", icon="X") + row.operator("measureit.deleteallsegment", text="Delete all", icon="X") # ----------------- # Sum loop segments # ----------------- @@ -476,25 +475,25 @@ class MeasureitEditPanel(Panel): if ac[idx] is True: final += tot[idx] tx_dist = format_distance(fmt, units, tot[idx]) - row = box.row(True) - row.label("Group " + tx[idx] + ":") - row.label(" ") - row.label(tx_dist) + row = box.row(align=True) + row.label(text="Group " + tx[idx] + ":") + row.label(text=" ") + row.label(text=tx_dist) # Grand total - row = box.row(True) - row.label("") - row.label(" ") - row.label("-" * 20) + row = box.row(align=True) + row.label(text="") + row.label(text=" ") + row.label(text="-" * 20) tx_dist = format_distance(fmt, units, final) - row = box.row(True) - row.label("") - row.label(" ") - row.label(tx_dist) + row = box.row(align=True) + row.label(text="") + row.label(text=" ") + row.label(text=tx_dist) # delete all row = box.row() - row.operator("measureit.deleteallsumbutton", text="Delete all", icon="X") + row.operator("measureit.deleteallsum", text="Delete all", icon="X") # ----------------------------------------------------- @@ -502,32 +501,32 @@ class MeasureitEditPanel(Panel): # ----------------------------------------------------- def add_item(box, idx, segment): scene = bpy.context.scene - row = box.row(True) + row = box.row(align=True) if segment.glview is True: icon = "VISIBLE_IPO_ON" else: icon = "VISIBLE_IPO_OFF" row.prop(segment, 'glview', text="", toggle=True, icon=icon) - row.prop(segment, 'gladvance', text="", toggle=True, icon="SCRIPTWIN") + row.prop(segment, 'gladvance', text="", toggle=True, icon="PREFERENCES") if segment.gltype == 20: # Area special - split = row.split(percentage=0.15, align=True) + split = row.split(factor=0.15, align=True) split.prop(segment, 'glcolorarea', text="") - split = split.split(percentage=0.20, align=True) + split = split.split(factor=0.20, align=True) split.prop(segment, 'glcolor', text="") else: - split = row.split(percentage=0.25, align=True) + split = row.split(factor=0.25, align=True) split.prop(segment, 'glcolor', text="") split.prop(segment, 'gltxt', text="") - op = row.operator("measureit.deletesegmentbutton", text="", icon="X") + op = row.operator("measureit.deletesegment", text="", icon="X") op.tag = idx # saves internal data if segment.gladvance is True: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glfont_size', text="Font") row.prop(segment, 'glfont_align', text="") if segment.glfont_align == 'L': row.prop(segment, 'glfont_rotat', text="Rotate") - row = box.row(True) + row = box.row(align=True) if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20: row.prop(segment, 'glspace', text="Distance") row.prop(segment, 'glfontx', text="X") @@ -535,16 +534,16 @@ def add_item(box, idx, segment): # Arrows if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glarrow_a', text="") row.prop(segment, 'glarrow_b', text="") if segment.glarrow_a != '99' or segment.glarrow_b != '99': row.prop(segment, 'glarrow_s', text="Size") if segment.gltype != 2 and segment.gltype != 10: - row = box.row(True) + row = box.row(align=True) if scene.measureit_gl_show_d is True and segment.gltype != 9: - row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN") + row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN_CENTER") if scene.measureit_gl_show_n is True: row.prop(segment, 'glnames', text="Text", toggle=True, icon="FONT_DATA") # sum distances @@ -552,11 +551,11 @@ def add_item(box, idx, segment): row.prop(segment, 'gltot', text="Sum") if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glwidth', text="Line") row.prop(segment, 'gldefault', text="Automatic position") if segment.gldefault is False: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glnormalx', text="X") row.prop(segment, 'glnormaly', text="Y") row.prop(segment, 'glnormalz', text="Z") @@ -565,7 +564,7 @@ def add_item(box, idx, segment): if segment.gltype != 2 and segment.gltype != 9 and segment.gltype != 10 \ and segment.gltype != 11 and segment.gltype != 12 and segment.gltype != 13 \ and segment.gltype != 14 and segment.gltype != 20: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glocx', text="X", toggle=True) row.prop(segment, 'glocy', text="Y", toggle=True) row.prop(segment, 'glocz', text="Z", toggle=True) @@ -577,28 +576,28 @@ def add_item(box, idx, segment): # ortogonal (only segments) if segment.gltype == 1: if segment.glorto != "99": - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glorto_x', text="X", toggle=True) row.prop(segment, 'glorto_y', text="Y", toggle=True) row.prop(segment, 'glorto_z', text="Z", toggle=True) # Arc special if segment.gltype == 11: - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glarc_rad', text="Radius") row.prop(segment, 'glarc_len', text="Length") row.prop(segment, 'glarc_ang', text="Angle") - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glarc_txradio', text="") row.prop(segment, 'glarc_txlen', text="") row.prop(segment, 'glarc_txang', text="") - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glarc_full', text="Full Circle") if segment.glarc_rad is True: row.prop(segment, 'glarc_extrad', text="Adapt radio") - row = box.row(True) + row = box.row(align=True) row.prop(segment, 'glarc_a', text="") row.prop(segment, 'glarc_b', text="") if segment.glarc_a != '99' or segment.glarc_b != '99': @@ -608,12 +607,12 @@ def add_item(box, idx, segment): # ------------------------------------------------------------------ # Define panel class for main functions. # ------------------------------------------------------------------ -class MeasureitMainPanel(Panel): +class MEASUREIT_PT_Main(Panel): bl_idname = "measureit_main_panel" bl_label = "MeasureIt Tools" bl_space_type = 'VIEW_3D' - bl_region_type = "TOOLS" - bl_category = 'Measureit' + bl_region_type = 'UI' + bl_category= 'View' # ------------------------------ # Draw UI @@ -637,45 +636,45 @@ class MeasureitMainPanel(Panel): icon = "PAUSE" txt = 'Hide' - row.operator("measureit.runopenglbutton", text=txt, icon=icon) + row.operator("measureit.runopengl", text=txt, icon=icon) row.prop(scene, "measureit_gl_ghost", text="", icon='GHOST_ENABLED') # Tools box = layout.box() - box.label("Add Measures") + box.label(text="Add Measures") row = box.row() - row.operator("measureit.addsegmentbutton", text="Segment", icon="ALIGN") + row.operator("measureit.addsegment", text="Segment") row.prop(scene, "measureit_sum", text="Sum") # To origin row = box.row() - op = row.operator("measureit.addsegmentortobutton", text="X", icon="ALIGN") + op = row.operator("measureit.addsegmentorto", text="X") op.tag = 0 # saves internal data - op = row.operator("measureit.addsegmentortobutton", text="Y", icon="ALIGN") + op = row.operator("measureit.addsegmentorto", text="Y") op.tag = 1 # saves internal data - op = row.operator("measureit.addsegmentortobutton", text="Z", icon="ALIGN") + op = row.operator("measureit.addsegmentorto", text="Z") op.tag = 2 # saves internal data row = box.row() - row.operator("measureit.addanglebutton", text="Angle", icon="LINCURVE") - row.operator("measureit.addarcbutton", text="Arc", icon="MAN_ROT") + row.operator("measureit.addangle", text="Angle", icon="LINCURVE") + row.operator("measureit.addarc", text="Arc") row = box.row() - row.operator("measureit.addlabelbutton", text="Label", icon="FONT_DATA") - row.operator("measureit.addnotebutton", text="Annotation", icon="NEW") + row.operator("measureit.addlabel", text="Label", icon="FONT_DATA") + row.operator("measureit.addnote", text="Annotation") row = box.row() - row.operator("measureit.addlinkbutton", text="Link", icon="ROTATECENTER") - row.operator("measureit.addoriginbutton", text="Origin", icon="CURSOR") + row.operator("measureit.addlink", text="Link") + row.operator("measureit.addorigin", text="Origin") row = box.row() - row.operator("measureit.addareabutton", text="Area", icon="MESH_GRID") + row.operator("measureit.addarea", text="Area", icon="MESH_GRID") # ------------------------------ # Debug data # ------------------------------ box = layout.box() - row = box.row(False) + row = box.row(align=False) if scene.measureit_debug is False: row.prop(scene, "measureit_debug", icon="TRIA_RIGHT", text="Mesh Debug", emboss=False) @@ -684,43 +683,43 @@ class MeasureitMainPanel(Panel): text="Mesh Debug", emboss=False) row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.prop(scene, 'measureit_debug_obj_color', text="") split.prop(scene, "measureit_debug_objects", icon="OBJECT_DATA") split.prop(scene, "measureit_debug_object_loc", icon="EMPTY_DATA") row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.prop(scene, 'measureit_debug_vert_color', text="") - split.prop(scene, "measureit_debug_vertices", icon="LOOPSEL") + split.prop(scene, "measureit_debug_vertices", icon="VERTEXSEL") split.prop(scene, "measureit_debug_vert_loc", icon="EMPTY_DATA") if scene.measureit_debug_vert_loc is True: split.prop(scene, 'measureit_debug_vert_loc_toggle', text="") row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.prop(scene, 'measureit_debug_edge_color', text="") - split = split.split(percentage=0.5, align=True) + split = split.split(factor=0.5, align=True) split.prop(scene, "measureit_debug_edges", icon="EDGESEL") row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.prop(scene, 'measureit_debug_face_color', text="") - split = split.split(percentage=0.5, align=True) + split = split.split(factor=0.5, align=True) split.prop(scene, "measureit_debug_faces", icon="FACESEL") row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.prop(scene, 'measureit_debug_norm_color', text="") if scene.measureit_debug_normals is False: - split = split.split(percentage=0.50, align=True) - split.prop(scene, "measureit_debug_normals", icon="MAN_TRANS") + split = split.split(factor=0.50, align=True) + split.prop(scene, "measureit_debug_normals", icon="OBJECT_ORIGIN") else: - split = split.split(percentage=0.5, align=True) - split.prop(scene, "measureit_debug_normals", icon="MAN_TRANS") + split = split.split(factor=0.5, align=True) + split.prop(scene, "measureit_debug_normals", icon="OBJECT_ORIGIN") split.prop(scene, "measureit_debug_normal_size") row = box.row() - split = row.split(percentage=0.10, align=True) + split = row.split(factor=0.10, align=True) split.separator() split.prop(scene, "measureit_debug_normal_details") split.prop(scene, 'measureit_debug_width', text="Thickness") @@ -734,12 +733,13 @@ class MeasureitMainPanel(Panel): # ------------------------------------------------------------------ # Define panel class for conf functions. # ------------------------------------------------------------------ -class MeasureitConfPanel(Panel): +class MEASUREIT_PT_Conf(Panel): bl_idname = "measureit_conf_panel" - bl_label = "MeasureIt Configuration" + bl_label = "Configuration" bl_space_type = 'VIEW_3D' - bl_region_type = "TOOLS" - bl_category = 'Measureit' + bl_region_type = 'UI' + bl_category= 'View' + bl_parent_id = 'measureit_main_panel' bl_options = {'DEFAULT_CLOSED'} # ------------------------------ @@ -752,21 +752,21 @@ class MeasureitConfPanel(Panel): # Configuration data box = layout.box() row = box.row() - split = row.split(percentage=0.2, align=True) - split.label("Text") - split = split.split(percentage=0.2, align=True) + split = row.split(factor=0.2, align=True) + split.label(text="Text") + split = split.split(factor=0.2, align=True) split.prop(scene, "measureit_default_color", text="") split.prop(scene, "measureit_gl_txt", text="") - row = box.row(True) + row = box.row(align=True) row.prop(scene, "measureit_hint_space") row.prop(scene, "measureit_font_align", text="") # Arrow - row = box.row(True) + row = box.row(align=True) row.prop(scene, "measureit_glarrow_a", text="") row.prop(scene, "measureit_glarrow_b", text="") if scene.measureit_glarrow_a != '99' or scene.measureit_glarrow_b != '99': row.prop(scene, "measureit_glarrow_s", text="Size") - row = box.row(True) + row = box.row(align=True) row.prop(scene, "measureit_font_size") if scene.measureit_font_align == 'L': row.prop(scene, "measureit_font_rotation", text="Rotate") @@ -775,12 +775,13 @@ class MeasureitConfPanel(Panel): # ------------------------------------------------------------------ # Define panel class for render functions. # ------------------------------------------------------------------ -class MeasureitRenderPanel(Panel): +class MEASUREIT_PT_Render(Panel): bl_idname = "measureit_render_panel" - bl_label = "MeasureIt Render" + bl_label = "Render" bl_space_type = 'VIEW_3D' - bl_region_type = "TOOLS" - bl_category = 'Measureit' + bl_region_type = 'UI' + bl_category= 'View' + bl_parent_id = 'measureit_main_panel' bl_options = {'DEFAULT_CLOSED'} # ------------------------------ @@ -795,7 +796,7 @@ class MeasureitRenderPanel(Panel): row = box.row() row.prop(scene, "measureit_render_type") row = box.row() - row.operator("measureit.rendersegmentbutton", icon='SCRIPT') + row.operator("measureit.rendersegment", icon='SCRIPT') row = box.row() row.prop(scene, "measureit_render", text="Save render image") row = box.row() @@ -811,11 +812,10 @@ class MeasureitRenderPanel(Panel): # Defines button that adds a measure segment # # ------------------------------------------------------------- -class AddSegmentButton(Operator): - bl_idname = "measureit.addsegmentbutton" +class MEASUREIT_OT_AddSegment(Operator): + bl_idname = "measureit.addsegment" bl_label = "Add" bl_description = "(EDITMODE only) Add a new measure segment between 2 vertices (select 2 vertices or more)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -900,11 +900,10 @@ class AddSegmentButton(Operator): # Defines button that adds an area measure # # ------------------------------------------------------------- -class AddAreaButton(Operator): - bl_idname = "measureit.addareabutton" +class MEASUREIT_OT_AddArea(Operator): + bl_idname = "measureit.addarea" bl_label = "Area" bl_description = "(EDITMODE only) Add a new measure for area (select 1 o more faces)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -988,13 +987,12 @@ class AddAreaButton(Operator): # Defines button that adds a measure segment to x/y/z origin # # ------------------------------------------------------------- -class AddSegmentOrtoButton(Operator): - bl_idname = "measureit.addsegmentortobutton" +class MEASUREIT_OT_AddSegmentOrto(Operator): + bl_idname = "measureit.addsegmentorto" bl_label = "Add" bl_description = "(EDITMODE only) Add a new measure segment from vertex to object origin for one " \ "axis (select 1 vertex)" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Poll @@ -1079,11 +1077,10 @@ class AddSegmentOrtoButton(Operator): # Defines button that adds an angle measure # # ------------------------------------------------------------- -class AddAngleButton(Operator): - bl_idname = "measureit.addanglebutton" +class MEASUREIT_OT_AddAngle(Operator): + bl_idname = "measureit.addangle" bl_label = "Angle" bl_description = "(EDITMODE only) Add a new angle measure (select 3 vertices, 2nd is angle vertex)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -1160,12 +1157,11 @@ class AddAngleButton(Operator): # Defines button that adds an arc measure # # ------------------------------------------------------------- -class AddArcButton(Operator): - bl_idname = "measureit.addarcbutton" +class MEASUREIT_OT_AddArc(Operator): + bl_idname = "measureit.addarc" bl_label = "Angle" bl_description = "(EDITMODE only) Add a new arc measure (select 3 vertices of the arc," \ " vertices 1st and 3rd are arc extremes)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -1245,11 +1241,10 @@ class AddArcButton(Operator): # Defines button that adds a label segment # # ------------------------------------------------------------- -class AddLabelButton(Operator): - bl_idname = "measureit.addlabelbutton" +class MEASUREIT_OT_AddLabel(Operator): + bl_idname = "measureit.addlabel" bl_label = "Add" bl_description = "(EDITMODE only) Add a new measure label (select 1 vertex)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -1328,12 +1323,11 @@ class AddLabelButton(Operator): # Defines button that adds a link # # ------------------------------------------------------------- -class AddLinkButton(Operator): - bl_idname = "measureit.addlinkbutton" +class MEASUREIT_OT_AddLink(Operator): + bl_idname = "measureit.addlink" bl_label = "Add" bl_description = "(OBJECT mode only) Add a new measure between objects (select 2 " \ "objects and optionally 1 or 2 vertices)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -1475,11 +1469,10 @@ class AddLinkButton(Operator): # Defines button that adds an origin segment # # ------------------------------------------------------------- -class AddOriginButton(Operator): - bl_idname = "measureit.addoriginbutton" +class MEASUREIT_OT_AddOrigin(Operator): + bl_idname = "measureit.addorigin" bl_label = "Add" bl_description = "(OBJECT mode only) Add a new measure to origin (select object and optionally 1 vertex)" - bl_category = 'Measureit' # ------------------------------ # Poll @@ -1574,12 +1567,11 @@ class AddOriginButton(Operator): # Defines button that deletes a measure segment # # ------------------------------------------------------------- -class DeleteSegmentButton(Operator): - bl_idname = "measureit.deletesegmentbutton" +class MEASUREIT_OT_DeleteSegment(Operator): + bl_idname = "measureit.deletesegment" bl_label = "Delete" bl_description = "Delete a measure" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1608,12 +1600,11 @@ class DeleteSegmentButton(Operator): # Defines button that deletes all measure segments # # ------------------------------------------------------------- -class DeleteAllSegmentButton(Operator): - bl_idname = "measureit.deleteallsegmentbutton" +class MEASUREIT_OT_DeleteAllSegment(Operator): + bl_idname = "measureit.deleteallsegment" bl_label = "Delete" bl_description = "Delete all measures (it cannot be undone)" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1643,12 +1634,11 @@ class DeleteAllSegmentButton(Operator): # Defines button that deletes all measure segment sums # # ------------------------------------------------------------- -class DeleteAllSumButton(Operator): - bl_idname = "measureit.deleteallsumbutton" +class MEASUREIT_OT_DeleteAllSum(Operator): + bl_idname = "measureit.deleteallsum" bl_label = "Delete" bl_description = "Delete all sum groups" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1669,12 +1659,11 @@ class DeleteAllSumButton(Operator): # Defines button that expands all measure segments # # ------------------------------------------------------------- -class ExpandAllSegmentButton(Operator): - bl_idname = "measureit.expandallsegmentbutton" +class MEASUREIT_OT_ExpandAllSegment(Operator): + bl_idname = "measureit.expandallsegment" bl_label = "Expand" bl_description = "Expand all measure properties" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1700,12 +1689,11 @@ class ExpandAllSegmentButton(Operator): # Defines button that collapses all measure segments # # ------------------------------------------------------------- -class CollapseAllSegmentButton(Operator): - bl_idname = "measureit.collapseallsegmentbutton" +class MEASUREIT_OT_CollapseAllSegment(Operator): + bl_idname = "measureit.collapseallsegment" bl_label = "Collapse" bl_description = "Collapses all measure properties" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1731,12 +1719,11 @@ class CollapseAllSegmentButton(Operator): # Defines button for render option # # ------------------------------------------------------------- -class RenderSegmentButton(Operator): - bl_idname = "measureit.rendersegmentbutton" +class MEASUREIT_OT_RenderSegment(Operator): + bl_idname = "measureit.rendersegment" bl_label = "Render" bl_description = "Create a render image with measures. Use UV/Image editor to view image generated" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Execute button action @@ -1866,12 +1853,11 @@ class RenderSegmentButton(Operator): # Defines a new note # # ------------------------------------------------------------- -class AddNoteButton(Operator): - bl_idname = "measureit.addnotebutton" +class MEASUREIT_OT_AddNote(Operator): + bl_idname = "measureit.addnote" bl_label = "Note" bl_description = "(OBJECT mode only) Add a new annotation" - bl_category = 'Measureit' - tag = IntProperty() + tag: IntProperty() # ------------------------------ # Poll @@ -1936,11 +1922,10 @@ class AddNoteButton(Operator): # Defines button that enables/disables the tip display # # ------------------------------------------------------------- -class RunHintDisplayButton(Operator): - bl_idname = "measureit.runopenglbutton" +class MEASUREIT_OT_RunHintDisplay(Operator): + bl_idname = "measureit.runopengl" bl_label = "Display hint data manager" bl_description = "Main control for enabling or disabling the display of measurements in the viewport" - bl_category = 'Measureit' _handle = None # keep function handler @@ -1949,8 +1934,8 @@ class RunHintDisplayButton(Operator): # ---------------------------------- @staticmethod def handle_add(self, context): - if RunHintDisplayButton._handle is None: - RunHintDisplayButton._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context), + if MEASUREIT_OT_RunHintDisplay._handle is None: + MEASUREIT_OT_RunHintDisplay._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context), 'WINDOW', 'POST_PIXEL') context.window_manager.measureit_run_opengl = True @@ -1961,9 +1946,9 @@ class RunHintDisplayButton(Operator): # noinspection PyUnusedLocal @staticmethod def handle_remove(self, context): - if RunHintDisplayButton._handle is not None: - SpaceView3D.draw_handler_remove(RunHintDisplayButton._handle, 'WINDOW') - RunHintDisplayButton._handle = None + if MEASUREIT_OT_RunHintDisplay._handle is not None: + SpaceView3D.draw_handler_remove(MEASUREIT_OT_RunHintDisplay._handle, 'WINDOW') + MEASUREIT_OT_RunHintDisplay._handle = None context.window_manager.measureit_run_opengl = False # ------------------------------ @@ -2011,22 +1996,9 @@ def draw_main(context): rv3d = context.space_data.region_quadviews[i] scene = bpy.context.scene - local_view = context.area.spaces.active.local_view is not None - layers = [] - if local_view is False: - # Get visible layers - if bpy.context.space_data.lock_camera_and_layers is True: - for x in range(20): - if bpy.context.scene.layers[x] is True: - layers.append(x) - else: - # Lock disabled, use view dependent visible layers - for x in range(20): - if bpy.context.space_data.layers[x] is True: - layers.append(x) # Display selected or all - if scene.measureit_gl_ghost is False or local_view is True: + if scene.measureit_gl_ghost is False: objlist = context.selected_objects else: objlist = context.scene.objects @@ -2037,20 +2009,11 @@ def draw_main(context): # Generate all OpenGL calls for measures # --------------------------------------- for myobj in objlist: - if myobj.hide is False: + if myobj.visible_get() is True: if 'MeasureGenerator' in myobj: - if local_view is False: - # verify visible layer - for x in range(20): - if myobj.layers[x] is True and x in layers: - op = myobj.MeasureGenerator[0] - draw_segments(context, myobj, op, region, rv3d) - break - else: - # Layer check not needed here, selected objects are not - # added to context.selected_objects if in disabled layers - op = myobj.MeasureGenerator[0] - draw_segments(context, myobj, op, region, rv3d) + op = myobj.MeasureGenerator[0] + draw_segments(context, myobj, op, region, rv3d) + # --------------------------------------- # Generate all OpenGL calls for debug # --------------------------------------- @@ -2075,7 +2038,6 @@ def draw_main(context): # ----------------------- bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) - bgl.glColor4f(0.0, 0.0, 0.0, 1.0) # ------------------------------------------------------------- @@ -2118,7 +2080,7 @@ def get_selected_vertex(myobject): # meshes # -------------------- oldobj = bpy.context.object - bpy.context.scene.objects.active = myobject + bpy.context.view_layer.objects.active = myobject flag = False if myobject.mode != 'EDIT': bpy.ops.object.mode_set(mode='EDIT') @@ -2133,7 +2095,7 @@ def get_selected_vertex(myobject): if flag is True: bpy.ops.object.editmode_toggle() # Back context object - bpy.context.scene.objects.active = oldobj + bpy.context.view_layer.objects.active = oldobj # if select all vertices, then use origin if tv == len(mylist): @@ -2154,7 +2116,7 @@ def get_selected_vertex_history(myobject): # meshes # -------------------- oldobj = bpy.context.object - bpy.context.scene.objects.active = myobject + bpy.context.view_layer.objects.active = myobject flag = False if myobject.mode != 'EDIT': bpy.ops.object.mode_set(mode='EDIT') @@ -2167,7 +2129,7 @@ def get_selected_vertex_history(myobject): if flag is True: bpy.ops.object.editmode_toggle() # Back context object - bpy.context.scene.objects.active = oldobj + bpy.context.view_layer.objects.active = oldobj return mylist @@ -2184,7 +2146,7 @@ def get_smart_selected(myobject): # meshes # -------------------- oldobj = bpy.context.object - bpy.context.scene.objects.active = myobject + bpy.context.view_layer.objects.active = myobject flag = False if myobject.mode != 'EDIT': bpy.ops.object.mode_set(mode='EDIT') @@ -2199,7 +2161,7 @@ def get_smart_selected(myobject): if flag is True: bpy.ops.object.editmode_toggle() # Back context object - bpy.context.scene.objects.active = oldobj + bpy.context.view_layer.objects.active = oldobj return mylist @@ -2216,7 +2178,7 @@ def get_selected_faces(myobject): # meshes # -------------------- oldobj = bpy.context.object - bpy.context.scene.objects.active = myobject + bpy.context.view_layer.objects.active = myobject flag = False if myobject.mode != 'EDIT': bpy.ops.object.mode_set(mode='EDIT') @@ -2234,6 +2196,6 @@ def get_selected_faces(myobject): if flag is True: bpy.ops.object.editmode_toggle() # Back context object - bpy.context.scene.objects.active = oldobj + bpy.context.view_layer.objects.active = oldobj return mylist diff --git a/measureit/measureit_render.py b/measureit/measureit_render.py index d5eb6430..491c0071 100644 --- a/measureit/measureit_render.py +++ b/measureit/measureit_render.py @@ -53,13 +53,7 @@ def render_main(self, context, animation=False): settings.color_depth = '8' # noinspection PyBroadException try: - # Get visible layers - layers = [] scene = context.scene - for x in range(20): - if scene.layers[x] is True: - layers.append(x) - # Get object list objlist = context.scene.objects # -------------------- @@ -102,13 +96,12 @@ def render_main(self, context, animation=False): # pixels out of visible area cut4 = (col_num * tile_x * 4) - width * 4 # pixels aout of drawing area totpixel4 = width * height * 4 # total pixels RGBA - viewport_info = bgl.Buffer(bgl.GL_INT, 4) bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport_info) # Load image on memory - img.gl_load(0, bgl.GL_NEAREST, bgl.GL_NEAREST) - tex = img.bindcode[0] + img.gl_load(frame=0, filter=bgl.GL_NEAREST, mag=bgl.GL_NEAREST) + tex = img.bindcode # -------------------------------------------- # Create output image (to apply texture) @@ -131,7 +124,7 @@ def render_main(self, context, animation=False): bgl.glViewport(0, 0, tile_x, tile_y) bgl.glMatrixMode(bgl.GL_PROJECTION) - bgl.glLoadIdentity() + gpu.matrix.load_identity() # defines ortographic view for single tile x1 = tile_x * col @@ -167,15 +160,10 @@ def render_main(self, context, animation=False): # Loop to draw all lines # ----------------------------- for myobj in objlist: - if myobj.hide is False: + if myobj.visible_get() is True: if 'MeasureGenerator' in myobj: - # verify visible layer - for x in range(20): - if myobj.layers[x] is True: - if x in layers: - op = myobj.MeasureGenerator[0] - draw_segments(context, myobj, op, None, None) - break + op = myobj.MeasureGenerator[0] + draw_segments(context, myobj, op, None, None) # ----------------------------- # Loop to draw all debug @@ -197,19 +185,16 @@ def render_main(self, context, animation=False): draw_faces(context, myobj, None, None) if scene.measureit_rf is True: - bgl.glColor3f(1.0, 1.0, 1.0) rfcolor = scene.measureit_rf_color rfborder = scene.measureit_rf_border rfline = scene.measureit_rf_line bgl.glLineWidth(rfline) - bgl.glColor4f(rfcolor[0], rfcolor[1], rfcolor[2], rfcolor[3]) - x1 = rfborder x2 = width - rfborder y1 = int(ceil(rfborder / (width / height))) y2 = height - y1 - draw_rectangle((x1, y1), (x2, y2)) + draw_rectangle((x1, y1), (x2, y2), rfcolor) # -------------------------------- # copy pixels to temporary area @@ -248,7 +233,6 @@ def render_main(self, context, animation=False): # ----------------------- bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) - bgl.glColor4f(0.0, 0.0, 0.0, 1.0) # Saves image if out is not None and (scene.measureit_render is True or animation is True): ren_path = bpy.context.scene.render.filepath -- cgit v1.2.3