Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

1,2,3 #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
rovh merged 36 commits into master from 1,2,3
Jul 13, 2020
Merged

1,2,3 #17

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f5291ad
Code
rovh Jul 5, 2020
fcaf481
Code
rovh Jul 5, 2020
4739137
Code
rovh Jul 5, 2020
867af41
Code
rovh Jul 5, 2020
b3caca0
Code
rovh Jul 5, 2020
74456ac
Code
rovh Jul 6, 2020
dc827b7
Code
rovh Jul 6, 2020
db720b1
Code
rovh Jul 6, 2020
b84c2b6
Code
rovh Jul 6, 2020
14cc7f7
Code
rovh Jul 7, 2020
3582a6f
Code
rovh Jul 7, 2020
6f2eeb3
Code
rovh Jul 7, 2020
25fc43f
Code
rovh Jul 7, 2020
60d26e7
Code
rovh Jul 7, 2020
2aa0418
Code
rovh Jul 7, 2020
ea29c58
Code
rovh Jul 7, 2020
069e456
Code
rovh Jul 7, 2020
817c9ae
Code
rovh Jul 7, 2020
6d0fb4b
Code
rovh Jul 8, 2020
f486d39
Code
rovh Jul 8, 2020
0ba0e8d
Code
rovh Jul 8, 2020
78d5832
Code
rovh Jul 8, 2020
72c6d5f
Code
rovh Jul 9, 2020
4d705df
Code
rovh Jul 9, 2020
55ac68f
Code
rovh Jul 9, 2020
7a07355
Code
rovh Jul 9, 2020
9bc4809
Code
rovh Jul 9, 2020
d7b6c9d
Code
rovh Jul 9, 2020
31e93c4
Code
rovh Jul 10, 2020
ed89934
Code
rovh Jul 11, 2020
0787cf5
Code
rovh Jul 11, 2020
aeb5608
Code
rovh Jul 12, 2020
158e765
Code
rovh Jul 12, 2020
bfb00db
Code
rovh Jul 13, 2020
09f86c0
Code
rovh Jul 13, 2020
8b9c6f0
Code
rovh Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions Draw.py
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import bpy
import bgl
import blf
import gpu
from gpu_extras.batch import batch_for_shader

from . import __name__

# class Pop_Up_Set_Cursor_To_Normal (bpy.types.Operator):
# """Tooltip"""
# bl_idname = "mesh.set_cursor_to_normal_pop_up"
# bl_label = "Set the Cursor to the normal"
# bl_description = "Set the cursor location to the selected vertex/edge/face and set the cursor direction along its normal\
# \nYou can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut"
# # bl_options = {'REGISTER', 'UNDO'}
# bl_options = {'UNDO'}

# def execute(self, context):
# return {'FINISHED'}

# # def invoke(self, context, event):
# # return context.window_manager.invoke_popup(self, width = 200)


# def draw(self, context):

# layout=self.layout

# col = layout.column(align = 1)
# col.scale_y = 1.2


# if len(selected_verts) == 0 and len(selected_edges) == 0 and len(selected_faces) == 0:
# col.label(icon = "ERROR")
# col.label(text = "You need to select one element (vertex/edge/face)")
# if len(selected_verts) > 1:
# col.operator("mesh.set_cursor", text="Vertices", icon = "VERTEXSEL").get_from_verts = True
# if len(selected_edges) != 0:
# col.operator("mesh.set_cursor", text="Edges", icon = "EDGESEL").get_from_edges = True
# if len(selected_faces) != 0:
# col.operator("mesh.set_cursor", text="Faces", icon = "FACESEL").get_from_faces = True


def draw():
v1 = bpy.context.window_manager.setprecisemesh.length_display_coordinate_1
v2 = bpy.context.window_manager.setprecisemesh.length_display_coordinate_2
length_display_stop = bpy.context.window_manager.setprecisemesh.length_display_sto p

if length_display_stop == False and bpy.context.active_object is not None:
if bpy.context.active_object.mode in {'EDIT'}:

coords = [ (v1[0], v1[1], v1[2]), (v2[0], v2[1], v2[2])]
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'LINES', {"pos": coords})

shader.bind()
shader.uniform_float("color", (1, 1, 0, 0))
batch.draw(shader)
else:
pass
else:
pass

def draw_callback_px(self, context):

length_display_number = bpy.context.window_manager.setprecisemesh.length_display_number
length_display_stop = bpy.context.window_manager.setprecisemesh.length_display_sto p

font_id = 0 # XXX, need to find out how best to get this.

blf.position(font_id, 75, 30, 0)
blf.size(font_id, 20, 72)

if context.active_object is not None:
if context.active_object.mode in {'EDIT'}:
if length_display_stop == False:

length_unit = bpy.context.scene.unit_settings.length_unit

if bpy.context.scene.unit_settings.system == 'METRIC' and length_unit == 'ADAPTIVE':
unit_index = ""

elif length_unit == "MICROMETERS":
unit_index = "um"
length_display_number = length_display_number * 1000000

elif length_unit == "MILLIMETERS":
unit_index = "mm"
length_display_number = length_display_number * 1000

elif length_unit == "CENTIMETERS":
unit_index = "cm"
length_display_number = length_display_number * 100

elif length_unit == "METERS":
unit_index = "m"

elif length_unit == "KILOMETERS":
unit_index = "km"
length_display_number = length_display_number / 1000


if bpy.context.scene.unit_settings.system == 'IMPERIAL'and length_unit == 'ADAPTIVE':
unit_index = ""
length_display_number = length_display_number * 3.2808398950131

elif length_unit == 'MILES':
unit_index = "mi"
length_display_number = length_display_number * 0.00062137119223733

elif length_unit == 'FEET':
unit_index = "'"
length_display_number = length_display_number * 3.2808398950131

elif length_unit == 'INCHES':
unit_index = "''"
length_display_number = length_display_number * 39.370078740157

elif length_unit == 'THOU':
unit_index = "thou"
length_display_number = length_display_number * 39.370078740157 * 1000

length_display_number = self.scale_length * length_display_number
length_display_number = round(length_display_number, self.round_precision)
length_display_number = str(length_display_number)

blf.draw(font_id, "Length: " + length_display_number + " " + unit_index)
else:
blf.draw(font_id, "Length: " + "No")
else:
pass

class ModalDrawOperator_Set_Precise_Mesh_Length(bpy.types.Operator):
"""Draw a line with the mouse"""
bl_idname = "view3d.modal_operator_setprecisemesh_draw_length"
bl_label = "Display Length"
bl_description = "Display Length between two selected elements in left buttom corner"

def modal(self, context, event):

length_display_stop = bpy.context.window_manager.setprecisemesh.length_display_sto p
draw_length_line = bpy.context.window_manager.setprecisemesh.draw_length_line

if draw_length_line == False:
bpy.types.SpaceView3D.draw_handler_remove(self._handle_2, 'WINDOW')
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
try:
context.area.tag_redraw()
except AttributeError:
pass
return {'FINISHED'}

else:
try:
context.area.tag_redraw()
except AttributeError:
pass

if event.type == 'MOUSEMOVE' or event.value == 'RELEASE' or event.value == 'PRESS':
try:
length_display_stop = False
bpy.ops.mesh.change_length(draw = 1)
except RuntimeError:
length_display_stop = True
pass
except ReferenceError:
length_display_stop = True
pass

# elif event.type in {'ESC', 'SPACE'}:
# bpy.types.SpaceView3D.draw_handler_remove(self._handle_2, 'WINDOW')
# bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
# return {'FINISHED'}

return {'PASS_THROUGH'}

def invoke(self, context, event):
draw_length_line = bpy.context.window_manager.setprecisemesh.draw_length_line
settings = bpy.context.preferences.addons[__name__].preferences
self.scale_length = bpy.context.scene.unit_settings.scale_length
self.round_precision = settings.round_precision

if draw_length_line == True:
bpy.context.window_manager.setprecisemesh.draw_length_line = False
return {'RUNNING_MODAL'}
else:
bpy.context.window_manager.setprecisemesh.draw_length_line = True

if context.area.type == 'VIEW_3D':
args = (self, context)
self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
self._handle_2 = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}

if __name__ == "__main__":
register()
14 changes: 13 additions & 1 deletion Presets.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,12 @@ class PRESETS_PT_presets_List_Angle(Panel):
bl_context = "scene"
# bl_context = "mesh_edit"

@classmethod
def poll(cls, context):
return bpy.context.active_object != None\
and bpy.context.active_object.mode in {'EDIT'}


def draw_header(self, context):
layout = self.layout
layout.label(icon = "DRIVER_ROTATIONAL_DIFFERENCE")
Expand Down Expand Up @@ -932,6 +938,11 @@ class PRESETS_PT_presets_List_Length(Panel):
bl_context = "scene"
# bl_context = "mesh_edit"

@classmethod
def poll(cls, context):
return bpy.context.active_object != None\
and bpy.context.active_object.mode in {'EDIT'}

def draw_header(self, context):
layout = self.layout
layout.label(icon = "DRIVER_DISTANCE")
Expand Down Expand Up @@ -1199,7 +1210,8 @@ class PRESETS_FOR_PRESETS_PT_panel(Panel):

@classmethod
def poll(cls, context):
return True
return bpy.context.active_object != None\
and bpy.context.active_object.mode in {'EDIT'}

def draw_header(self, context):
layout = self.layout
Expand Down
10 changes: 10 additions & 0 deletions Presets_Object.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ class PRESETS_PT_presets_List_Angle_Object(Panel):
bl_context = "object"
# bl_context = "mesh_edit"

@classmethod
def poll(cls, context):
return bpy.context.active_object != None\
and bpy.context.active_object.mode in {'EDIT'}

def draw_header(self, context):
layout = self.layout
layout.label(icon = "DRIVER_ROTATIONAL_DIFFERENCE")
Expand Down Expand Up @@ -744,6 +749,11 @@ class PRESETS_PT_presets_List_Length_Object(Panel):
bl_region_type = 'WINDOW'
bl_context = "object"

@classmethod
def poll(cls, context):
return bpy.context.active_object != None\
and bpy.context.active_object.mode in {'EDIT'}

def draw_header(self, context):
layout = self.layout
layout.label(icon = "DRIVER_DISTANCE")
Expand Down
7 changes: 5 additions & 2 deletions SetAngle.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mathutils
from mathutils import geometry
from mathutils import Vector, Matrix, Quaternion, Euler
from . import name


# from pynput.keyboard import Key, Controller
Expand All @@ -26,7 +27,7 @@ def check(self):
class SetAngle(bpy.types.Operator):
"""Tooltip"""
bl_idname = "mesh.change_angle"
bl_label = ""
bl_label = "Set Angle " + name
bl_description = "Set Angle \n You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut"
bl_options = {'UNDO'}

Expand All @@ -35,7 +36,9 @@ class SetAngle(bpy.types.Operator):

@classmethod
def poll(cls, context):
return context.active_object is not None
return context.active_object is not None\
and context.active_object.mode in {'EDIT'}\
and context.active_object.type == "MESH"

@classmethod
def description(cls, context, properties):
Expand Down
Loading