-
Notifications
You must be signed in to change notification settings - Fork 2
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
1,2,3 #17
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f5291ad
Code
rovh fcaf481
Code
rovh 4739137
Code
rovh 867af41
Code
rovh b3caca0
Code
rovh 74456ac
Code
rovh dc827b7
Code
rovh db720b1
Code
rovh b84c2b6
Code
rovh 14cc7f7
Code
rovh 3582a6f
Code
rovh 6f2eeb3
Code
rovh 25fc43f
Code
rovh 60d26e7
Code
rovh 2aa0418
Code
rovh ea29c58
Code
rovh 069e456
Code
rovh 817c9ae
Code
rovh 6d0fb4b
Code
rovh f486d39
Code
rovh 0ba0e8d
Code
rovh 78d5832
Code
rovh 72c6d5f
Code
rovh 4d705df
Code
rovh 55ac68f
Code
rovh 7a07355
Code
rovh 9bc4809
Code
rovh d7b6c9d
Code
rovh 31e93c4
Code
rovh ed89934
Code
rovh 0787cf5
Code
rovh aeb5608
Code
rovh 158e765
Code
rovh bfb00db
Code
rovh 09f86c0
Code
rovh 8b9c6f0
Code
rovh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
200 changes: 200 additions & 0 deletions
Draw.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
|
@@ -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") | ||
|
|
@@ -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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
|
@@ -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") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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'} | ||
|
|
||
|
|
@@ -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): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.