diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-25 04:33:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-25 04:33:59 +0300 |
commit | 425a3f6a705beab849cab36d2ca2ae43726d700f (patch) | |
tree | 00802f0b1efac9d9fc8b7b4062ab5349ca90722d | |
parent | 3c6e9c26bc6b35399dfbc38c3116b1375fa6f53c (diff) |
Cleanup: strip trailing space
29 files changed, 285 insertions, 287 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index d3cd5a72..4a4ae4ba 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -91,13 +91,13 @@ else: from blenderkit import upload from blenderkit import utils - from blenderkit.bl_ui_widgets import bl_ui_label - from blenderkit.bl_ui_widgets import bl_ui_button + from blenderkit.bl_ui_widgets import bl_ui_label + from blenderkit.bl_ui_widgets import bl_ui_button # from blenderkit.bl_ui_widgets import bl_ui_checkbox # from blenderkit.bl_ui_widgets import bl_ui_slider # from blenderkit.bl_ui_widgets import bl_ui_up_down - from blenderkit.bl_ui_widgets import bl_ui_drag_panel - from blenderkit.bl_ui_widgets import bl_ui_draw_op + from blenderkit.bl_ui_widgets import bl_ui_drag_panel + from blenderkit.bl_ui_widgets import bl_ui_draw_op # from blenderkit.bl_ui_widgets import bl_ui_textbox diff --git a/blenderkit/asset_pack_bg.py b/blenderkit/asset_pack_bg.py index adde9515..c59ca08d 100644 --- a/blenderkit/asset_pack_bg.py +++ b/blenderkit/asset_pack_bg.py @@ -5,4 +5,4 @@ from blenderkit import resolutions BLENDERKIT_EXPORT_DATA = sys.argv[-1] if __name__ == "__main__": - resolutions.run_bg(sys.argv[-1])
\ No newline at end of file + resolutions.run_bg(sys.argv[-1]) diff --git a/blenderkit/bl_ui_widgets/__init__.py b/blenderkit/bl_ui_widgets/__init__.py index 745f59c9..a1db444d 100644 --- a/blenderkit/bl_ui_widgets/__init__.py +++ b/blenderkit/bl_ui_widgets/__init__.py @@ -16,7 +16,7 @@ from bpy.props import * addon_keymaps = [] def register(): - + bpy.utils.register_class(DP_OT_draw_operator) kcfg = bpy.context.window_manager.keyconfigs.addon if kcfg: @@ -29,8 +29,8 @@ def unregister(): for km, kmi in addon_keymaps: km.keymap_items.remove(kmi) addon_keymaps.clear() - + bpy.utils.unregister_class(DP_OT_draw_operator) - + if __name__ == "__main__": register() diff --git a/blenderkit/bl_ui_widgets/bl_ui_button.py b/blenderkit/bl_ui_widgets/bl_ui_button.py index ce26c54e..f3902c4b 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_button.py +++ b/blenderkit/bl_ui_widgets/bl_ui_button.py @@ -4,13 +4,13 @@ import blf import bpy class BL_UI_Button(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x, y, width, height) self._text_color = (1.0, 1.0, 1.0, 1.0) self._hover_bg_color = (0.5, 0.5, 0.5, 1.0) self._select_bg_color = (0.7, 0.7, 0.7, 1.0) - + self._text = "Button" self._text_size = 16 self._textpos = (x, y) @@ -35,7 +35,7 @@ class BL_UI_Button(BL_UI_Widget): @text.setter def text(self, value): self._text = value - + @property def text_size(self): return self._text_size @@ -58,8 +58,8 @@ class BL_UI_Button(BL_UI_Widget): @select_bg_color.setter def select_bg_color(self, value): - self._select_bg_color = value - + self._select_bg_color = value + def set_image_size(self, imgage_size): self.__image_size = imgage_size @@ -68,30 +68,30 @@ class BL_UI_Button(BL_UI_Widget): def set_image(self, rel_filepath): try: - self.__image = bpy.data.images.load(rel_filepath, check_existing=True) + self.__image = bpy.data.images.load(rel_filepath, check_existing=True) self.__image.gl_load() except: pass - def update(self, x, y): + def update(self, x, y): super().update(x, y) self._textpos = [x, y] - + def draw(self): if not self.visible: return - + area_height = self.get_area_height() self.shader.bind() - + self.set_colors() - + bgl.glEnable(bgl.GL_BLEND) - self.batch_panel.draw(self.shader) + self.batch_panel.draw(self.shader) - self.draw_image() + self.draw_image() bgl.glDisable(bgl.GL_BLEND) @@ -128,21 +128,21 @@ class BL_UI_Button(BL_UI_Widget): if self.__image is not None: try: y_screen_flip = self.get_area_height() - self.y_screen - + off_x, off_y = self.__image_position sx, sy = self.__image_size - + # bottom left, top left, top right, bottom right vertices = ( - (self.x_screen + off_x, y_screen_flip - off_y), - (self.x_screen + off_x, y_screen_flip - sy - off_y), + (self.x_screen + off_x, y_screen_flip - off_y), + (self.x_screen + off_x, y_screen_flip - sy - off_y), (self.x_screen + off_x + sx, y_screen_flip - sy - off_y), (self.x_screen + off_x + sx, y_screen_flip - off_y)) - + self.shader_img = gpu.shader.from_builtin('2D_IMAGE') - self.batch_img = batch_for_shader(self.shader_img, 'TRI_FAN', - { "pos" : vertices, - "texCoord": ((0, 1), (0, 0), (1, 0), (1, 1)) + self.batch_img = batch_for_shader(self.shader_img, 'TRI_FAN', + { "pos" : vertices, + "texCoord": ((0, 1), (0, 0), (1, 0), (1, 1)) },) # send image to gpu if it isn't there already @@ -154,39 +154,39 @@ class BL_UI_Button(BL_UI_Widget): self.shader_img.bind() self.shader_img.uniform_int("image", 0) - self.batch_img.draw(self.shader_img) + self.batch_img.draw(self.shader_img) return True except: pass - return False - + return False + def set_mouse_down(self, mouse_down_func): - self.mouse_down_func = mouse_down_func - - def mouse_down(self, x, y): + self.mouse_down_func = mouse_down_func + + def mouse_down(self, x, y): if self.is_in_rect(x,y): self.__state = 1 try: self.mouse_down_func(self) except Exception as e: print(e) - + return True - + return False - + def mouse_move(self, x, y): if self.is_in_rect(x,y): if(self.__state != 1): - + # hover state self.__state = 2 else: self.__state = 0 - + def mouse_up(self, x, y): if self.is_in_rect(x,y): self.__state = 2 else: - self.__state = 0
\ No newline at end of file + self.__state = 0 diff --git a/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py b/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py index e07aa784..44a5b1b9 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py +++ b/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py @@ -1,7 +1,7 @@ -from . bl_ui_widget import * +from . bl_ui_widget import * class BL_UI_Drag_Panel(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x,y, width, height) self.drag_offset_x = 0 @@ -15,35 +15,35 @@ class BL_UI_Drag_Panel(BL_UI_Widget): def add_widget(self, widget): self.widgets.append(widget) - + def add_widgets(self, widgets): self.widgets = widgets self.layout_widgets() - + def layout_widgets(self): for widget in self.widgets: - widget.update(self.x_screen + widget.x, self.y_screen + widget.y) - + widget.update(self.x_screen + widget.x, self.y_screen + widget.y) + def update(self, x, y): super().update(x - self.drag_offset_x, y + self.drag_offset_y) - + def child_widget_focused(self, x, y): for widget in self.widgets: if widget.is_in_rect(x, y): - return True + return True return False - + def mouse_down(self, x, y): if self.child_widget_focused(x, y): return False - + if self.is_in_rect(x,y): height = self.get_area_height() self.is_drag = True self.drag_offset_x = x - self.x_screen self.drag_offset_y = y - (height - self.y_screen) return True - + return False def mouse_move(self, x, y): @@ -55,4 +55,4 @@ class BL_UI_Drag_Panel(BL_UI_Widget): def mouse_up(self, x, y): self.is_drag = False self.drag_offset_x = 0 - self.drag_offset_y = 0
\ No newline at end of file + self.drag_offset_y = 0 diff --git a/blenderkit/bl_ui_widgets/bl_ui_draw_op.py b/blenderkit/bl_ui_widgets/bl_ui_draw_op.py index 2f534479..ab407f47 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_draw_op.py +++ b/blenderkit/bl_ui_widgets/bl_ui_draw_op.py @@ -5,14 +5,14 @@ from bpy.types import Operator class BL_UI_OT_draw_operator(Operator): bl_idname = "object.bl_ui_ot_draw_operator" bl_label = "bl ui widgets operator" - bl_description = "Operator for bl ui widgets" + bl_description = "Operator for bl ui widgets" bl_options = {'REGISTER'} - + def __init__(self): self.draw_handle = None self.draw_event = None self._finished = False - + self.widgets = [] def init_widgets(self, context, widgets): @@ -31,32 +31,32 @@ class BL_UI_OT_draw_operator(Operator): self.on_invoke(context, event) args = (self, context) - + self.register_handlers(args, context) - + context.window_manager.modal_handler_add(self) return {"RUNNING_MODAL"} - + def register_handlers(self, args, context): self.draw_handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_callback_px, args, "WINDOW", "POST_PIXEL") self.draw_event = context.window_manager.event_timer_add(0.1, window=context.window) - + def unregister_handlers(self, context): - + context.window_manager.event_timer_remove(self.draw_event) - + bpy.types.SpaceView3D.draw_handler_remove(self.draw_handle, "WINDOW") - + self.draw_handle = None self.draw_event = None - + def handle_widget_events(self, event): result = False for widget in self.widgets: if widget.handle_event(event): result = True return result - + def modal(self, context, event): if self._finished: @@ -64,20 +64,20 @@ class BL_UI_OT_draw_operator(Operator): if context.area: context.area.tag_redraw() - + if self.handle_widget_events(event): - return {'RUNNING_MODAL'} - + return {'RUNNING_MODAL'} + if event.type in {"ESC"}: self.finish() - + return {"PASS_THROUGH"} - + def finish(self): self.unregister_handlers(bpy.context) self.on_finish(bpy.context) - + # Draw handler to paint onto the screen def draw_callback_px(self, op, context): for widget in self.widgets: - widget.draw()
\ No newline at end of file + widget.draw() diff --git a/blenderkit/bl_ui_widgets/bl_ui_label.py b/blenderkit/bl_ui_widgets/bl_ui_label.py index 11743b41..b008a17b 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_label.py +++ b/blenderkit/bl_ui_widgets/bl_ui_label.py @@ -3,7 +3,7 @@ from . bl_ui_widget import * import blf class BL_UI_Label(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x, y, width, height) @@ -34,24 +34,24 @@ class BL_UI_Label(BL_UI_Widget): @text_size.setter def text_size(self, value): self._text_size = value - + def is_in_rect(self, x, y): return False - + def draw(self): if not self.visible: return - + area_height = self.get_area_height() blf.size(0, self._text_size, 72) size = blf.dimensions(0, self._text) - + textpos_y = area_height - self.y_screen - self.height blf.position(0, self.x_screen, textpos_y, 0) r, g, b, a = self._text_color blf.color(0, r, g, b, a) - - blf.draw(0, self._text)
\ No newline at end of file + + blf.draw(0, self._text) diff --git a/blenderkit/bl_ui_widgets/bl_ui_widget.py b/blenderkit/bl_ui_widgets/bl_ui_widget.py index 2ae529fa..c13bb33d 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_widget.py +++ b/blenderkit/bl_ui_widgets/bl_ui_widget.py @@ -4,7 +4,7 @@ import bgl from gpu_extras.batch import batch_for_shader class BL_UI_Widget: - + def __init__(self, x, y, width, height): self.x = x self.y = y @@ -50,40 +50,40 @@ class BL_UI_Widget: @tag.setter def tag(self, value): self._tag = value - + def draw(self): if not self.visible: return - + self.shader.bind() self.shader.uniform_float("color", self._bg_color) - + bgl.glEnable(bgl.GL_BLEND) - self.batch_panel.draw(self.shader) + self.batch_panel.draw(self.shader) bgl.glDisable(bgl.GL_BLEND) def init(self, context): self.context = context self.update(self.x, self.y) - + def update(self, x, y): - + area_height = self.get_area_height() - + self.x_screen = x self.y_screen = y - + indices = ((0, 1, 2), (0, 2, 3)) y_screen_flip = area_height - self.y_screen # bottom left, top left, top right, bottom right vertices = ( - (self.x_screen, y_screen_flip), - (self.x_screen, y_screen_flip - self.height), + (self.x_screen, y_screen_flip), + (self.x_screen, y_screen_flip - self.height), (self.x_screen + self.width, y_screen_flip - self.height), (self.x_screen + self.width, y_screen_flip)) - + self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') self.batch_panel = batch_for_shader(self.shader, 'TRIS', {"pos" : vertices}, indices=indices) @@ -140,17 +140,17 @@ class BL_UI_Widget: widget_y = area_height - self.y_screen if ( - (self.x_screen <= x <= (self.x_screen + self.width)) and + (self.x_screen <= x <= (self.x_screen + self.width)) and (widget_y >= y >= (widget_y - self.height)) ): return True - - return False - def text_input(self, event): return False - def mouse_down(self, x, y): + def text_input(self, event): + return False + + def mouse_down(self, x, y): return self.is_in_rect(x,y) def mouse_down_right(self, x, y): @@ -160,8 +160,8 @@ class BL_UI_Widget: pass def set_mouse_enter(self, mouse_enter_func): - self.mouse_enter_func = mouse_enter_func - + self.mouse_enter_func = mouse_enter_func + def call_mouse_enter(self): try: if self.mouse_enter_func: @@ -173,8 +173,8 @@ class BL_UI_Widget: self.call_mouse_enter() def set_mouse_exit(self, mouse_exit_func): - self.mouse_exit_func = mouse_exit_func - + self.mouse_exit_func = mouse_exit_func + def call_mouse_exit(self): try: if self.mouse_exit_func: @@ -186,4 +186,4 @@ class BL_UI_Widget: self.call_mouse_exit() def mouse_move(self, x, y): - pass
\ No newline at end of file + pass diff --git a/blenderkit/image_utils.py b/blenderkit/image_utils.py index e0b49b10..96bad204 100644 --- a/blenderkit/image_utils.py +++ b/blenderkit/image_utils.py @@ -87,5 +87,3 @@ def generate_hdr_thumbnail(): inew.scale(thumbnailWidth, thumbnailHeight) img_save_as(inew, filepath=inew.filepath) - - diff --git a/blenderkit/resolutions.py b/blenderkit/resolutions.py index 03026c68..6d66d55b 100644 --- a/blenderkit/resolutions.py +++ b/blenderkit/resolutions.py @@ -209,7 +209,7 @@ def make_possible_reductions_on_image(teximage, input_filepath, do_reductions=Fa - it finds it's usages and replaces the inputs where the image is used with zero/black color. currently implemented file type conversions: - PNG->JPG + PNG->JPG ''' colorspace = teximage.colorspace_settings.name teximage.colorspace_settings.name = 'Non-Color' diff --git a/blenderkit/resolutions_bg.py b/blenderkit/resolutions_bg.py index adde9515..c59ca08d 100644 --- a/blenderkit/resolutions_bg.py +++ b/blenderkit/resolutions_bg.py @@ -5,4 +5,4 @@ from blenderkit import resolutions BLENDERKIT_EXPORT_DATA = sys.argv[-1] if __name__ == "__main__": - resolutions.run_bg(sys.argv[-1])
\ No newline at end of file + resolutions.run_bg(sys.argv[-1]) diff --git a/bone_selection_sets.py b/bone_selection_sets.py index 563a4d9d..7a382d75 100644 --- a/bone_selection_sets.py +++ b/bone_selection_sets.py @@ -56,9 +56,9 @@ class SelectionEntry(PropertyGroup): class SelectionSet(PropertyGroup): name: StringProperty(name="Set Name", override={'LIBRARY_OVERRIDABLE'}) bone_ids: CollectionProperty( - type=SelectionEntry, + type=SelectionEntry, override={'LIBRARY_OVERRIDABLE', 'USE_INSERTION'} - ) + ) is_selected: BoolProperty(name="Is Selected", override={'LIBRARY_OVERRIDABLE'}) diff --git a/greasepencil_tools/box_deform.py b/greasepencil_tools/box_deform.py index 1f6d3abf..502c18ed 100644 --- a/greasepencil_tools/box_deform.py +++ b/greasepencil_tools/box_deform.py @@ -60,7 +60,7 @@ def view_cage(obj): target_frames = [f for f in l.frames if f.select] else: target_frames = [l.active_frame] - + for f in target_frames: for s in f.strokes: if not s.select: @@ -77,7 +77,7 @@ def view_cage(obj): for s in l.active_frame.strokes: for p in s.points: coords.append(obj.matrix_world @ p.co) - + elif bpy.context.mode == 'PAINT_GPENCIL': # get last stroke points coordinated if not gpl.active or not gpl.active.active_frame: @@ -85,12 +85,12 @@ def view_cage(obj): if not len(gpl.active.active_frame.strokes): return 'No stroke found to deform' - + paint_id = -1 if bpy.context.scene.tool_settings.use_gpencil_draw_onback: paint_id = 0 coords = [obj.matrix_world @ p.co for p in gpl.active.active_frame.strokes[paint_id].points] - + else: return 'Wrong mode!' @@ -106,24 +106,24 @@ def view_cage(obj): if bpy.context.mode == 'EDIT_GPENCIL': vg = assign_vg(obj, vg_name) - + if bpy.context.mode == 'PAINT_GPENCIL': # points cannot be assign to API yet(ugly and slow workaround but only way) # -> https://developer.blender.org/T56280 so, hop'in'ops ! - + # store selection and deselect all plist = [] for s in gpl.active.active_frame.strokes: for p in s.points: plist.append([p, p.select]) p.select = False - + # select ## foreach_set does not update # gpl.active.active_frame.strokes[paint_id].points.foreach_set('select', [True]*len(gpl.active.active_frame.strokes[paint_id].points)) for p in gpl.active.active_frame.strokes[paint_id].points: p.select = True - + # assign bpy.ops.object.mode_set(mode='EDIT_GPENCIL') vg = assign_vg(obj, vg_name) @@ -131,7 +131,7 @@ def view_cage(obj): # restore for pl in plist: pl[0].select = pl[1] - + ## View axis Mode --- @@ -216,7 +216,7 @@ def view_cage(obj): if initial_mode == 'PAINT_GPENCIL': mod.layer = gpl.active.info - + # note : if initial was Paint, changed to Edit # so vertex attribution is valid even for paint if bpy.context.mode == 'EDIT_GPENCIL': @@ -226,7 +226,7 @@ def view_cage(obj): if bpy.context.mode != 'OBJECT': bpy.ops.object.mode_set(mode='OBJECT') - # Store name of deformed object in case of 'revive modal' + # Store name of deformed object in case of 'revive modal' cage.vertex_groups.new(name=obj.name) ## select and make cage active @@ -245,7 +245,7 @@ def view_cage(obj): def back_to_obj(obj, gp_mode, org_lattice_toolset, context): if context.mode == 'EDIT_LATTICE' and org_lattice_toolset:# Tweaktoolcode - restore the active tool used by lattice edit.. bpy.ops.wm.tool_set_by_id(name = org_lattice_toolset)# Tweaktoolcode - + # gp object active and selected bpy.ops.object.mode_set(mode='OBJECT') obj.select_set(True) @@ -273,9 +273,9 @@ def cancel_cage(gp_obj, cage): gp_obj.grease_pencil_modifiers.remove(mod) else: print('tmp_lattice modifier not found to remove...') - + delete_cage(cage) - + class GP_OT_latticeGpDeform(bpy.types.Operator): """Create a lattice to use as quad corner transform""" @@ -302,7 +302,7 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" if event.type in {'Z'} and event.value == 'PRESS' and event.ctrl: ## Disable (capture key) return {"RUNNING_MODAL"} - ## Not found how possible to find modal start point in undo stack to + ## Not found how possible to find modal start point in undo stack to # print('ops list', context.window_manager.operators.keys()) # if context.window_manager.operators:#can be empty # print('\nlast name', context.window_manager.operators[-1].name) @@ -320,7 +320,7 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" if event.type in {'H'} and event.value == 'PRESS': # self.report({'INFO'}, "Can't hide") return {"RUNNING_MODAL"} - + if event.type in {'ONE'} and event.value == 'PRESS':# , 'NUMPAD_1' self.lat.points_u = self.lat.points_v = 2 return {"RUNNING_MODAL"} @@ -361,25 +361,25 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" self.lat.points_u = 2 self.lat.points_v = 1 return {"RUNNING_MODAL"} - + if event.type in {'RIGHT_ARROW'} and event.value == 'PRESS' and event.ctrl: if self.lat.points_u < 20: - self.lat.points_u += 1 + self.lat.points_u += 1 return {"RUNNING_MODAL"} if event.type in {'LEFT_ARROW'} and event.value == 'PRESS' and event.ctrl: if self.lat.points_u > 1: - self.lat.points_u -= 1 + self.lat.points_u -= 1 return {"RUNNING_MODAL"} if event.type in {'UP_ARROW'} and event.value == 'PRESS' and event.ctrl: if self.lat.points_v < 20: - self.lat.points_v += 1 + self.lat.points_v += 1 return {"RUNNING_MODAL"} if event.type in {'DOWN_ARROW'} and event.value == 'PRESS' and event.ctrl: if self.lat.points_v > 1: - self.lat.points_v -= 1 + self.lat.points_v -= 1 return {"RUNNING_MODAL"} @@ -397,15 +397,15 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" self.restore_prefs(context) back_to_obj(self.gp_obj, self.gp_mode, self.org_lattice_toolset, context) apply_cage(self.gp_obj, self.cage)#must be in object mode - - # back to original mode + + # back to original mode if self.gp_mode != 'OBJECT': bpy.ops.object.mode_set(mode=self.gp_mode) context.area.header_text_set(None)#reset header return {'FINISHED'} - + # Abort --- # One Warning for Tab cancellation. if event.type == 'TAB' and event.value == 'PRESS': @@ -432,14 +432,14 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" self.restore_prefs(context) back_to_obj(self.gp_obj, self.gp_mode, self.org_lattice_toolset, context) cancel_cage(self.gp_obj, self.cage) - context.area.header_text_set(None) + context.area.header_text_set(None) if self.gp_mode != 'OBJECT': bpy.ops.object.mode_set(mode=self.gp_mode) def store_prefs(self, context): # store_valierables <-< preferences - self.use_drag_immediately = context.preferences.inputs.use_drag_immediately - self.drag_threshold_mouse = context.preferences.inputs.drag_threshold_mouse + self.use_drag_immediately = context.preferences.inputs.use_drag_immediately + self.drag_threshold_mouse = context.preferences.inputs.drag_threshold_mouse self.drag_threshold_tablet = context.preferences.inputs.drag_threshold_tablet self.use_overlays = context.space_data.overlay.show_overlays # maybe store in windows manager to keep around in case of modal revival ? @@ -450,7 +450,7 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" context.preferences.inputs.drag_threshold_mouse = self.drag_threshold_mouse context.preferences.inputs.drag_threshold_tablet = self.drag_threshold_tablet context.space_data.overlay.show_overlays = self.use_overlays - + def set_prefs(self, context): context.preferences.inputs.use_drag_immediately = True context.preferences.inputs.drag_threshold_mouse = 1 @@ -475,8 +475,8 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" self.org_lattice_toolset = None ## usability toggles if self.prefs.use_clic_drag:#Store the active tool since we will change it - self.org_lattice_toolset = bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname# Tweaktoolcode - + self.org_lattice_toolset = bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname# Tweaktoolcode + #store (scene properties needed in case of ctrlZ revival) self.store_prefs(context) self.gp_mode = 'EDIT_GPENCIL' @@ -502,17 +502,17 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" if context.object.type != 'GPENCIL': # self.report({'ERROR'}, "Works only on gpencil objects") - ## silent return + ## silent return return {'CANCELLED'} #paint need VG workaround. object need good shortcut if context.mode not in ('EDIT_GPENCIL', 'OBJECT', 'PAINT_GPENCIL'): # self.report({'WARNING'}, "Works only in following GPencil modes: edit")# ERROR - ## silent return + ## silent return return {'CANCELLED'} # bpy.ops.ed.undo_push(message="Box deform step")#don't work as expected (+ might be obsolete) - # https://developer.blender.org/D6147 <- undo forget + # https://developer.blender.org/D6147 <- undo forget self.gp_obj = context.object # Clean potential failed previous job (delete tmp lattice) @@ -529,10 +529,10 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" if [m for m in self.gp_obj.grease_pencil_modifiers if m.type == 'GP_LATTICE']: self.report({'ERROR'}, "Grease pencil object already has a lattice modifier (can only have one)") return {'CANCELLED'} - + self.gp_mode = context.mode#store mode for restore - + # All good, create lattice and start modal # Create lattice (and switch to lattice edit) ---- @@ -540,7 +540,7 @@ valid:Spacebar/Enter, cancel:Del/Backspace/Tab/Ctrl+T" if isinstance(self.cage, str):#error, cage not created, display error self.report({'ERROR'}, self.cage) return {'CANCELLED'} - + self.lat = self.cage.data self.set_prefs(context) @@ -581,4 +581,4 @@ def unregister(): wm = bpy.context.window_manager p = 'boxdeform_running' if p in wm: - del wm[p]
\ No newline at end of file + del wm[p] diff --git a/greasepencil_tools/import_brush_pack.py b/greasepencil_tools/import_brush_pack.py index 90d186c3..b1306bed 100644 --- a/greasepencil_tools/import_brush_pack.py +++ b/greasepencil_tools/import_brush_pack.py @@ -30,7 +30,7 @@ def download_url(url, dest): import time ssl._create_default_https_context = ssl._create_unverified_context start_time = time.time() - + try: with urllib.request.urlopen(url) as response, open(dest, 'wb') as out_file: shutil.copyfileobj(response, out_file) @@ -53,7 +53,7 @@ def get_brushes(blend_fp): ## force fake user for the brushes for b in data_to.brushes: b.use_fake_user = True - + return len(data_to.brushes) class GP_OT_install_brush_pack(bpy.types.Operator): @@ -101,12 +101,12 @@ class GP_OT_install_brush_pack(bpy.types.Operator): if not temp: self.report({'ERROR'}, 'no os temporary directory found to download brush pack (using python tempfile.gettempdir())') return {"CANCELLED"} - + self.temp = Path(temp) ## download link from gitlab - # brush pack project https://gitlab.com/pepe-school-land/gp-brush-pack - repo_url = r'https://gitlab.com/api/v4/projects/21994857' + # brush pack project https://gitlab.com/pepe-school-land/gp-brush-pack + repo_url = r'https://gitlab.com/api/v4/projects/21994857' tree_url = f'{repo_url}/repository/tree' ## need to create an SSl context or linux fail and raise unverified ssl @@ -127,7 +127,7 @@ class GP_OT_install_brush_pack(bpy.types.Operator): self.report({'ERROR'}, f'Check your internet connexion, Impossible to connect to url: {tree_url}') return {"CANCELLED"} - + if not html: self.report({'ERROR'}, f'No response read from: {tree_url}') return {"CANCELLED"} @@ -154,7 +154,7 @@ class GP_OT_install_brush_pack(bpy.types.Operator): dl_url = f"{repo_url}/repository/blobs/{id_num}/raw" self.brushzip = self.temp / zipname - + ### Load existing files instead of redownloading if exists and up to date (same hash) if self.brushzip.exists(): @@ -167,20 +167,20 @@ class GP_OT_install_brush_pack(bpy.types.Operator): while len(fb) > 0: file_hash.update(fb) fb = f.read(BLOCK_SIZE) - + if file_hash.hexdigest() == id_num: # same git SHA1 - ## is up to date, install + ## is up to date, install print(f'{self.brushzip} is up do date, appending brushes') self._install_from_zip() return {"FINISHED"} - + ## Download, unzip, use blend print(f'Downloading brushpack in {self.brushzip}') ## https://cloud.blender.org/p/gallery/5f235cc297f8815e74ffb90b fallback_url='https://gitlab.com/pepe-school-land/gp-brush-pack/-/blob/master/Official_GP_brush_pack_v01.zip' err = simple_dl_url(dl_url, str(self.brushzip), fallback_url) - # err = download_url(dl_url, str(self.brushzip), fallback_url) + # err = download_url(dl_url, str(self.brushzip), fallback_url) if err: self.report({'ERROR'}, 'Could not download brush pack. Check your internet connection. (see console for detail)') @@ -195,4 +195,4 @@ def register(): bpy.utils.register_class(GP_OT_install_brush_pack) def unregister(): - bpy.utils.unregister_class(GP_OT_install_brush_pack)
\ No newline at end of file + bpy.utils.unregister_class(GP_OT_install_brush_pack) diff --git a/greasepencil_tools/line_reshape.py b/greasepencil_tools/line_reshape.py index 608b95b2..b994b8d6 100644 --- a/greasepencil_tools/line_reshape.py +++ b/greasepencil_tools/line_reshape.py @@ -15,7 +15,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### - + '''Based on GP_refine_stroke 0.2.4 - Author: Samuel Bernou''' import bpy @@ -36,10 +36,10 @@ def vector_len_from_coord(a, b): Get two points (that has coordinate 'co' attribute) or Vectors (2D or 3D) Return length as float ''' - from mathutils import Vector + from mathutils import Vector if type(a) is Vector: return (a - b).length - else: + else: return (a.co - b.co).length def point_from_dist_in_segment_3d(a, b, ratio): @@ -53,7 +53,7 @@ def get_stroke_length(s): all_len = 0.0 for i in range(0, len(s.points)-1): #print(vector_len_from_coord(s.points[i],s.points[i+1])) - all_len += vector_len_from_coord(s.points[i],s.points[i+1]) + all_len += vector_len_from_coord(s.points[i],s.points[i+1]) return (all_len) ### --- Functions @@ -63,7 +63,7 @@ def to_straight_line(s, keep_points=True, influence=100, straight_pressure=True) keep points : if false only start and end point stay straight_pressure : (not available with keep point) take the mean pressure of all points and apply to stroke. ''' - + p_len = len(s.points) if p_len <= 2: # 1 or 2 points only, cancel return @@ -83,21 +83,21 @@ def to_straight_line(s, keep_points=True, influence=100, straight_pressure=True) full_dist = get_stroke_length(s) dist_from_start = 0.0 coord_list = [] - + for i in range(1, p_len-1):#all but first and last dist_from_start += vector_len_from_coord(s.points[i-1],s.points[i]) ratio = dist_from_start / full_dist # dont apply directly (change line as we measure it in loop) coord_list.append( point_from_dist_in_segment_3d(A, B, ratio) ) - + # apply change for i in range(1, p_len-1): ## Direct super straight 100% #s.points[i].co = coord_list[i-1] - + ## With influence s.points[i].co = point_from_dist_in_segment_3d(s.points[i].co, coord_list[i-1], influence / 100) - + return def get_last_index(context=None): @@ -119,9 +119,9 @@ class GP_OT_straightStroke(bpy.types.Operator): return context.active_object is not None and context.object.type == 'GPENCIL' #and context.mode in ('PAINT_GPENCIL', 'EDIT_GPENCIL') - influence_val : bpy.props.FloatProperty(name="Straight force", description="Straight interpolation percentage", + influence_val : bpy.props.FloatProperty(name="Straight force", description="Straight interpolation percentage", default=100, min=0, max=100, step=2, precision=1, subtype='PERCENTAGE', unit='NONE') - + def execute(self, context): gp = context.object.data gpl = gp.layers @@ -130,16 +130,16 @@ class GP_OT_straightStroke(bpy.types.Operator): if context.mode == 'PAINT_GPENCIL': if not gpl.active or not gpl.active.active_frame: - self.report({'ERROR'}, 'No Grease pencil frame found') + self.report({'ERROR'}, 'No Grease pencil frame found') return {"CANCELLED"} if not len(gpl.active.active_frame.strokes): - self.report({'ERROR'}, 'No strokes found.') + self.report({'ERROR'}, 'No strokes found.') return {"CANCELLED"} s = gpl.active.active_frame.strokes[get_last_index(context)] to_straight_line(s, keep_points=True, influence=self.influence_val) - + elif context.mode == 'EDIT_GPENCIL': ct = 0 for l in gpl: @@ -150,15 +150,15 @@ class GP_OT_straightStroke(bpy.types.Operator): target_frames = [f for f in l.frames if f.select] else: target_frames = [l.active_frame] - + for f in target_frames: for s in f.strokes: if s.select: ct += 1 to_straight_line(s, keep_points=True, influence=self.influence_val) - + if not ct: - self.report({'ERROR'}, 'No selected stroke found.') + self.report({'ERROR'}, 'No selected stroke found.') return {"CANCELLED"} ## filter method @@ -172,7 +172,7 @@ class GP_OT_straightStroke(bpy.types.Operator): # to_straight_line(s, keep_points=True, influence = self.influence_val)#, straight_pressure=True return {"FINISHED"} - + def draw(self, context): layout = self.layout layout.prop(self, "influence_val") diff --git a/greasepencil_tools/prefs.py b/greasepencil_tools/prefs.py index 69b92780..b8b9894d 100644 --- a/greasepencil_tools/prefs.py +++ b/greasepencil_tools/prefs.py @@ -74,13 +74,13 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences): name='Use click drag directly on points', description="Change the active tool to 'tweak' during modal, Allow to direct clic-drag points of the box", default=True) - + default_deform_type : EnumProperty( items=(('KEY_LINEAR', "Linear (perspective mode)", "Linear interpolation, like corner deform / perspective tools of classic 2D", 'IPO_LINEAR',0), ('KEY_BSPLINE', "Spline (smooth deform)", "Spline interpolation transformation\nBest when lattice is subdivided", 'IPO_CIRC',1), ), name='Starting Interpolation', default='KEY_LINEAR', description='Choose default interpolation when entering mode') - + # About interpolation : https://docs.blender.org/manual/en/2.83/animation/shape_keys/shape_keys_panel.html#fig-interpolation-type auto_swap_deform_type : BoolProperty( @@ -112,7 +112,7 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences): ('MIDDLEMOUSE', 'Mid click', 'Use click on Mid mouse button', 'MOUSE_MMB', 2), ), update=auto_rebind) - + use_shift: BoolProperty( name = "combine with shift", description = "add shift", @@ -139,8 +139,8 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences): row.prop(self, "pref_tabs", expand=True) if self.pref_tabs == 'PREF': - - ## TAB CATEGORY + + ## TAB CATEGORY box = layout.box() row = box.row(align=True) row.label(text="Panel Category:") @@ -153,7 +153,7 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences): # box.separator() box.prop(self, "default_deform_type") box.label(text="Deformer type can be changed during modal with 'M' key, this is for default behavior", icon='INFO') - + box.prop(self, "auto_swap_deform_type") box.label(text="Once 'M' is hit, auto swap is desactivated to stay in your chosen mode", icon='INFO') @@ -164,7 +164,7 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences): box.prop(self, "canvas_use_shortcut", text='Bind Shortcuts') if self.canvas_use_shortcut: - + row = box.row() row.label(text="(Auto rebind when changing shortcut)")#icon="" # row.operator("prefs.rebind_shortcut", text='Bind/Rebind shortcuts', icon='FILE_REFRESH')#EVENT_SPACEKEY @@ -255,4 +255,4 @@ def register(): def unregister(): unregister_keymaps() bpy.utils.unregister_class(GreasePencilAddonPrefs) - bpy.utils.unregister_class(GPTS_timeline_settings)
\ No newline at end of file + bpy.utils.unregister_class(GPTS_timeline_settings) diff --git a/greasepencil_tools/rotate_canvas.py b/greasepencil_tools/rotate_canvas.py index 2ba5ed34..aec6e900 100644 --- a/greasepencil_tools/rotate_canvas.py +++ b/greasepencil_tools/rotate_canvas.py @@ -83,14 +83,14 @@ class RC_OT_RotateCanvas(bpy.types.Operator): if self.in_cam: self.cam.matrix_world = self.cam_matrix self.cam.rotation_euler.rotate_axis("Z", self.angle) - + else:#free view context.space_data.region_3d.view_rotation = self._rotation rot = context.space_data.region_3d.view_rotation rot = rot.to_euler() rot.rotate_axis("Z", self.angle) context.space_data.region_3d.view_rotation = rot.to_quaternion() - + if event.type in {'RIGHTMOUSE', 'LEFTMOUSE', 'MIDDLEMOUSE'} and event.value == 'RELEASE': if not self.angle: # self.report({'INFO'}, 'Reset') @@ -98,7 +98,7 @@ class RC_OT_RotateCanvas(bpy.types.Operator): context.space_data.region_3d.view_rotation = aim.to_track_quat('Z','Y')#track Z, up Y self.execute(context) return {'FINISHED'} - + if event.type == 'ESC':#Cancel self.execute(context) if self.in_cam: @@ -118,10 +118,10 @@ class RC_OT_RotateCanvas(bpy.types.Operator): if self.in_cam: # Get camera from scene self.cam = bpy.context.scene.camera - + #return if one element is locked (else bypass location) if self.cam.lock_rotation[:] != (False, False, False): - self.report({'WARNING'}, 'Camera rotation is locked') + self.report({'WARNING'}, 'Camera rotation is locked') return {'CANCELLED'} self.center = self.get_center_view(context, self.cam) @@ -135,21 +135,21 @@ class RC_OT_RotateCanvas(bpy.types.Operator): else: self.center = mathutils.Vector((context.area.width/2, context.area.height/2)) - + # store current rotation self._rotation = context.space_data.region_3d.view_rotation.copy() # Get current mouse coordination self.pos_current = mathutils.Vector((event.mouse_region_x, event.mouse_region_y)) - + self.initial_pos = self.pos_current# for draw debug, else no need # Calculate inital vector self.vector_initial = self.pos_current - self.center self.vector_initial.normalize() - + # Initializes the current vector with the same initial vector. self.vector_current = self.vector_initial.copy() - + args = (self, context) if self.hud: self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL') @@ -167,4 +167,4 @@ def unregister(): bpy.utils.unregister_class(RC_OT_RotateCanvas) # if __name__ == "__main__": -# register()
\ No newline at end of file +# register() diff --git a/greasepencil_tools/timeline_scrub.py b/greasepencil_tools/timeline_scrub.py index bd7edebe..1f89f4d1 100644 --- a/greasepencil_tools/timeline_scrub.py +++ b/greasepencil_tools/timeline_scrub.py @@ -227,7 +227,7 @@ class GPTS_OT_time_scrub(bpy.types.Operator): self.my = my = event.mouse_region_y self.hud_lines = [] - + # frame marks for x in hud_pos_x: self.hud_lines.append((x, my - (frame_height/2))) diff --git a/greasepencil_tools/ui_panels.py b/greasepencil_tools/ui_panels.py index 715c4db5..292d0e5a 100644 --- a/greasepencil_tools/ui_panels.py +++ b/greasepencil_tools/ui_panels.py @@ -27,7 +27,7 @@ class GP_PT_sidebarPanel(bpy.types.Panel): def draw(self, context): layout = self.layout layout.use_property_split = True - + # Box deform ops self.layout.operator_context = 'INVOKE_DEFAULT' layout.operator('gp.latticedeform', icon ="MOD_MESHDEFORM")# MOD_LATTICE, LATTICE_DATA diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index 28e8f711..0a40a6d0 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -78,7 +78,7 @@ def every_3_seconds(): if(only_one_time): only_one_time = False folders.loadExchangeFolder() - + try: coat3D = bpy.context.scene.coat3D @@ -96,7 +96,7 @@ def every_3_seconds(): except: pass - + return 3.0 @persistent @@ -207,10 +207,10 @@ def updatemesh(objekti, proxy, texturelist): if(udim_textures): udim = proxy.data.uv_layers[index].name udim_index = int(udim[2:]) - 1 - + objekti.data.uv_layers[0].data[indi].uv[0] = proxy.data.uv_layers[index].data[indi].uv[0] objekti.data.uv_layers[0].data[indi].uv[1] = proxy.data.uv_layers[index].data[indi].uv[1] - + index = index + 1 # Mesh Copy @@ -225,9 +225,9 @@ class SCENE_OT_getback(bpy.types.Operator): bl_label = "Export your custom property" bl_description = "Export your custom property" bl_options = {'UNDO'} - + def invoke(self, context, event): - + global global_exchange_folder path_ex = '' @@ -236,23 +236,23 @@ class SCENE_OT_getback(bpy.types.Operator): BlenderFolder = Blender_folder ExportFolder = Export_folder - + Blender_folder += ('%sexport.txt' % (os.sep)) Export_folder += ('%sexport.txt' % (os.sep)) - + if (bpy.app.background == False): if os.path.isfile(Export_folder): - + print('BLENDER -> 3DC -> BLENDER WORKFLLOW') - DeleteExtra3DC() + DeleteExtra3DC() workflow1(ExportFolder) removeFile(Export_folder) - removeFile(Blender_folder) - + removeFile(Blender_folder) + elif os.path.isfile(Blender_folder): print('3DC -> BLENDER WORKFLLOW') - DeleteExtra3DC() + DeleteExtra3DC() workflow2(BlenderFolder) removeFile(Blender_folder) @@ -263,23 +263,23 @@ class SCENE_OT_savenew(bpy.types.Operator): bl_label = "Export your custom property" bl_description = "Export your custom property" bl_options = {'UNDO'} - + def invoke(self, context, event): - + coat3D = bpy.context.scene.coat3D platform = os.sys.platform - + if(platform == 'win32' or platform == 'darwin'): exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt' else: exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt' if(os.path.isfile(exchangeFile)): folderPath = '' - + if(os.path.isfile(exchangeFile)): file = open(exchangeFile, "w") file.write("%s"%(coat3D.exchangeFolder)) - file.close() + file.close() return {'FINISHED'} @@ -331,7 +331,7 @@ class SCENE_OT_opencoat(bpy.types.Operator): def scaleParents(): save = [] names =[] - + for objekti in bpy.context.selected_objects: temp = objekti while (temp.parent is not None and temp.parent.name not in names): @@ -527,7 +527,7 @@ class SCENE_OT_export(bpy.types.Operator): def invoke(self, context, event): bpy.ops.export_applink.pilgway_3d_coat() - + return {'FINISHED'} def execute(self, context): @@ -548,7 +548,7 @@ class SCENE_OT_export(bpy.types.Operator): export_ok = False coat3D = bpy.context.scene.coat3D - + if (bpy.context.selected_objects == []): return {'FINISHED'} else: @@ -574,11 +574,11 @@ class SCENE_OT_export(bpy.types.Operator): if (os.path.isfile(Blender_folder2)): os.remove(Blender_folder2) - + if (not os.path.isdir(coat3D.exchangeFolder)): coat3D.exchange_found = False return {'FINISHED'} - + folder_objects = folders.set_working_folders() folder_size(folder_objects) @@ -735,7 +735,7 @@ class SCENE_OT_export(bpy.types.Operator): bpy.data.images.remove(image) index_bake_tex += 1 - + #BAKING ENDS #bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') @@ -789,7 +789,7 @@ class SCENE_OT_export(bpy.types.Operator): if(node.name.startswith('3DC_') == True): material.material.node_tree.nodes.remove(node) - + for ind, mat_list in enumerate(mod_mat_list): if(mat_list == '__' + objekti.name): for ind, mat in enumerate(mod_mat_list[mat_list]): @@ -822,7 +822,7 @@ def DeleteExtra3DC(): bpy.data.images.remove(del_img) bpy.data.materials.remove(material) - + image_del_list = [] for image in bpy.data.images: if (image.name.startswith('3DC')): @@ -901,7 +901,7 @@ def new_ref_function(new_applink_address, nimi): def blender_3DC_blender(texturelist, file_applink_address): - + coat3D = bpy.context.scene.coat3D old_materials = bpy.data.materials.keys() @@ -915,7 +915,7 @@ def blender_3DC_blender(texturelist, file_applink_address): for objekti in bpy.data.objects: if objekti.type == 'MESH' and objekti.coat3D.applink_address == file_applink_address: obj_coat = objekti.coat3D - + object_list.append(objekti.name) if(os.path.isfile(obj_coat.applink_address)): if (obj_coat.objecttime != str(os.path.getmtime(obj_coat.applink_address))): @@ -1050,7 +1050,7 @@ def blender_3DC_blender(texturelist, file_applink_address): #delete_materials_from_end(keep_materials_count, obj_proxy) - + updatemesh(objekti,obj_proxy, texturelist) bpy.context.view_layer.objects.active = objekti @@ -1178,7 +1178,7 @@ def blender_3DC(texturelist, new_applink_address): old_materials = bpy.data.materials.keys() old_objects = bpy.data.objects.keys() - + bpy.ops.import_scene.fbx(filepath=new_applink_address, global_scale = 1, axis_forward='-Z', axis_up='Y') new_materials = bpy.data.materials.keys() @@ -1253,7 +1253,7 @@ def blender_3DC(texturelist, new_applink_address): os.remove(Blender_export) if (os.path.isfile(Blender_folder2)): os.remove(Blender_folder2) - + for material in bpy.data.materials: if material.use_nodes == True: for node in material.node_tree.nodes: @@ -1271,9 +1271,9 @@ def workflow1(ExportFolder): for image in bpy.data.images: if(image.filepath == texturepath[3] and image.users == 0): bpy.data.images.remove(image) - + path3b_now = coat3D.exchangeFolder - + path3b_now += ('last_saved_3b_file.txt') new_applink_address = 'False' new_object = False @@ -1297,7 +1297,7 @@ def workflow1(ExportFolder): new_ref_object = True nimi = scene_objects.name - + exportfile = coat3D.exchangeFolder @@ -1327,9 +1327,9 @@ def workflow2(BlenderFolder): kokeilu = coat3D.exchangeFolder Blender_export = os.path.join(kokeilu, 'Blender') - + path3b_now = coat3D.exchangeFolder - + path3b_now += ('last_saved_3b_file.txt') Blender_export += ('%sexport.txt'%(os.sep)) new_applink_address = 'False' @@ -2007,7 +2007,7 @@ def register(): default=True ) - + from bpy.utils import register_class @@ -2017,7 +2017,7 @@ def register(): bpy.types.Object.coat3D = PointerProperty(type=ObjectCoat3D) bpy.types.Scene.coat3D = PointerProperty(type=SceneCoat3D) bpy.types.Mesh.coat3D = PointerProperty(type=MeshCoat3D) - bpy.types.Material.coat3D = PointerProperty(type=MaterialCoat3D) + bpy.types.Material.coat3D = PointerProperty(type=MaterialCoat3D) bpy.app.handlers.load_post.append(load_handler) kc = bpy.context.window_manager.keyconfigs.addon diff --git a/io_coat3D/folders.py b/io_coat3D/folders.py index ad54bf71..ed348cfa 100644 --- a/io_coat3D/folders.py +++ b/io_coat3D/folders.py @@ -9,33 +9,33 @@ def InitFolders(): # Global variable foundExchangeFolder (True / False) guides these steps # 1. Read Exchange_folder.txt, if not success -> # 2. Try to find exchange folder from system hard drive, if not success --> - # 3. Leave foundExchangeFolder = False + # 3. Leave foundExchangeFolder = False # 1. ################################################################# if(platform == 'win32' or platform == 'darwin'): - DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' else: - DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender' - + DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender' + exchangeFile = DC2Folder + os.sep + 'Exchange_folder.txt' if(not os.path.isdir(DC2Folder)): os.mkdir(DC2Folder) - + if(not os.path.isfile(exchangeFile)): file = open(exchangeFile, 'w') file.close() else: savedExchangePath = '' folderPath = open(exchangeFile) - + for line in folderPath: savedExchangePath = line break folderPath.close() - + coat3D.exchangeFolder = savedExchangePath return True, coat3D.exchangeFolder @@ -50,7 +50,7 @@ def InitFolders(): exchangeFolder = os.path.expanduser("~") + os.sep + '3D-CoatV3' + os.sep + 'Exchange' if(os.path.isdir(exchangeFolder)): coat3D.exchangeFolder = exchangeFolder - + Blender_folder = ("%s%sBlender"%(exchangeFolder,os.sep)) if(not(os.path.isdir(Blender_folder))): @@ -68,7 +68,7 @@ def InitFolders(): file = open(Blender_folder3, "w") file.write("Blender Cycles") file.close() - + file = open(exchangeFile, "w") file.write("%s"%(os.path.abspath(coat3D.exchangeFolder))) file.close() @@ -81,14 +81,14 @@ def InitFolders(): def updateExchangeFile(newPath): platform = os.sys.platform - + if(platform == 'win32' or platform == 'darwin'): exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt' else: exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt' if(os.path.isfile(exchangeFile)): folderPath = '' - + if(os.path.isfile(exchangeFile)): file = open(exchangeFile, "w") file.write("%s"%(newPath)) @@ -100,22 +100,22 @@ def loadExchangeFolder(): coat3D = bpy.context.scene.coat3D if(platform == 'win32' or platform == 'darwin'): - DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' else: - DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender' - + DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender' + exchangeFile = DC2Folder + os.sep + 'Exchange_folder.txt' if(not os.path.isdir(DC2Folder)): os.mkdir(DC2Folder) - + if(not os.path.isfile(exchangeFile)): file = open(exchangeFile, 'w') file.close() else: savedExchangePath = '' folderPath = open(exchangeFile) - + for line in folderPath: savedExchangePath = line break diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index c46275be..9901e3b2 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -73,22 +73,22 @@ def updatetextures(objekti): # Update 3DC textures def testi(objekti, texture_info, index_mat_name, uv_MODE_mat, mat_index): if uv_MODE_mat == 'UV': - + uv_set_founded = False for uvset in objekti.data.uv_layers: - + if(uvset.name == texture_info): uv_set_founded = True - + break - + if(uv_set_founded): for uv_poly in objekti.data.uv_layers[texture_info].id_data.polygons: if(mat_index == uv_poly.material_index): return True else: return False - + elif uv_MODE_mat == 'MAT': return (texture_info == index_mat_name) @@ -113,18 +113,18 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures, udi if(udim_textures == False): for slot_index, texture_info in enumerate(texturelist): - uv_MODE_mat = 'MAT' + uv_MODE_mat = 'MAT' for index, layer in enumerate(objekti.data.uv_layers): if(layer.name == texturelist[slot_index][0]): uv_MODE_mat = 'UV' break - + if(testi(objekti, texturelist[slot_index][0], index_mat.name, uv_MODE_mat, ind)) : if (os.path.isfile(texture_info[3])): if texture_info[2] == 'color' or texture_info[2] == 'diffuse': if(index_mat.material.coat3D_diffuse): - + texcoat['color'].append(texture_info[3]) create_nodes = True else: @@ -187,7 +187,7 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures, udi os.remove(texture_info[3]) create_group_node = True - + else: for texture_info in texturelist: @@ -281,8 +281,8 @@ def createnodes(active_mat,texcoat, create_group_node, objekti, ind, is_new, udi act_material = node.node_tree applink_tree = node break - - + + for node in act_material.nodes: if (node.type != 'GROUP'): if (node.type != 'GROUP_OUTPUT'): @@ -312,7 +312,7 @@ def createnodes(active_mat,texcoat, create_group_node, objekti, ind, is_new, udi bring_alpha = False updateimage.update(texcoat, 'alpha', node, udim_textures, udim_len) - + elif (node.type == 'GROUP' and node.name.startswith('3DC_')): if (node.name == '3DC_color'): bring_color = False @@ -481,12 +481,12 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, load_image = True for image in bpy.data.images: - + if(os.path.normpath(texcoat[type['name']][0]) == os.path.normpath(image.filepath)): load_image = False node.image = image - + if(udim_textures): node.image.source = 'TILED' for udim_index in udim_len: @@ -494,7 +494,7 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, node.image.tiles.new(udim_index) node.image.reload() - + break if (load_image): @@ -508,7 +508,7 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, if (udim_index != 1001): node.image.tiles.new(udim_index) - + if node.image and type['colorspace'] == 'noncolor': node.image.colorspace_settings.is_data = True @@ -567,7 +567,7 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, if(material.name == '3DC_Emission'): main_material.links.new(applink_tree.outputs[type['input']], material.inputs[0]) break - + uv_node.location = node.location uv_node.location[0] -= 300 uv_node.location[1] -= 200 @@ -660,19 +660,19 @@ def matlab(objekti,mat_list,texturelist,is_new): if(is_new): RemoveFbxNodes(objekti) - updatetextures(objekti) + updatetextures(objekti) - # Count udim tiles + # Count udim tiles if(texturelist != []): - + udim_textures = False udim_count = 0 udim_indexs = [] if texturelist[0][0].startswith('10') and len(texturelist[0][0]) == 4: udim_textures = True - + udim_target = '' udim_target = texturelist[0][2] for texture in texturelist: @@ -680,7 +680,7 @@ def matlab(objekti,mat_list,texturelist,is_new): udim_indexs.append(int(texture[0])) udim_indexs.sort() # sort tiles list -> 1001, 1002, 1003... - + # Main loop for creating nodes readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures, udim_indexs) diff --git a/io_coat3D/updateimage.py b/io_coat3D/updateimage.py index c811d770..2b967fd7 100644 --- a/io_coat3D/updateimage.py +++ b/io_coat3D/updateimage.py @@ -2,7 +2,7 @@ import bpy import os def update(texcoat,tex_type,node, udim_textures, udim_len): - + if (os.path.normpath(texcoat[tex_type][0]) != os.path.normpath(node.image.filepath)): tex_found = False diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py b/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py index d2a2cf3a..bd4f6a96 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py @@ -45,7 +45,7 @@ class GlTF2Exporter: generator='Khronos glTF Blender I/O v' + get_version_string(), min_version=None, version='2.0') - + export_user_extensions('gather_asset_hook', export_settings, asset) self.__gltf = gltf2_io.Gltf( @@ -106,7 +106,7 @@ class GlTF2Exporter: gltf2_io.MaterialNormalTextureInfoClass, gltf2_io.MaterialOcclusionTextureInfoClass ] - + self.__traverse(asset) @property diff --git a/io_scene_gltf2/blender/imp/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/blender/imp/gltf2_io_draco_compression_extension.py index 5a93673f..42c1af6b 100644 --- a/io_scene_gltf2/blender/imp/gltf2_io_draco_compression_extension.py +++ b/io_scene_gltf2/blender/imp/gltf2_io_draco_compression_extension.py @@ -64,7 +64,7 @@ def decode_primitive(gltf, prim): dll.decoderCopyIndices.restype = None dll.decoderCopyIndices.argtypes = [c_void_p, c_void_p] - + decoder = dll.decoderCreate() extension = prim.extensions['KHR_draco_mesh_compression'] @@ -82,7 +82,7 @@ def decode_primitive(gltf, prim): for existing_buffer_idx in gltf.buffers: if base_buffer_idx <= existing_buffer_idx: base_buffer_idx = existing_buffer_idx + 1 - + # Read indices. index_accessor = gltf.data.accessors[prim.indices] if dll.decoderGetIndexCount(decoder) != index_accessor.count: @@ -91,7 +91,7 @@ def decode_primitive(gltf, prim): if not dll.decoderReadIndices(decoder, index_accessor.component_type): print_console('ERROR', 'Draco Decoder: Unable to decode indices. Skipping primitive {}.'.format(name)) return - + indices_byte_length = dll.decoderGetIndicesByteLength(decoder) decoded_data = bytes(indices_byte_length) dll.decoderCopyIndices(decoder, decoded_data) @@ -107,14 +107,14 @@ def decode_primitive(gltf, prim): # Update accessor to point to the new buffer view. index_accessor.buffer_view = len(gltf.data.buffer_views) - 1 - + # Read each attribute. for attr_idx, attr in enumerate(extension['attributes']): dracoId = extension['attributes'][attr] if attr not in prim.attributes: print_console('ERROR', 'Draco Decoder: Draco attribute {} not in primitive attributes. Skipping primitive {}.'.format(attr, name)) return - + accessor = gltf.data.accessors[prim.attributes[attr]] if dll.decoderGetVertexCount(decoder) != accessor.count: print_console('WARNING', 'Draco Decoder: Vertex count of accessor and decoded vertex count does not match for attribute {}. Updating accessor.'.format(attr, name)) @@ -122,7 +122,7 @@ def decode_primitive(gltf, prim): if not dll.decoderReadAttribute(decoder, dracoId, accessor.component_type, accessor.type.encode()): print_console('ERROR', 'Draco Decoder: Could not decode attribute {}. Skipping primitive {}.'.format(attr, name)) return - + byte_length = dll.decoderGetAttributeByteLength(decoder, dracoId) decoded_data = bytes(byte_length) dll.decoderCopyAttribute(decoder, dracoId, decoded_data) @@ -130,7 +130,7 @@ def decode_primitive(gltf, prim): # Generate a new buffer holding the decoded vertex data. buffer_idx = base_buffer_idx + 1 + attr_idx gltf.buffers[buffer_idx] = decoded_data - + # Create a buffer view referencing the new buffer. gltf.data.buffer_views.append(BufferView.from_dict({ 'buffer': buffer_idx, diff --git a/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py index 51359f82..fc57a1e5 100644 --- a/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py +++ b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py @@ -39,7 +39,7 @@ def dll_path() -> Path: }.get(sys.platform) else: path = Path(path) - + library_name = { 'win32': '{}.dll'.format(lib_name), 'linux': 'lib{}.so'.format(lib_name), diff --git a/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py index 613bd231..0c6bfaf4 100644 --- a/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py +++ b/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py @@ -40,7 +40,7 @@ def encode_scene_primitives(scenes, export_settings): dll.encoderSetQuantizationBits.restype = None dll.encoderSetQuantizationBits.argtypes = [c_void_p, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32] - + dll.encoderSetIndices.restype = None dll.encoderSetIndices.argtypes = [c_void_p, c_size_t, c_uint32, c_void_p] @@ -114,7 +114,7 @@ def __encode_primitive(primitive, dll, export_settings): export_settings['gltf_draco_texcoord_quantization'], export_settings['gltf_draco_color_quantization'], export_settings['gltf_draco_generic_quantization']) - + if not dll.encoderEncode(encoder, primitive.targets is not None and len(primitive.targets) > 0): print_console('ERROR', 'Could not encode primitive. Skipping primitive.') @@ -124,7 +124,7 @@ def __encode_primitive(primitive, dll, export_settings): if primitive.extensions is None: primitive.extensions = {} - + primitive.extensions['KHR_draco_mesh_compression'] = { 'bufferView': BinaryData(encoded_data), 'attributes': draco_ids diff --git a/power_sequencer/operators/utils/functions.py b/power_sequencer/operators/utils/functions.py index 5b33067c..021dfd54 100644 --- a/power_sequencer/operators/utils/functions.py +++ b/power_sequencer/operators/utils/functions.py @@ -275,11 +275,11 @@ def trim_strips(context, frame_start, frame_end, to_trim, to_delete=[]): bpy.ops.sequencer.split(frame=trim_start, type="SOFT", side="RIGHT") bpy.ops.sequencer.split(frame=trim_end, type="SOFT", side="LEFT") to_delete.append(context.selected_sequences[0]) - + for c in context.sequences: if c.channel == s.channel: strips_in_target_channel.append(c) - + if s in initial_selection: initial_selection.append(strips_in_target_channel[0]) continue diff --git a/rigify/rot_mode.py b/rigify/rot_mode.py index 855857b8..59a233cb 100644 --- a/rigify/rot_mode.py +++ b/rigify/rot_mode.py @@ -249,7 +249,7 @@ def register(): # Classes. for cls in classes: register_class(cls) - + bpy.types.VIEW3D_MT_pose.append(draw_convert_rotation) def unregister(): |