From a29ef6cdc8d8eb9743d323fcbc29c9a2d52283ee Mon Sep 17 00:00:00 2001 From: NevilArt Date: Sun, 24 Dec 2023 20:32:34 +0300 Subject: [PATCH] U20231224 Graphic Draw for Blender 4.0 Fixed. Abort primitive issue fixed. --- CHANGELOG.md | 8 + README.md | 9 +- __init__.py | 2 +- bsmax/graphic.py | 62 +- bsmax/gride.py | 22 +- primitive/adaptive_plane.py | 2 +- primitive/arc.py | 2 +- primitive/bolt.py | 2 +- primitive/bone.py | 2 +- primitive/box.py | 2 +- primitive/camera.py | 7 +- primitive/capsule.py | 2 +- primitive/circle.py | 2 +- primitive/cylinder.py | 4 +- primitive/donut.py | 2 +- primitive/effector.py | 2 +- primitive/ellipse.py | 2 +- primitive/empty.py | 2 +- primitive/extrude.py | 4 +- primitive/gear.py | 2 +- primitive/greacepencil.py | 2 +- primitive/gride.py | 57 +- primitive/helix.py | 2 +- primitive/icosphere.py | 2 +- primitive/lattice.py | 2 +- primitive/light.py | 11 +- primitive/lightprobe.py | 2 +- primitive/line.py | 2 +- primitive/menu.py | 586 +++++++++------ primitive/metaball.py | 2 +- primitive/monkey.py | 2 +- primitive/ngon.py | 2 +- primitive/oiltank.py | 2 +- primitive/plane.py | 2 +- primitive/primitive.py | 30 +- primitive/profilo.py | 2 +- primitive/pyramid.py | 2 +- primitive/quadsphere.py | 2 +- primitive/rectangle.py | 2 +- primitive/speaker.py | 2 +- primitive/sphere.py | 2 +- primitive/star.py | 2 +- primitive/surface.py | 4 +- primitive/teapot.py | 2 +- primitive/text.py | 2 +- primitive/torus.py | 2 +- primitive/torusknot.py | 2 +- primitive/tube.py | 2 +- primitive/update.py | 690 ++++++++++-------- tools/internal/camera/target_camera.py | 6 +- tools/internal/ligth/target_light.py | 6 +- tools/internal/mesh/weld.py | 30 +- tools/internal/object/create.py | 50 +- tools/internal/rigg/joystick.py | 33 +- tools/internal/scene/mdf.py | 307 ++++++++ tools/internal/transform/align_objects.py | 68 +- tools/pipeline/__init__.py | 13 +- ...eady_render.py => make_ready_render_v1.py} | 8 +- ...r_ready_nhj.py => make_render_ready_v2.py} | 0 59 files changed, 1350 insertions(+), 737 deletions(-) create mode 100644 tools/internal/scene/mdf.py rename tools/pipeline/{make_ready_render.py => make_ready_render_v1.py} (99%) rename tools/pipeline/{make_render_ready_nhj.py => make_render_ready_v2.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a81731..7a57a3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 0, 1, 2, 20231210 +* Backburner submiter optimized, Same functionality with less registerd operators. +* Reset operator open new empty scene with one click. (File/Reset) +* Note: You still able to add and delete defult cube from New. (File/New/General) +* Join plus rename UVs chanels if chanels count is same in surce and target objects. (Optinal) +* Quadmenu Convert to issues fixed. (3DsMax mode) +* After effect exporter is part of BsMax now (Original authors Bartek Skorupa & Damien Picard) + # 0, 1, 2, 20231127 * Backburner timeout limit issue fixed. * Backburner submiter shows numbeer of frames are going to render, helps to avoid submit thousands of frame by mistake. diff --git a/README.md b/README.md index 984774d..d2c4780 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,9 @@ If you found this product useful and want to support this project you can Donate * [Download Older Version (2.80-2.92)(2.93-3.2)](https://github.com/NevilArt/BsMax_2_80) ## Recent Updates and Changes -* Backburner submiter optimized, Same functionality with less registerd operators. -* Reset operator open new empty scene with one click. (File/Reset) -* Note: You still able to add and delete defult cube from New. (File/New/General) -* Join plus rename UVs chanels if chanels count is same in surce and target objects. (Optinal) -* Quadmenu Convert to issues fixed. (3DsMax mode) -* After effect exporter is part of BsMax now (Original authors Bartek Skorupa & Damien Picard) +* Align objects and Target weld preview line is back for Blender 4.0. +* Draw Primitives Local preview gride is back for Blender 4.0. +* Draw Primitives Abort issue in Blender 4.0 Fixed. * [Change log ...](https://github.com/NevilArt/BsMax/blob/master/CHANGELOG.md) ## License diff --git a/__init__.py b/__init__.py index 6825bd9..f1fa8d5 100644 --- a/__init__.py +++ b/__init__.py @@ -20,7 +20,7 @@ 'name': 'BsMax', 'description': 'Package of many tools + other CG apps UI mimic', 'author': 'Naser Merati (Nevil)', - 'version': (0, 1, 2, 20231210), + 'version': (0, 1, 2, 20231225), 'blender': (3, 3, 0),# 3.3LTS ~ 4.0 'location': 'Almost Everywhere in Blender', 'wiki_url': 'https://github.com/NevilArt/BsMax/wiki', diff --git a/bsmax/graphic.py b/bsmax/graphic.py index 3f2a0d5..40adf2a 100644 --- a/bsmax/graphic.py +++ b/bsmax/graphic.py @@ -17,7 +17,6 @@ import bpy import gpu -from bgl import glEnable, GL_BLEND, glDisable, glLineWidth from gpu_extras.batch import batch_for_shader from bpy_extras.view3d_utils import location_3d_to_region_2d from bpy.app import version @@ -34,8 +33,7 @@ def get_uniform_color(mode="2D"): if version < (3, 6, 0): if mode == "2D": return "2D_UNIFORM_COLOR" - else: - return "3D_UNIFORM_COLOR" + return "3D_UNIFORM_COLOR" return "UNIFORM_COLOR" @@ -47,50 +45,6 @@ def get_screen_pos(ctx,coord): -def draw_line(self, mode, color): - if version < (4, 0, 0): - glEnable(GL_BLEND) - coords = [self.start, self.end] - shader = gpu.shader.from_builtin(mode) - batch = batch_for_shader(shader, 'LINE_STRIP', {'pos': coords}) - shader.bind() - shader.uniform_float('color', color) - batch.draw(shader) - glDisable(GL_BLEND) - - else: - pass - - - -def register_line(ctx, self, mode, color): - """ owner most have to 'start' and 'end' point values """ - """ self.start self.end """ - space = ctx.area.spaces.active - if mode == '2d': - return space.draw_handler_add( - draw_line, - tuple([self, get_uniform_color(mode="2D"), color]), - 'WINDOW', - 'POST_PIXEL' - ) - - if mode == '3d': - return space.draw_handler_add( - draw_line, - tuple([self, get_uniform_color(mode="3D"), color]), - 'WINDOW', - 'POST_VIEW' - ) - - - -def unregister_line(handle): - if handle: - bpy.types.SpaceView3D.draw_handler_remove(handle, 'WINDOW') - - - def rubber_band_create(self, sx, sy, ex, ey): self.vertices.clear() self.colors.clear() @@ -100,10 +54,8 @@ def rubber_band_create(self, sx, sy, ex, ey): self.colors.append(self.color_b) -def rubber_band_draw(self): - # glEnable(GL_BLEND) - glLineWidth(self.size) +def rubber_band_draw(self): if len(self.vertices) == 2: coords = [self.vertices[0], self.vertices[1]] batch = batch_for_shader(self.shader, 'LINE_STRIP', {"pos": coords}) @@ -112,7 +64,6 @@ def rubber_band_draw(self): self.shader.uniform_float("color", self.color_a) batch.draw(self.shader) - # glDisable(GL_BLEND) @@ -125,7 +76,7 @@ def __init__(self): self.draw_handler = None self.vertices = [] self.colors = [] - self.color_a = (0.0, 0.5, 0.5, 1.0) + self.color_a = (0.0, 0.75, 0.75, 1.0) self.color_b = (0.2, 0.0, 0.0, 1.0) self.shader = gpu.shader.from_builtin(get_uniform_color(mode="2D")) @@ -137,10 +88,11 @@ def draw_rubber(self): def register(self): SpaceView3D = bpy.types.SpaceView3D - self.draw_handler = SpaceView3D.draw_handler_add(self.draw_rubber, (), - 'WINDOW', 'POST_PIXEL') + self.draw_handler = SpaceView3D.draw_handler_add( + self.draw_rubber, (), 'WINDOW', 'POST_PIXEL' + ) def unregister(self): if self.draw_handler: bpy.types.SpaceView3D.draw_handler_remove(self.draw_handler, 'WINDOW') - self.draw_handler = None \ No newline at end of file + self.draw_handler = None diff --git a/bsmax/gride.py b/bsmax/gride.py index 94ce7da..ef3e963 100644 --- a/bsmax/gride.py +++ b/bsmax/gride.py @@ -16,7 +16,6 @@ import bpy import gpu -from bgl import glEnable, GL_BLEND, glDisable, glLineWidth from gpu_extras.batch import batch_for_shader from mathutils import Vector @@ -24,6 +23,9 @@ from bpy.app import version +if version < (4, 0, 0): + from bgl import glEnable, GL_BLEND, glDisable, glLineWidth + def get_uniform_color(mode="2D"): @@ -121,7 +123,23 @@ def local_gride_draw(self): glDisable(GL_BLEND) else: - pass + shader = gpu.shader.from_builtin(get_uniform_color(mode="3D")) + + # draw gride + self.draw_shader(shader, self.gride, 'LINES', self.gride_color) + + # draw border + if self.border: + self.draw_shader(shader, self.border, + 'LINE_STRIP', self.border_color) + + # draw closs + if self.cross: + self.draw_shader(shader, self.cross[0:2], + 'LINES', self.cross_x_color) + + self.draw_shader(shader, self.cross[2:4], + 'LINES', self.cross_y_color) diff --git a/primitive/adaptive_plane.py b/primitive/adaptive_plane.py index 9e33882..3574351 100644 --- a/primitive/adaptive_plane.py +++ b/primitive/adaptive_plane.py @@ -84,7 +84,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/arc.py b/primitive/arc.py index 72e9bce..aaee524 100644 --- a/primitive/arc.py +++ b/primitive/arc.py @@ -155,7 +155,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/bolt.py b/primitive/bolt.py index 9a70a71..ba46ea0 100644 --- a/primitive/bolt.py +++ b/primitive/bolt.py @@ -54,7 +54,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/bone.py b/primitive/bone.py index e078b65..cc9a873 100644 --- a/primitive/bone.py +++ b/primitive/bone.py @@ -52,7 +52,7 @@ def abort(self): # remove armature if no bone created if len(self.data.bones) == 0: - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) self.reset() diff --git a/primitive/box.py b/primitive/box.py index 8459cfa..e27bd86 100644 --- a/primitive/box.py +++ b/primitive/box.py @@ -270,7 +270,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/camera.py b/primitive/camera.py index 5400798..b3a14dc 100644 --- a/primitive/camera.py +++ b/primitive/camera.py @@ -25,9 +25,10 @@ def init(self): self.target = None def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) - if self.target: - bpy.ops.object.delete({'selected_objects': [self.target]}) + bpy.ops.object.select_all(action='DESELECT') + self.owner.select_set(True) + self.target.select_set(True) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/capsule.py b/primitive/capsule.py index 2a22251..58bcacd 100644 --- a/primitive/capsule.py +++ b/primitive/capsule.py @@ -150,7 +150,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/circle.py b/primitive/circle.py index 6fed475..91ce6b9 100644 --- a/primitive/circle.py +++ b/primitive/circle.py @@ -67,7 +67,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/cylinder.py b/primitive/cylinder.py index fa33d5b..fe067f0 100644 --- a/primitive/cylinder.py +++ b/primitive/cylinder.py @@ -238,7 +238,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) @@ -262,7 +262,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/donut.py b/primitive/donut.py index 421cbc3..e2ac9b7 100644 --- a/primitive/donut.py +++ b/primitive/donut.py @@ -56,7 +56,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/effector.py b/primitive/effector.py index e967d6c..6cc155b 100644 --- a/primitive/effector.py +++ b/primitive/effector.py @@ -25,7 +25,7 @@ def init(self): self.owner = None def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/ellipse.py b/primitive/ellipse.py index a820fbc..4caf2cd 100644 --- a/primitive/ellipse.py +++ b/primitive/ellipse.py @@ -60,7 +60,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/empty.py b/primitive/empty.py index 542132f..ddb15fc 100644 --- a/primitive/empty.py +++ b/primitive/empty.py @@ -26,7 +26,7 @@ def init(self): self.owner = None def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/extrude.py b/primitive/extrude.py index dcaf109..e87619a 100644 --- a/primitive/extrude.py +++ b/primitive/extrude.py @@ -132,7 +132,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) @@ -161,7 +161,7 @@ def update(self, ctx): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/gear.py b/primitive/gear.py index a49736b..af8239e 100644 --- a/primitive/gear.py +++ b/primitive/gear.py @@ -990,7 +990,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) class Create_OT_Gear(Draw_Primitive): diff --git a/primitive/greacepencil.py b/primitive/greacepencil.py index e1b7354..5455483 100644 --- a/primitive/greacepencil.py +++ b/primitive/greacepencil.py @@ -30,7 +30,7 @@ def create(self, ctx, gpencil_type): self.data = self.owner.data def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/gride.py b/primitive/gride.py index 8bec7e1..0b2239f 100644 --- a/primitive/gride.py +++ b/primitive/gride.py @@ -15,13 +15,15 @@ from mathutils import Vector, Matrix, Euler from math import pi, sqrt + from bpy_extras.view3d_utils import region_2d_to_location_3d from bsmax.state import get_view_orientation from bsmax.mouse import ray_cast, get_click_point_on_face -from bsmax.bsmatrix import (matrix_from_elements, - transform_point_to_matrix, - points_to_local_matrix) + +from bsmax.bsmatrix import ( + matrix_from_elements, transform_point_to_matrix, points_to_local_matrix +) @@ -106,10 +108,10 @@ def __init__(self): def get_defualt_face(self): return ( - Vector((-self.size, -self.size, 0)), - Vector((self.size, -self.size, 0)), - Vector((self.size, self.size, 0)), - Vector((-self.size, self.size, 0)) + Vector((-self.size, -self.size, 0)), + Vector((self.size, -self.size, 0)), + Vector((self.size, self.size, 0)), + Vector((-self.size, self.size, 0)) ) def reset(self): @@ -121,15 +123,30 @@ def reset(self): def update(self): # calculate matrix and meshes - self.gride_matrix = matrix_from_elements(self.location, self.rotation, Vector((1,1,1))) - self.floor_matrix = matrix_from_elements(Vector((0,0,0)), self.floor_rotation, Vector((1,1,1))) - self.gride_face = transform_point_to_matrix(self.get_defualt_face(), self.gride_matrix) - self.floor_face = transform_point_to_matrix(self.get_defualt_face(), self.floor_matrix) + self.gride_matrix = matrix_from_elements( + self.location, self.rotation, Vector((1,1,1)) + ) + + self.floor_matrix = matrix_from_elements( + Vector((0,0,0)), self.floor_rotation, Vector((1,1,1)) + ) + + self.gride_face = transform_point_to_matrix( + self.get_defualt_face(), self.gride_matrix + ) + + self.floor_face = transform_point_to_matrix( + self.get_defualt_face(), self.floor_matrix + ) def get_normal_direction(self, normal): if normal: direction = normal.normalized() - matrix = Matrix([direction, -direction.cross(normal), normal]).transposed() + + matrix = Matrix( + [direction, -direction.cross(normal), normal] + ).transposed() + self.rotation = matrix.to_euler() self.rotation.y += pi/2 else: @@ -138,7 +155,11 @@ def get_normal_direction(self, normal): def get_vector_direction(self, start, end, normal): if start and end and normal: direction = (end - start).normalized() - matrix = Matrix([direction, -direction.cross(normal), normal]).transposed() + + matrix = Matrix( + [direction, -direction.cross(normal), normal] + ).transposed() + return matrix.to_euler() return Euler((0, 0, 0), 'XYZ') #TODO @@ -157,7 +178,10 @@ def get_coordinate_view(self, ctx, x, y): region_3d = ctx.space_data.region_3d location = ctx.scene.cursor.location - click_location = region_2d_to_location_3d(region, region_3d, (x, y ), location) + click_location = region_2d_to_location_3d( + region, region_3d, (x, y ), location + ) + view_rotation = region_3d.view_matrix.inverted().to_euler() return click_location, view_rotation @@ -200,7 +224,10 @@ def get_coordinate(self, ctx, x, y): self.rotation = surf_rotation else: if view_orient == 'USER': - self.location = get_click_point_on_face(ctx, self.floor_face, x, y) + self.location = get_click_point_on_face( + ctx, self.floor_face, x, y + ) + self.rotation = Vector((0, 0, 0)) self.floor_rotation = Vector((0, 0, 0)) else: diff --git a/primitive/helix.py b/primitive/helix.py index 70efe99..ba0d523 100644 --- a/primitive/helix.py +++ b/primitive/helix.py @@ -131,7 +131,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/icosphere.py b/primitive/icosphere.py index c8c298f..c001f58 100644 --- a/primitive/icosphere.py +++ b/primitive/icosphere.py @@ -67,7 +67,7 @@ def update(self): bm.free() def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/lattice.py b/primitive/lattice.py index 7048b32..4f8c315 100644 --- a/primitive/lattice.py +++ b/primitive/lattice.py @@ -36,7 +36,7 @@ def create(self, ctx, gride): self.owner.rotation_euler = gride.rotation def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/light.py b/primitive/light.py index 401c7e8..9d7ce1b 100644 --- a/primitive/light.py +++ b/primitive/light.py @@ -49,7 +49,10 @@ def create(self, ctx, datatype): self.owner = newlight def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner, self.target]}) + bpy.ops.object.select_all(action='DESELECT') + self.owner.select_set(True) + self.target.select_set(True) + bpy.ops.object.delete(confirm=False) @@ -73,7 +76,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) @@ -168,7 +171,9 @@ def finish(self): if self.params.radius1 == 0: for constraint in self.light.owner.constraints: self.light.owner.constraints.remove(constraint) - bpy.ops.object.delete({'selected_objects': [self.subclass.owner]}) + bpy.ops.object.select_all(action='DESELECT') + self.subclass.owner.select_set(True) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/lightprobe.py b/primitive/lightprobe.py index 7cfe3ea..6c8b3ca 100644 --- a/primitive/lightprobe.py +++ b/primitive/lightprobe.py @@ -29,7 +29,7 @@ def init(self): self.data = None def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/line.py b/primitive/line.py index f43c68f..e0c75d1 100644 --- a/primitive/line.py +++ b/primitive/line.py @@ -69,7 +69,7 @@ def update(self): def abort(self): if len(self.knots) < 2: - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) else: self.lastknot = [] self.knots.pop() diff --git a/primitive/menu.py b/primitive/menu.py index 14ed5de..c1c62ac 100644 --- a/primitive/menu.py +++ b/primitive/menu.py @@ -25,21 +25,21 @@ class BsMax_MT_VertexCreate(Menu): def draw(self, ctx): layout=self.layout - layout.operator("create.vertex", - text="Vertex", - icon="DOT").fill_type='NONE' + layout.operator( + "create.vertex", text="Vertex", icon="DOT" + ).fill_type='NONE' - layout.operator("create.vertex", - text="Vertexs", - icon="STICKY_UVS_DISABLE").fill_type='VERT' + layout.operator( + "create.vertex", text="Vertexs", icon="STICKY_UVS_DISABLE" + ).fill_type='VERT' - layout.operator("create.vertex", - text="Edge", - icon="CON_TRACKTO").fill_type='EDGE' + layout.operator( + "create.vertex", text="Edge", icon="CON_TRACKTO" + ).fill_type='EDGE' - layout.operator("create.vertex", - text="Face", - icon="LIGHTPROBE_PLANAR").fill_type='FACE' + layout.operator( + "create.vertex", text="Face", icon="LIGHTPROBE_PLANAR" + ).fill_type='FACE' @@ -50,18 +50,19 @@ class BsMax_MT_Mesh_Extera(Menu): def draw(self, ctx): layout=self.layout - layout.operator("mesh.add_spider_web", - text="Spider Web", - icon="FREEZE") + layout.operator( + "mesh.add_spider_web", text="Spider Web", icon="FREEZE" + ) - layout.operator("mesh.make_pillow", - text="Pillow", - icon="GHOST_ENABLED") + layout.operator( + "mesh.make_pillow", text="Pillow", icon="GHOST_ENABLED" + ) layout.operator_context = "EXEC_DEFAULT" - layout.operator("object.create", - text="Bolt", - icon="TOOL_SETTINGS").type='BOLT' + + layout.operator( + "object.create", text="Bolt", icon="TOOL_SETTINGS" + ).type='BOLT' @@ -72,60 +73,77 @@ class BsMax_MT_MeshCreate(Menu): def draw(self, ctx): layout=self.layout - # layout.operator("create.adaptive_plane", - # text="Adaptive Plane", icon="MOD_BEVEL") + # layout.operator( + # "create.adaptive_plane", text="Adaptive Plane", icon="MOD_BEVEL" + # ) - layout.operator("create.plane", - text="Plane", icon="MESH_PLANE") + layout.operator( + "create.plane", text="Plane", icon="MESH_PLANE" + ) - layout.operator("create.box", - text="Box", icon="MESH_CUBE") + layout.operator( + "create.box", text="Box", icon="MESH_CUBE" + ) - layout.operator("create.cone", - text="Cone", icon="MESH_CONE") + layout.operator( + "create.cone", text="Cone", icon="MESH_CONE" + ) - layout.operator("create.sphere", - text="Sphere", icon="MESH_UVSPHERE") + layout.operator( + "create.sphere", text="Sphere", icon="MESH_UVSPHERE" + ) - # layout.operator("bsmax.creategeosphere", - # icon="MESH_ICOSPHERE") + # layout.operator( + # "bsmax.creategeosphere", icon="MESH_ICOSPHERE" + # ) - layout.operator("create.uicosphere", - text="IcoSphere", icon="MESH_ICOSPHERE") + layout.operator( + "create.uicosphere", text="IcoSphere", icon="MESH_ICOSPHERE" + ) - layout.operator("create.capsule", - text="Capsule", icon="META_CAPSULE") + layout.operator( + "create.capsule", text="Capsule", icon="META_CAPSULE" + ) - layout.operator("create.oiltank", - text="OilTank", icon="META_CAPSULE") + layout.operator( + "create.oiltank", text="OilTank", icon="META_CAPSULE" + ) - layout.operator("create.cylinder", - text="Cylinder", icon="MESH_CYLINDER") + layout.operator( + "create.cylinder", text="Cylinder", icon="MESH_CYLINDER" + ) - layout.operator("create.tube", - text="Tube", icon="MESH_TORUS") + layout.operator( + "create.tube", text="Tube", icon="MESH_TORUS" + ) - layout.operator("create.torus", - text="Torus", icon="MESH_TORUS") + layout.operator( + "create.torus", text="Torus", icon="MESH_TORUS" + ) - layout.operator("create.pyramid", - text="Pyramid", icon="MARKER") + layout.operator( + "create.pyramid", text="Pyramid", icon="MARKER" + ) - layout.operator("create.quadsphere", - text="QuadSphere", icon="SHADING_WIRE") + layout.operator( + "create.quadsphere", text="QuadSphere", icon="SHADING_WIRE" + ) - layout.operator("create.teapot", - text="Teapot", icon="NODE_MATERIAL") + layout.operator( + "create.teapot", text="Teapot", icon="NODE_MATERIAL" + ) - layout.operator("create.monkey", - text="Monkey", icon="MESH_MONKEY") + layout.operator( + "create.monkey", text="Monkey", icon="MESH_MONKEY" + ) layout.separator() layout.menu("BSMAX_MT_vertex_create_menu", icon='DOT') layout.separator() - layout.operator("create.extrude", - text="Extrude Mesh (Add)", icon="EXPORT").mode='Mesh' + layout.operator( + "create.extrude", text="Extrude Mesh (Add)", icon="EXPORT" + ).mode='Mesh' layout.separator() layout.menu("BSMAX_MT_mesh_extera_menu", icon='DOCUMENTS') @@ -151,8 +169,10 @@ def draw(self, ctx): layout.operator("create.helix", text="Helix", icon="MOD_SCREW") layout.operator("create.profilo", text="Profilo", icon="MOD_BOOLEAN") layout.separator() - layout.operator("create.extrude", - text="Extrude Curve (Add)",icon="EXPORT").mode='Curve' + + layout.operator( + "create.extrude", text="Extrude Curve (Add)",icon="EXPORT" + ).mode='Curve' @@ -174,20 +194,25 @@ class BsMax_MT_MetaballCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.metaball", text="Ball", - icon="META_BALL").metaball_type='BALL' + layout.operator( + "create.metaball", text="Ball", icon="META_BALL" + ).metaball_type='BALL' - layout.operator("create.metaball", text="Capcule", - icon="META_CAPSULE").metaball_type='CAPSULE' + layout.operator( + "create.metaball", text="Capcule", icon="META_CAPSULE" + ).metaball_type='CAPSULE' - layout.operator("create.metaball", text="Plane", - icon="META_PLANE").metaball_type='PLANE' + layout.operator( + "create.metaball", text="Plane", icon="META_PLANE" + ).metaball_type='PLANE' - layout.operator("create.metaball", text="Ellipsoid", - icon="META_ELLIPSOID").metaball_type='ELLIPSOID' + layout.operator( + "create.metaball", text="Ellipsoid", icon="META_ELLIPSOID" + ).metaball_type='ELLIPSOID' - layout.operator("create.metaball", text="Cube", - icon="META_CUBE").metaball_type='CUBE' + layout.operator( + "create.metaball", text="Cube", icon="META_CUBE" + ).metaball_type='CUBE' @@ -198,8 +223,10 @@ class BsMax_MT_TextCreate(Menu): def draw(self, ctx): layout = self.layout + layout.operator("create.text", text="Text", icon="OUTLINER_OB_FONT").fill_mode='BOTH' + layout.operator("create.text", text="Text", icon="FONT_DATA").fill_mode="NONE" @@ -212,12 +239,18 @@ class BsMax_MT_GreacePencilCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.greacepencil", text="Blank", - icon="EMPTY_AXIS").gpencil_type="EMPTY" - layout.operator("create.greacepencil", text="Stroke", - icon="OUTLINER_OB_GREASEPENCIL").gpencil_type='STROKE' - layout.operator("create.greacepencil", text="Monkey", - icon="MESH_MONKEY").gpencil_type="MONKEY" + layout.operator( + "create.greacepencil", text="Blank", icon="EMPTY_AXIS" + ).gpencil_type="EMPTY" + + layout.operator( + "create.greacepencil", text="Stroke", + icon="OUTLINER_OB_GREASEPENCIL" + ).gpencil_type='STROKE' + + layout.operator( + "create.greacepencil", text="Monkey", icon="MESH_MONKEY" + ).gpencil_type="MONKEY" @@ -240,12 +273,20 @@ class BsMax_MT_LatticeCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.lattice", text='Lattice 2x2x2 (Create)', - icon="OUTLINER_OB_LATTICE").resolution=2 - layout.operator("create.lattice", text='Lattice 3x3x3 (Create)', - icon="OUTLINER_OB_LATTICE").resolution=3 - layout.operator("create.lattice", text='Lattice 4x4x4 (Create)', - icon="OUTLINER_OB_LATTICE").resolution=4 + layout.operator( + "create.lattice", text='Lattice 2x2x2 (Create)', + icon="OUTLINER_OB_LATTICE" + ).resolution=2 + + layout.operator( + "create.lattice", text='Lattice 3x3x3 (Create)', + icon="OUTLINER_OB_LATTICE" + ).resolution=3 + + layout.operator( + "create.lattice", text='Lattice 4x4x4 (Create)', + icon="OUTLINER_OB_LATTICE" + ).resolution=4 @@ -256,22 +297,37 @@ class BsMax_MT_EmptyCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.empty", text="Plane Axis", - icon="EMPTY_AXIS").empty_type='PLAIN_AXES' - layout.operator("create.empty", text="Arrows", - icon="EMPTY_ARROWS").empty_type='ARROWS' - layout.operator("create.empty", text="Single Arrows", - icon="EMPTY_SINGLE_ARROW").empty_type='SINGLE_ARROW' - layout.operator("create.empty", text="Circle", - icon="MESH_CIRCLE").empty_type='CIRCLE' - layout.operator("create.empty", text="Cube", - icon="CUBE").empty_type='CUBE' - layout.operator("create.empty", text="Sphere", - icon="SPHERE").empty_type='SPHERE' - layout.operator("create.empty", text="Cone", - icon="CONE").empty_type='CONE' - layout.operator("create.empty", text="Image", - icon="FILE_IMAGE").empty_type='IMAGE' + layout.operator( + "create.empty", text="Plane Axis", icon="EMPTY_AXIS" + ).empty_type='PLAIN_AXES' + + layout.operator( + "create.empty", text="Arrows", icon="EMPTY_ARROWS" + ).empty_type='ARROWS' + + layout.operator( + "create.empty", text="Single Arrows", icon="EMPTY_SINGLE_ARROW" + ).empty_type='SINGLE_ARROW' + + layout.operator( + "create.empty", text="Circle", icon="MESH_CIRCLE" + ).empty_type='CIRCLE' + + layout.operator( + "create.empty", text="Cube", icon="CUBE" + ).empty_type='CUBE' + + layout.operator( + "create.empty", text="Sphere", icon="SPHERE" + ).empty_type='SPHERE' + + layout.operator( + "create.empty", text="Cone", icon="CONE" + ).empty_type='CONE' + + layout.operator( + "create.empty", text="Image", icon="FILE_IMAGE" + ).empty_type='IMAGE' @@ -282,10 +338,13 @@ class BsMax_MT_ImageCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.image", text="Refrence", - icon="IMAGE_REFERENCE").image_type='REFERENCE' - layout.operator("create.image", text="BackGround", - icon="IMAGE_BACKGROUND").image_type='BACKGROUND' + layout.operator( + "create.image", text="Refrence", icon="IMAGE_REFERENCE" + ).image_type='REFERENCE' + + layout.operator( + "create.image", text="BackGround", icon="IMAGE_BACKGROUND" + ).image_type='BACKGROUND' @@ -296,20 +355,25 @@ class BsMax_MT_LightCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.pointlight", - text="Point", icon="LIGHT_POINT") + layout.operator( + "create.pointlight", text="Point", icon="LIGHT_POINT" + ) - layout.operator("create.sunlight", - text="Sun", icon="LIGHT_SUN") + layout.operator( + "create.sunlight", text="Sun", icon="LIGHT_SUN" + ) - layout.operator("create.spotlight", - text="Spot Light Free/Target", icon="LIGHT_SPOT") + layout.operator( + "create.spotlight", text="Spot Light Free/Target", icon="LIGHT_SPOT" + ) - layout.operator("create.arealight", - text="Free Area",icon="LIGHT_AREA").free = True + layout.operator( + "create.arealight", text="Free Area",icon="LIGHT_AREA" + ).free = True - layout.operator("create.arealight", - text="Target Area",icon="LIGHT_AREA") + layout.operator( + "create.arealight", text="Target Area",icon="LIGHT_AREA" + ) @@ -319,12 +383,23 @@ class BsMax_MT_LightProbsCreate(Menu): bl_label = "Light Probe" def draw(self, ctx): layout = self.layout - layout.operator("create.light_probe_cubemap", - text="Reflection Cubemap", icon="LIGHTPROBE_CUBEMAP") - layout.operator("create.light_probe_planer", - text="Reflection Plane", icon="LIGHTPROBE_PLANAR") - layout.operator("create.light_probe_grid", - text="Irradiance Volume", icon="LIGHTPROBE_GRID") + layout.operator( + "create.light_probe_cubemap", + text="Reflection Cubemap", + icon="LIGHTPROBE_CUBEMAP" + ) + + layout.operator( + "create.light_probe_planer", + text="Reflection Plane", + icon="LIGHTPROBE_PLANAR" + ) + + layout.operator( + "create.light_probe_grid", + text="Irradiance Volume", + icon="LIGHTPROBE_GRID" + ) @@ -335,9 +410,14 @@ class BsMax_MT_CameraCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.camera", - text="Camera Free/Target", icon="OUTLINER_OB_CAMERA") - layout.operator("camera.create_from_view", icon="OUTLINER_OB_CAMERA") + layout.operator( + "create.camera", + text="Camera Free/Target", icon="OUTLINER_OB_CAMERA" + ) + + layout.operator( + "camera.create_from_view", icon="OUTLINER_OB_CAMERA" + ) @@ -348,8 +428,9 @@ class BsMax_MT_SpeakerCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.speaker", - text="Speaker", icon="OUTLINER_OB_SPEAKER") + layout.operator( + "create.speaker", text="Speaker", icon="OUTLINER_OB_SPEAKER" + ) @@ -360,44 +441,57 @@ class BsMax_MT_ForceFieldCreate(Menu): def draw(self, ctx): layout = self.layout - layout.operator("create.effector", text="Force", - icon="FORCE_FORCE").effector_type = 'FORCE' + layout.operator( + "create.effector", text="Force", icon="FORCE_FORCE" + ).effector_type = 'FORCE' - layout.operator("create.effector", text="Wind", - icon="FORCE_WIND").effector_type = 'WIND' + layout.operator( + "create.effector", text="Wind", icon="FORCE_WIND" + ).effector_type = 'WIND' - layout.operator("create.effector", text="Vortex", - icon="FORCE_VORTEX").effector_type = 'VORTEX' + layout.operator( + "create.effector", text="Vortex", icon="FORCE_VORTEX" + ).effector_type = 'VORTEX' - layout.operator("create.effector", text="Magnet", - icon="FORCE_MAGNETIC").effector_type = 'MAGNET' + layout.operator( + "create.effector", text="Magnet", icon="FORCE_MAGNETIC" + ).effector_type = 'MAGNET' - layout.operator("create.effector", text="Harmonic", - icon="FORCE_HARMONIC").effector_type = 'HARMONIC' + layout.operator( + "create.effector", text="Harmonic", icon="FORCE_HARMONIC" + ).effector_type = 'HARMONIC' - layout.operator("create.effector", text="Charge", - icon="FORCE_CHARGE").effector_type = 'CHARGE' + layout.operator( + "create.effector", text="Charge", icon="FORCE_CHARGE" + ).effector_type = 'CHARGE' - layout.operator("create.effector", text="Lennardj", - icon="FORCE_LENNARDJONES").effector_type = 'LENNARDJ' + layout.operator( + "create.effector", text="Lennardj", icon="FORCE_LENNARDJONES" + ).effector_type = 'LENNARDJ' - layout.operator("create.effector", text="Texture", - icon="FORCE_TEXTURE").effector_type = 'TEXTURE' + layout.operator( + "create.effector", text="Texture", icon="FORCE_TEXTURE" + ).effector_type = 'TEXTURE' - layout.operator("create.effector", text="Guide", - icon="FORCE_CURVE").effector_type = 'GUIDE' + layout.operator( + "create.effector", text="Guide", icon="FORCE_CURVE" + ).effector_type = 'GUIDE' - layout.operator("create.effector", text="Boid", - icon="FORCE_BOID").effector_type = 'BOID' + layout.operator( + "create.effector", text="Boid", icon="FORCE_BOID" + ).effector_type = 'BOID' - layout.operator("create.effector", text="Turbulence", - icon="FORCE_TURBULENCE").effector_type = 'TURBULENCE' + layout.operator( + "create.effector", text="Turbulence", icon="FORCE_TURBULENCE" + ).effector_type = 'TURBULENCE' - layout.operator("create.effector", text="Drag", - icon="FORCE_DRAG").effector_type = 'DRAG' + layout.operator( + "create.effector", text="Drag", icon="FORCE_DRAG" + ).effector_type = 'DRAG' - layout.operator("create.effector", text="Smoke", - icon="FORCE_FLUIDFLOW").effector_type = 'SMOKE' + layout.operator( + "create.effector", text="Smoke", icon="FORCE_FLUIDFLOW" + ).effector_type = 'SMOKE' @@ -416,56 +510,71 @@ def draw(self, ctx): layout.prop(ctx.scene.primitive_setting, 'draw_mode', text='', icon='VIEW3D') layout.separator() - layout.menu("BSMAX_MT_mesh_create_menu", - icon='OUTLINER_OB_MESH') + layout.menu( + "BSMAX_MT_mesh_create_menu", icon='OUTLINER_OB_MESH' + ) - layout.menu("BSMAX_MT_curve_create_menu", - icon='OUTLINER_OB_CURVE') + layout.menu( + "BSMAX_MT_curve_create_menu", icon='OUTLINER_OB_CURVE' + ) - layout.menu("BSMAX_MT_surface_create_menu", - icon='OUTLINER_OB_SURFACE') + layout.menu( + "BSMAX_MT_surface_create_menu", icon='OUTLINER_OB_SURFACE' + ) - layout.menu("BSMAX_MT_metaball_create_menu", - icon='OUTLINER_OB_META') + layout.menu( + "BSMAX_MT_metaball_create_menu", icon='OUTLINER_OB_META' + ) - layout.menu("BSMAX_MT_text_create_menu", - icon='OUTLINER_OB_FONT') + layout.menu( + "BSMAX_MT_text_create_menu", icon='OUTLINER_OB_FONT' + ) - layout.menu("BSMAX_MT_gracepencil_create_menu", - icon='OUTLINER_OB_GREASEPENCIL') + layout.menu( + "BSMAX_MT_gracepencil_create_menu", icon='OUTLINER_OB_GREASEPENCIL' + ) layout.separator() - layout.menu("BSMAX_MT_armature_create_menu", - icon='OUTLINER_OB_ARMATURE') + layout.menu( + "BSMAX_MT_armature_create_menu", icon='OUTLINER_OB_ARMATURE' + ) - layout.menu("BSMAX_MT_lattice_create_menu", - icon='OUTLINER_OB_LATTICE') + layout.menu( + "BSMAX_MT_lattice_create_menu", icon='OUTLINER_OB_LATTICE' + ) layout.separator() - layout.menu("BSMAX_MT_empty_create_menu", - icon='OUTLINER_OB_EMPTY') + layout.menu( + "BSMAX_MT_empty_create_menu", icon='OUTLINER_OB_EMPTY' + ) - layout.menu("BSMAX_MT_image_create_menu", - icon='OUTLINER_OB_IMAGE') + layout.menu( + "BSMAX_MT_image_create_menu", icon='OUTLINER_OB_IMAGE' + ) layout.separator() - layout.menu("BSMAX_MT_light_create_menu", - icon='OUTLINER_OB_LIGHT') + layout.menu( + "BSMAX_MT_light_create_menu", icon='OUTLINER_OB_LIGHT' + ) - layout.menu("BSMAX_MT_lightProbs_primitives", - icon='OUTLINER_OB_LIGHTPROBE') + layout.menu( + "BSMAX_MT_lightProbs_primitives", icon='OUTLINER_OB_LIGHTPROBE' + ) layout.separator() - layout.menu("BSMAX_MT_camera_create_menu", - icon='OUTLINER_OB_CAMERA') + layout.menu( + "BSMAX_MT_camera_create_menu", icon='OUTLINER_OB_CAMERA' + ) layout.separator() - layout.operator("create.speaker", - icon="OUTLINER_OB_SPEAKER") + layout.operator( + "create.speaker", icon="OUTLINER_OB_SPEAKER" + ) layout.separator() - layout.menu("BSMAX_MT_forcefield_cecreate_menu", - icon='OUTLINER_OB_FORCE_FIELD') + layout.menu( + "BSMAX_MT_forcefield_cecreate_menu", icon='OUTLINER_OB_FORCE_FIELD' + ) # OUTLINER_OB_GROUP_INSTANCE @@ -473,50 +582,65 @@ def mesh_add_append_menu(self, ctx): layout = self.layout layout.separator() layout.operator_context = "EXEC_DEFAULT" - layout.operator("object.create", - text="Plane", icon="MESH_PLANE").type='PLANE' + layout.operator( + "object.create", text="Plane", icon="MESH_PLANE" + ).type='PLANE' - layout.operator("object.create", - text="Box", icon="MESH_CUBE").type='BOX' + layout.operator( + "object.create", text="Box", icon="MESH_CUBE" + ).type='BOX' - layout.operator("object.create", - text="Cone", icon="MESH_CONE").type='CONE' + layout.operator( + "object.create", text="Cone", icon="MESH_CONE" + ).type='CONE' - layout.operator("object.create", - text="Sphere", icon="MESH_UVSPHERE").type='SPHERE' + layout.operator( + "object.create", text="Sphere", icon="MESH_UVSPHERE" + ).type='SPHERE' - layout.operator("object.create", - text="IcoSphere", icon="MESH_ICOSPHERE").type='ICOSPHERE' + layout.operator( + "object.create", text="IcoSphere", icon="MESH_ICOSPHERE" + ).type='ICOSPHERE' - layout.operator("object.create", - text="Capsule", icon="META_CAPSULE").type='CAPSULE' + layout.operator( + "object.create", text="Capsule", icon="META_CAPSULE" + ).type='CAPSULE' - layout.operator("object.create", - text="OilTank", icon="META_CAPSULE").type='OILTANK' + layout.operator( + "object.create", text="OilTank", icon="META_CAPSULE" + ).type='OILTANK' - layout.operator("object.create", - text="Cylinder", icon="MESH_CYLINDER").type='CYLINDER' + layout.operator( + "object.create", text="Cylinder", icon="MESH_CYLINDER" + ).type='CYLINDER' - layout.operator("object.create", - text="Tube", icon="MESH_TORUS").type='TUBE' + layout.operator( + "object.create", text="Tube", icon="MESH_TORUS" + ).type='TUBE' - layout.operator("object.create", - text="Torus", icon="MESH_TORUS").type='TORUS' + layout.operator( + "object.create", text="Torus", icon="MESH_TORUS" + ).type='TORUS' - layout.operator("object.create", - text="Pyramid", icon="MARKER").type='PYRAMID' + layout.operator( + "object.create", text="Pyramid", icon="MARKER" + ).type='PYRAMID' - layout.operator("object.create", - text="QuadSphere", icon="SHADING_WIRE").type='QUADSPHERE' + layout.operator( + "object.create", text="QuadSphere", icon="SHADING_WIRE" + ).type='QUADSPHERE' - layout.operator("object.create", - text="Teapot", icon="NODE_MATERIAL").type='TEAPOT' + layout.operator( + "object.create", text="Teapot", icon="NODE_MATERIAL" + ).type='TEAPOT' - layout.operator("object.create", - text="Monkey", icon="MESH_MONKEY").type='MONKEY' + layout.operator( + "object.create", text="Monkey", icon="MESH_MONKEY" + ).type='MONKEY' - layout.operator("object.create", - text="Bolt", icon="TOOL_SETTINGS").type='BOLT' + layout.operator( + "object.create", text="Bolt", icon="TOOL_SETTINGS" + ).type='BOLT' # layout.separator() # layout.menu("BSMAX_MT_vertex_create_menu", icon='DOT').type='' @@ -528,35 +652,45 @@ def curve_add_append_menu(self, ctx): layout.separator() layout.operator_context = "EXEC_DEFAULT" - layout.operator("object.create", - text="Rectangle", icon="META_PLANE").type='RECTANGLE' + layout.operator( + "object.create", text="Rectangle", icon="META_PLANE" + ).type='RECTANGLE' - layout.operator("object.create", - text="Circle", icon="MESH_CIRCLE").type='CIRCLE' + layout.operator( + "object.create", text="Circle", icon="MESH_CIRCLE" + ).type='CIRCLE' - layout.operator("object.create", - text="Ellipse", icon="MESH_CAPSULE").type='ELLIPSE' + layout.operator( + "object.create", text="Ellipse", icon="MESH_CAPSULE" + ).type='ELLIPSE' - layout.operator("object.create", - text="Arc", icon="SPHERECURVE").type='ARC' + layout.operator( + "object.create", text="Arc", icon="SPHERECURVE" + ).type='ARC' - layout.operator("object.create", - text="Donut", icon="MESH_CIRCLE").type='DONUT' + layout.operator( + "object.create", text="Donut", icon="MESH_CIRCLE" + ).type='DONUT' - layout.operator("object.create", - text="Ngon", icon="SEQ_CHROMA_SCOPE").type='NGON' + layout.operator( + "object.create", text="Ngon", icon="SEQ_CHROMA_SCOPE" + ).type='NGON' - layout.operator("object.create", - text="Start", icon="SOLO_OFF").type='STAR' + layout.operator( + "object.create", text="Start", icon="SOLO_OFF" + ).type='STAR' - layout.operator("object.create", - text="TorusKnot", icon="HAND").type='TORUSKNOT' + layout.operator( + "object.create", text="TorusKnot", icon="HAND" + ).type='TORUSKNOT' - layout.operator("object.create", - text="Helix", icon="MOD_SCREW").type='HELIX' + layout.operator( + "object.create", text="Helix", icon="MOD_SCREW" + ).type='HELIX' - layout.operator("object.create", - text="Profilo", icon="MOD_BOOLEAN").type='PROFILO' + layout.operator( + "object.create", text="Profilo", icon="MOD_BOOLEAN" + ).type='PROFILO' diff --git a/primitive/metaball.py b/primitive/metaball.py index 281338d..6544fee 100644 --- a/primitive/metaball.py +++ b/primitive/metaball.py @@ -38,7 +38,7 @@ def update(self): pass def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) def finish(self): pass diff --git a/primitive/monkey.py b/primitive/monkey.py index 989b9ca..0dfb3f2 100644 --- a/primitive/monkey.py +++ b/primitive/monkey.py @@ -309,7 +309,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/ngon.py b/primitive/ngon.py index d200ecd..62d0f9c 100644 --- a/primitive/ngon.py +++ b/primitive/ngon.py @@ -65,7 +65,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/oiltank.py b/primitive/oiltank.py index 7abecf3..7ddbb8a 100644 --- a/primitive/oiltank.py +++ b/primitive/oiltank.py @@ -174,7 +174,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/plane.py b/primitive/plane.py index 516f4c1..209def8 100644 --- a/primitive/plane.py +++ b/primitive/plane.py @@ -61,7 +61,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/primitive.py b/primitive/primitive.py index c617c9d..41f77ab 100644 --- a/primitive/primitive.py +++ b/primitive/primitive.py @@ -177,10 +177,12 @@ def ClearPrimitiveData(obj): # Overide mouse pointer def GetCursurMesh(size, x, y): - shape =((0.4, 0.0), (0.6, 0.0), (0.6, 0.4), - (1.0, 0.4), (1.0, 0.6), (0.6, 0.6), - (0.6, 1.0), (0.4, 1.0), (0.4, 0.6), - (0.0, 0.6), (0.0, 0.4), (0.4, 0.4)) + shape =( + (0.4, 0.0), (0.6, 0.0), (0.6, 0.4), + (1.0, 0.4), (1.0, 0.6), (0.6, 0.6), + (0.6, 1.0), (0.4, 1.0), (0.4, 0.6), + (0.0, 0.6), (0.0, 0.4), (0.4, 0.4) + ) verts = [] offset_x = x - size / 2 @@ -191,10 +193,12 @@ def GetCursurMesh(size, x, y): ypos = shape[i][1] * size + offset_y verts.append((xpos, ypos)) - faces =((0, 1, 11), (1, 2, 11), - (2, 3, 5), (3, 4, 5), - (5, 6, 7), (7, 8, 5), - (8, 9, 11), (11, 9, 10)) + faces =( + (0, 1, 11), (1, 2, 11), + (2, 3, 5), (3, 4, 5), + (5, 6, 7), (7, 8, 5), + (8, 9, 11), (11, 9, 10) + ) return verts, faces @@ -210,8 +214,14 @@ def DrawCursurOveride(self): shader.uniform_float("color",(0.8, 0.8, 0.8, 0.6)) batch.draw(shader) bgl.glDisable(bgl.GL_BLEND) + else: - pass + shader = gpu.shader.from_builtin(get_uniform_color(mode="2D")) + v,f = GetCursurMesh(20, self.mpos.x, self.mpos.y) + batch = batch_for_shader(shader, 'TRIS', {"pos":v}, indices=f) + shader.bind() + shader.uniform_float("color",(0.8, 0.8, 0.8, 0.6)) + batch.draw(shader) @@ -470,12 +480,14 @@ def modal(self, ctx, event): if self.use_gride: self.point_current.location = self.gride.get_click_point_gride(ctx, x, y) + elif self.use_surface: self.point_current.location = self.gride.get_click_point_surface(ctx, x, y) ################ self.localGride.matrix = self.gride.gride_matrix self.localGride.genarate_gride_lines() ################ + else: self.point_current.location = self.gride.get_click_point_gride(ctx, x, y) diff --git a/primitive/profilo.py b/primitive/profilo.py index 6039418..103aaf0 100644 --- a/primitive/profilo.py +++ b/primitive/profilo.py @@ -467,7 +467,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/pyramid.py b/primitive/pyramid.py index dde8495..6b9418f 100644 --- a/primitive/pyramid.py +++ b/primitive/pyramid.py @@ -164,7 +164,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/quadsphere.py b/primitive/quadsphere.py index c64ac61..6b5fd61 100644 --- a/primitive/quadsphere.py +++ b/primitive/quadsphere.py @@ -126,7 +126,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/rectangle.py b/primitive/rectangle.py index c9d9f0c..04b153b 100644 --- a/primitive/rectangle.py +++ b/primitive/rectangle.py @@ -69,7 +69,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/speaker.py b/primitive/speaker.py index c0fa21c..5dcebc3 100644 --- a/primitive/speaker.py +++ b/primitive/speaker.py @@ -24,7 +24,7 @@ def init(self): self.owner = None def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/sphere.py b/primitive/sphere.py index db249cb..f62ffda 100644 --- a/primitive/sphere.py +++ b/primitive/sphere.py @@ -183,7 +183,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/star.py b/primitive/star.py index 7a3c754..1a5f2b1 100644 --- a/primitive/star.py +++ b/primitive/star.py @@ -62,7 +62,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/surface.py b/primitive/surface.py index c43dec0..7787d94 100644 --- a/primitive/surface.py +++ b/primitive/surface.py @@ -46,8 +46,8 @@ def update(self, ctx): def abort(self): pass - # bpy.ops.object.delete({'selected_objects': [self.owner]}) - #self.reset() + # bpy.ops.object.delete(confirm=False) + # self.reset() diff --git a/primitive/teapot.py b/primitive/teapot.py index 75b316e..07b8fe8 100644 --- a/primitive/teapot.py +++ b/primitive/teapot.py @@ -246,7 +246,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/text.py b/primitive/text.py index a9b92c7..7617a26 100644 --- a/primitive/text.py +++ b/primitive/text.py @@ -29,7 +29,7 @@ def create(self, ctx): self.owner = ctx.active_object def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/torus.py b/primitive/torus.py index ce9ec2b..e3d0f9d 100644 --- a/primitive/torus.py +++ b/primitive/torus.py @@ -109,7 +109,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/torusknot.py b/primitive/torusknot.py index 5c10f93..fb47787 100644 --- a/primitive/torusknot.py +++ b/primitive/torusknot.py @@ -79,7 +79,7 @@ def update(self): self.update_curve(shapes) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/tube.py b/primitive/tube.py index a748659..0be05b7 100644 --- a/primitive/tube.py +++ b/primitive/tube.py @@ -224,7 +224,7 @@ def update(self): self.update_mesh(mesh) def abort(self): - bpy.ops.object.delete({'selected_objects': [self.owner]}) + bpy.ops.object.delete(confirm=False) diff --git a/primitive/update.py b/primitive/update.py index 23d4bf0..6860dfc 100644 --- a/primitive/update.py +++ b/primitive/update.py @@ -15,10 +15,13 @@ import bpy -from bpy.types import PropertyGroup +from bpy.types import Operator, PropertyGroup from bpy.app.handlers import persistent -from bpy.props import (StringProperty, IntProperty, FloatProperty, - BoolProperty, EnumProperty, PointerProperty) + +from bpy.props import ( + StringProperty, IntProperty, FloatProperty, + BoolProperty, EnumProperty, PointerProperty +) from .adaptive_plane import Adaptive_Plane from .box import Box @@ -111,6 +114,7 @@ def primitive_frame_update(scene): for data in bpy.data.meshes: if data.primitivedata.animatable: update(data) + for data in bpy.data.curves: if data.primitivedata.animatable: update(data) @@ -118,11 +122,15 @@ def primitive_frame_update(scene): class Primitive_Option(PropertyGroup): - draw_mode: EnumProperty(name='Draw Mode', default='FLOOR', + draw_mode: EnumProperty( + name='Draw Mode', default='FLOOR', update = primitive_update, - items =[('FLOOR', 'Draw on Floor', ''), + items =[ + ('FLOOR', 'Draw on Floor', ''), ('VIEW', 'Draw on View', ''), - ('SURFACE', 'Draw on Surface', '')]) + ('SURFACE', 'Draw on Surface', '') + ] + ) @@ -185,9 +193,11 @@ class PrimitiveData(PropertyGroup): # Profile ############################################### - profilo_mode: EnumProperty(name='Shape', default='Angle', + profilo_mode: EnumProperty( + name='Shape', default='Angle', update = primitive_update, - items =[('Angle', 'Angle', ''), + items =[ + ('Angle', 'Angle', ''), ('Bar', 'Bar', ''), ('Channel', 'Channel', ''), ('Cylinder', 'Cylinder', ''), @@ -195,362 +205,431 @@ class PrimitiveData(PropertyGroup): ('Tee', 'Tee', ''), ('Tube', 'Tube', ''), ('Width_flange', 'Width_flange', ''), - ('Elipse', 'Elipse', '')]) + ('Elipse', 'Elipse', '') + ] + ) - extrude_segmode: EnumProperty(name='Segment Type', default='Curve', + extrude_segmode: EnumProperty( + name='Segment Type', default='Curve', update = primitive_update, - items =[('Curve', 'Curve', ''), + items =[ + ('Curve', 'Curve', ''), ('Manual', 'Manual', ''), ('Optimized', 'Optimized', ''), - ('Adaptive', 'Adaptive', '')]) + ('Adaptive', 'Adaptive', '') + ] + ) # BoltFactory ############################################# MAX_INPUT_NUMBER = 50 - Bolt : BoolProperty(name="Bolt", update = primitive_update, - default=True, description="Bolt" + Bolt : BoolProperty( + name="Bolt", + update = primitive_update, + default=True, + description="Bolt" ) - change : BoolProperty(name = "Change", update = primitive_update, - default = False, - description = "change Bolt" + change : BoolProperty( + name = "Change", + update = primitive_update, + default = False, + description = "change Bolt" ) # Model Types - Model_Type_List = [('bf_Model_Bolt', 'BOLT', 'Bolt Model'), - ('bf_Model_Nut', 'NUT', 'Nut Model') - ] + Model_Type_List = [ + ('bf_Model_Bolt', 'BOLT', 'Bolt Model'), + ('bf_Model_Nut', 'NUT', 'Nut Model') + ] + bf_Model_Type: EnumProperty( - attr='bf_Model_Type', - name='Model', - update = primitive_update, - description='Choose the type off model you would like', - items=Model_Type_List, default='bf_Model_Bolt' - ) + attr='bf_Model_Type', + name='Model', + update = primitive_update, + description='Choose the type off model you would like', + items=Model_Type_List, default='bf_Model_Bolt' + ) + # Head Types - Model_Type_List = [('bf_Head_Hex', 'HEX', 'Hex Head'), - ('bf_Head_12Pnt', '12 POINT', '12 Point Head'), - ('bf_Head_Cap', 'CAP', 'Cap Head'), - ('bf_Head_Dome', 'DOME', 'Dome Head'), - ('bf_Head_Pan', 'PAN', 'Pan Head'), - ('bf_Head_CounterSink', 'COUNTER SINK', 'Counter Sink Head') - ] + Model_Type_List = [ + ('bf_Head_Hex', 'HEX', 'Hex Head'), + ('bf_Head_12Pnt', '12 POINT', '12 Point Head'), + ('bf_Head_Cap', 'CAP', 'Cap Head'), + ('bf_Head_Dome', 'DOME', 'Dome Head'), + ('bf_Head_Pan', 'PAN', 'Pan Head'), + ('bf_Head_CounterSink', 'COUNTER SINK', 'Counter Sink Head') + ] + bf_Head_Type: EnumProperty( - attr='bf_Head_Type', - name='Head', - update = primitive_update, - description='Choose the type off Head you would like', - items=Model_Type_List, default='bf_Head_Hex' - ) + attr='bf_Head_Type', + name='Head', + update = primitive_update, + description='Choose the type off Head you would like', + items=Model_Type_List, default='bf_Head_Hex' + ) + # Bit Types - Bit_Type_List = [('bf_Bit_None', 'NONE', 'No Bit Type'), - ('bf_Bit_Allen', 'ALLEN', 'Allen Bit Type'), - ('bf_Bit_Torx', 'TORX', 'Torx Bit Type'), - ('bf_Bit_Philips', 'PHILLIPS', 'Phillips Bit Type') - ] + Bit_Type_List = [ + ('bf_Bit_None', 'NONE', 'No Bit Type'), + ('bf_Bit_Allen', 'ALLEN', 'Allen Bit Type'), + ('bf_Bit_Torx', 'TORX', 'Torx Bit Type'), + ('bf_Bit_Philips', 'PHILLIPS', 'Phillips Bit Type') + ] + bf_Bit_Type: EnumProperty( - attr='bf_Bit_Type', - name='Bit Type', - update = primitive_update, - description='Choose the type of bit to you would like', - items=Bit_Type_List, default='bf_Bit_None' - ) + attr='bf_Bit_Type', + name='Bit Type', + update = primitive_update, + description='Choose the type of bit to you would like', + items=Bit_Type_List, default='bf_Bit_None' + ) + # Nut Types - Nut_Type_List = [('bf_Nut_Hex', 'HEX', 'Hex Nut'), - ('bf_Nut_Lock', 'LOCK', 'Lock Nut'), - ('bf_Nut_12Pnt', '12 POINT', '12 Point Nut') - ] + Nut_Type_List = [ + ('bf_Nut_Hex', 'HEX', 'Hex Nut'), + ('bf_Nut_Lock', 'LOCK', 'Lock Nut'), + ('bf_Nut_12Pnt', '12 POINT', '12 Point Nut') + ] + bf_Nut_Type: EnumProperty( - attr='bf_Nut_Type', - name='Nut Type', - update = primitive_update, - description='Choose the type of nut you would like', - items=Nut_Type_List, default='bf_Nut_Hex' - ) + attr='bf_Nut_Type', + name='Nut Type', + update = primitive_update, + description='Choose the type of nut you would like', + items=Nut_Type_List, + default='bf_Nut_Hex' + ) + # Shank Types bf_Shank_Length: FloatProperty( - attr='bf_Shank_Length', - name='Shank Length', default=0, - update = primitive_update, - min=0, soft_min=0, max=MAX_INPUT_NUMBER, - description='Length of the unthreaded shank', - unit='LENGTH', - ) + attr='bf_Shank_Length', + name='Shank Length', default=0, + update = primitive_update, + min=0, soft_min=0, max=MAX_INPUT_NUMBER, + description='Length of the unthreaded shank', + unit='LENGTH' + ) + bf_Shank_Dia: FloatProperty( - attr='bf_Shank_Dia', - name='Shank Dia', default=3, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - update = primitive_update, - description='Diameter of the shank', - unit='LENGTH', - ) + attr='bf_Shank_Dia', + name='Shank Dia', default=3, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + update = primitive_update, + description='Diameter of the shank', + unit='LENGTH' + ) + bf_Phillips_Bit_Depth: FloatProperty( - attr='bf_Phillips_Bit_Depth', - name='Bit Depth', default=1.1431535482406616, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - update = primitive_update, - description='Depth of the Phillips Bit', - unit='LENGTH', - ) + attr='bf_Phillips_Bit_Depth', + name='Bit Depth', default=1.1431535482406616, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + update = primitive_update, + description='Depth of the Phillips Bit', + unit='LENGTH' + ) + bf_Allen_Bit_Depth: FloatProperty( - attr='bf_Allen_Bit_Depth', - name='Bit Depth', default=1.5, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - update = primitive_update, - description='Depth of the Allen Bit', - unit='LENGTH', - ) + attr='bf_Allen_Bit_Depth', + name='Bit Depth', default=1.5, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + update = primitive_update, + description='Depth of the Allen Bit', + unit='LENGTH' + ) + bf_Allen_Bit_Flat_Distance: FloatProperty( - attr='bf_Allen_Bit_Flat_Distance', - name='Flat Dist', default=2.5, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - update = primitive_update, - description='Flat Distance of the Allen Bit', - unit='LENGTH', - ) + attr='bf_Allen_Bit_Flat_Distance', + name='Flat Dist', default=2.5, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + update = primitive_update, + description='Flat Distance of the Allen Bit', + unit='LENGTH' + ) + # Torx Size Types - Torx_Size_Type_List = [('bf_Torx_T10', 'T10', 'T10'), - ('bf_Torx_T20', 'T20', 'T20'), - ('bf_Torx_T25', 'T25', 'T25'), - ('bf_Torx_T30', 'T30', 'T30'), - ('bf_Torx_T40', 'T40', 'T40'), - ('bf_Torx_T50', 'T50', 'T50'), - ('bf_Torx_T55', 'T55', 'T55'), - ] + Torx_Size_Type_List = [ + ('bf_Torx_T10', 'T10', 'T10'), + ('bf_Torx_T20', 'T20', 'T20'), + ('bf_Torx_T25', 'T25', 'T25'), + ('bf_Torx_T30', 'T30', 'T30'), + ('bf_Torx_T40', 'T40', 'T40'), + ('bf_Torx_T50', 'T50', 'T50'), + ('bf_Torx_T55', 'T55', 'T55') + ] bf_Torx_Size_Type: EnumProperty( - attr='bf_Torx_Size_Type', - name='Torx Size', - update = primitive_update, - description='Size of the Torx Bit', - items=Torx_Size_Type_List, default='bf_Torx_T20' - ) + attr='bf_Torx_Size_Type', + name='Torx Size', + update = primitive_update, + description='Size of the Torx Bit', + items=Torx_Size_Type_List, + default='bf_Torx_T20' + ) + bf_Torx_Bit_Depth: FloatProperty( - attr='bf_Torx_Bit_Depth', - name='Bit Depth', default=1.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Depth of the Torx Bit', - unit='LENGTH', - ) + attr='bf_Torx_Bit_Depth', + name='Bit Depth', default=1.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Depth of the Torx Bit', + unit='LENGTH' + ) + bf_Hex_Head_Height: FloatProperty( - attr='bf_Hex_Head_Height', - name='Head Height', default=2, - update = primitive_update, - min=0, soft_min=0, max=MAX_INPUT_NUMBER, - description='Height of the Hex Head', - unit='LENGTH', - ) + attr='bf_Hex_Head_Height', + name='Head Height', default=2, + update = primitive_update, + min=0, soft_min=0, max=MAX_INPUT_NUMBER, + description='Height of the Hex Head', + unit='LENGTH' + ) + bf_Hex_Head_Flat_Distance: FloatProperty( - attr='bf_Hex_Head_Flat_Distance', - name='Flat Dist', default=5.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Flat Distance of the Hex Head', - unit='LENGTH', - ) + attr='bf_Hex_Head_Flat_Distance', + name='Flat Dist', default=5.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Flat Distance of the Hex Head', + unit='LENGTH' + ) + bf_12_Point_Head_Height: FloatProperty( - attr='bf_12_Point_Head_Height', - name='Head Height', default=3.0, - update = primitive_update, - min=0, soft_min=0, max=MAX_INPUT_NUMBER, - description='Height of the 12 Point Head', - unit='LENGTH', - ) + attr='bf_12_Point_Head_Height', + name='Head Height', default=3.0, + update = primitive_update, + min=0, soft_min=0, max=MAX_INPUT_NUMBER, + description='Height of the 12 Point Head', + unit='LENGTH' + ) + bf_12_Point_Head_Flat_Distance: FloatProperty( - attr='bf_12_Point_Head_Flat_Distance', - name='Flat Dist', default=3.0, - update = primitive_update, - min=0.001, soft_min=0, #limit to 0.001 to avoid calculation error - max=MAX_INPUT_NUMBER, - description='Flat Distance of the 12 Point Head', - unit='LENGTH', - ) + attr='bf_12_Point_Head_Flat_Distance', + name='Flat Dist', default=3.0, + update = primitive_update, + min=0.001, soft_min=0, #limit to 0.001 to avoid calculation error + max=MAX_INPUT_NUMBER, + description='Flat Distance of the 12 Point Head', + unit='LENGTH' + ) + bf_12_Point_Head_Flange_Dia: FloatProperty( - attr='bf_12_Point_Head_Flange_Dia', - name='12 Point Head Flange Dia', default=5.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Flange diameter of the 12 point Head', - unit='LENGTH', - ) + attr='bf_12_Point_Head_Flange_Dia', + name='12 Point Head Flange Dia', default=5.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Flange diameter of the 12 point Head', + unit='LENGTH' + ) + bf_CounterSink_Head_Dia: FloatProperty( - attr='bf_CounterSink_Head_Dia', - name='Head Dia', default=6.300000190734863, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Diameter of the Counter Sink Head', - unit='LENGTH', - ) + attr='bf_CounterSink_Head_Dia', + name='Head Dia', default=6.300000190734863, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Diameter of the Counter Sink Head', + unit='LENGTH' + ) + bf_Cap_Head_Height: FloatProperty( - attr='bf_Cap_Head_Height', - name='Head Height', default=3, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Height of the Cap Head', - unit='LENGTH', - ) + attr='bf_Cap_Head_Height', + name='Head Height', default=3, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Height of the Cap Head', + unit='LENGTH' + ) + bf_Cap_Head_Dia: FloatProperty( - attr='bf_Cap_Head_Dia', - name='Head Dia', default=5.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Diameter of the Cap Head', - unit='LENGTH', - ) + attr='bf_Cap_Head_Dia', + name='Head Dia', default=5.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Diameter of the Cap Head', + unit='LENGTH' + ) + bf_Dome_Head_Dia: FloatProperty( - attr='bf_Dome_Head_Dia', - name='Dome Head Dia', default=5.599999904632568, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Length of the unthreaded shank', - unit='LENGTH', - ) + attr='bf_Dome_Head_Dia', + name='Dome Head Dia', default=5.599999904632568, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Length of the unthreaded shank', + unit='LENGTH' + ) + bf_Pan_Head_Dia: FloatProperty( - attr='bf_Pan_Head_Dia', - name='Pan Head Dia', default=5.599999904632568, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Diameter of the Pan Head', - unit='LENGTH', - ) + attr='bf_Pan_Head_Dia', + name='Pan Head Dia', default=5.599999904632568, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Diameter of the Pan Head', + unit='LENGTH' + ) bf_Philips_Bit_Dia: FloatProperty( - attr='bf_Philips_Bit_Dia', - name='Bit Dia', default=1.8199999332427979, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Diameter of the Philips Bit', - unit='LENGTH', - ) + attr='bf_Philips_Bit_Dia', + name='Bit Dia', default=1.8199999332427979, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Diameter of the Philips Bit', + unit='LENGTH' + ) bf_Thread_Length: FloatProperty( - attr='bf_Thread_Length', - name='Thread Length', default=6, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Length of the Thread', - unit='LENGTH', - ) + attr='bf_Thread_Length', + name='Thread Length', default=6, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Length of the Thread', + unit='LENGTH' + ) bf_Major_Dia: FloatProperty( - attr='bf_Major_Dia', - name='Major Dia', default=3, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Outside diameter of the Thread', - unit='LENGTH', - ) + attr='bf_Major_Dia', + name='Major Dia', default=3, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Outside diameter of the Thread', + unit='LENGTH' + ) bf_Pitch: FloatProperty( - attr='bf_Pitch', - name='Pitch', default=0.3499999940395355, - update = primitive_update, - min=0.1, soft_min=0.1, - max=7.0, - description='Pitch if the thread', - unit='LENGTH', - ) + attr='bf_Pitch', + name='Pitch', default=0.3499999940395355, + update = primitive_update, + min=0.1, soft_min=0.1, + max=7.0, + description='Pitch if the thread', + unit='LENGTH' + ) + bf_Minor_Dia: FloatProperty( - attr='bf_Minor_Dia', - name='Minor Dia', default=2.6211137771606445, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Inside diameter of the Thread', - unit='LENGTH', - ) + attr='bf_Minor_Dia', + name='Minor Dia', default=2.6211137771606445, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Inside diameter of the Thread', + unit='LENGTH' + ) + bf_Crest_Percent: IntProperty( - attr='bf_Crest_Percent', - name='Crest Percent', default=10, - update = primitive_update, - min=1, soft_min=1, - max=90, - description='Percent of the pitch that makes up the Crest', - ) + attr='bf_Crest_Percent', + name='Crest Percent', default=10, + update = primitive_update, + min=1, soft_min=1, + max=90, + description='Percent of the pitch that makes up the Crest' + ) + bf_Root_Percent: IntProperty( - attr='bf_Root_Percent', - name='Root Percent', default=10, - update = primitive_update, - min=1, soft_min=1, - max=90, - description='Percent of the pitch that makes up the Root', - ) + attr='bf_Root_Percent', + name='Root Percent', default=10, + update = primitive_update, + min=1, soft_min=1, + max=90, + description='Percent of the pitch that makes up the Root' + ) + bf_Div_Count: IntProperty( - attr='bf_Div_Count', - name='Div count', default=36, - update = primitive_update, - min=4, soft_min=4, - max=4096, - description='Div count determine circle resolution', - ) + attr='bf_Div_Count', + name='Div count', default=36, + update = primitive_update, + min=4, soft_min=4, + max=4096, + description='Div count determine circle resolution' + ) + bf_Hex_Nut_Height: FloatProperty( - attr='bf_Hex_Nut_Height', - name='Hex Nut Height', default=2.4000000953674316, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Height of the Hex Nut', - unit='LENGTH', - ) + attr='bf_Hex_Nut_Height', + name='Hex Nut Height', default=2.4000000953674316, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Height of the Hex Nut', + unit='LENGTH' + ) + bf_Hex_Nut_Flat_Distance: FloatProperty( - attr='bf_Hex_Nut_Flat_Distance', - name='Hex Nut Flat Dist', default=5.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Flat distance of the Hex Nut', - unit='LENGTH', - ) + attr='bf_Hex_Nut_Flat_Distance', + name='Hex Nut Flat Dist', default=5.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Flat distance of the Hex Nut', + unit='LENGTH' + ) + bf_12_Point_Nut_Height: FloatProperty( - attr='bf_12_Point_Nut_Height', - name='12 Point Nut Height', default=2.4000000953674316, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Height of the 12 Point Nut', - unit='LENGTH', - ) + attr='bf_12_Point_Nut_Height', + name='12 Point Nut Height', default=2.4000000953674316, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Height of the 12 Point Nut', + unit='LENGTH' + ) bf_12_Point_Nut_Flat_Distance: FloatProperty( - attr='bf_12_Point_Nut_Flat_Distance', - name='12 Point Nut Flat Dist', default=3.0, - update = primitive_update, - min=0.001, soft_min=0, #limit to 0.001 to avoid calculation error - max=MAX_INPUT_NUMBER, - description='Flat distance of the 12 point Nut', - unit='LENGTH', - ) + attr='bf_12_Point_Nut_Flat_Distance', + name='12 Point Nut Flat Dist', default=3.0, + update = primitive_update, + min=0.001, soft_min=0, #limit to 0.001 to avoid calculation error + max=MAX_INPUT_NUMBER, + description='Flat distance of the 12 point Nut', + unit='LENGTH' + ) + bf_12_Point_Nut_Flange_Dia: FloatProperty( - attr='bf_12_Point_Nut_Flange_Dia', - name='12 Point Nut Flange Dia', default=5.5, - update = primitive_update, - min=0, soft_min=0, - max=MAX_INPUT_NUMBER, - description='Flange diameter of the 12 point Nut', - unit='LENGTH', - ) + attr='bf_12_Point_Nut_Flange_Dia', + name='12 Point Nut Flange Dia', default=5.5, + update = primitive_update, + min=0, soft_min=0, + max=MAX_INPUT_NUMBER, + description='Flange diameter of the 12 point Nut', + unit='LENGTH' + ) # End of Bolt factory ################################################### +class BsMax_OT_Update_Primitive_Geometry(Operator): + # TODO replace this with a smart convert tool + bl_idname="primitive.update" + bl_label="Update Primitive Mesh/Curve" + def execute(self, ctx): + for obj in ctx.selected_objects: + update(obj.data) + # objClassName = obj.data.primitivedata.classname + # if not objClassName: + # continue + + # subclass = get_class(objClassName) + # if subclass: + # subclass.data = ctx.object.data + # subclass.update() + return {"FINISHED"} + + + def register_update(): if hasattr(bpy.types.Mesh, 'primitivedata') or \ hasattr(bpy.types.Curve, 'primitivedata'): @@ -564,14 +643,19 @@ def register_update(): """ pass if it is allready exist and do not need to add again """ bpy.types.Scene.primitive_setting = PointerProperty( - type=Primitive_Option, - name='Primitive settings' - ) + type=Primitive_Option, + name='Primitive settings' + ) + bpy.types.Mesh.primitivedata = PointerProperty(type=PrimitiveData) bpy.types.Curve.primitivedata = PointerProperty(type=PrimitiveData) bpy.app.handlers.frame_change_post.append(primitive_frame_update) + + bpy.utils.register_class(BsMax_OT_Update_Primitive_Geometry) def unregister_update(): + bpy.utils.unregister_class(BsMax_OT_Update_Primitive_Geometry) + del bpy.types.Mesh.primitivedata del bpy.types.Curve.primitivedata del bpy.types.Scene.primitive_setting diff --git a/tools/internal/camera/target_camera.py b/tools/internal/camera/target_camera.py index 4874261..ee17718 100644 --- a/tools/internal/camera/target_camera.py +++ b/tools/internal/camera/target_camera.py @@ -65,7 +65,11 @@ def execute(self, ctx): cam.data.dof.driver_remove('aperture_fstop') transfoem = cam.matrix_world.copy() targ = cam.constraints["Track To"].target - bpy.ops.object.delete({'selected_objects': [targ]}) + + bpy.ops.object.select_all(action='DESELECT') + targ.select_set(True) + bpy.ops.object.delete(confirm=False) + TrackToConts = [ c for c in cam.constraints if c.type == 'TRACK_TO' ] for c in TrackToConts: cam.constraints.remove(c) diff --git a/tools/internal/ligth/target_light.py b/tools/internal/ligth/target_light.py index 9a8b456..c496c31 100644 --- a/tools/internal/ligth/target_light.py +++ b/tools/internal/ligth/target_light.py @@ -61,7 +61,11 @@ def execute(self, ctx): obj = ctx.active_object transfoem = obj.matrix_world.copy() targ = obj.constraints['Track To'].target - bpy.ops.object.delete({'selected_objects': [targ]}) + + bpy.ops.object.select_all(action='DESELECT') + targ.select_set(True) + bpy.ops.object.delete(confirm=False) + TrackToConts = [ c for c in obj.constraints if c.type == 'TRACK_TO' ] for c in TrackToConts: diff --git a/tools/internal/mesh/weld.py b/tools/internal/mesh/weld.py index e0eba4e..abccb85 100644 --- a/tools/internal/mesh/weld.py +++ b/tools/internal/mesh/weld.py @@ -16,7 +16,7 @@ import bpy from bpy.types import Operator, Menu from bpy.props import FloatProperty, BoolProperty -from bsmax.graphic import register_line, unregister_line +from bsmax.graphic import Rubber_Band # TARGET WELD # Original Coded from Stromberg90 updated by Nevil @@ -25,12 +25,9 @@ #TODO Target weld for edge mode same as vertex by face orient order -def SelectVert(ctx, event, started): - coord = event.mouse_region_x, event.mouse_region_y - if started: - result = bpy.ops.view3d.select(extend=True,location=coord) - else: - result = bpy.ops.view3d.select(extend=False,location=coord) +def select_vert(ctx, event, started): + coord = (event.mouse_region_x, event.mouse_region_y) + result = bpy.ops.view3d.select(extend=started, location=coord) if result == {'PASS_THROUGH'}: bpy.ops.mesh.select_all(action='DESELECT') @@ -44,6 +41,8 @@ class Mesh_OT_Target_Weld(Operator): start, end, handle = None, None, None drag, picked = False, False + rb = Rubber_Band() + def modal(self, ctx, event): ctx.area.tag_redraw() if not event.type in {'LEFTMOUSE','RIGHTMOUSE', 'MOUSEMOVE','ESC'}: @@ -52,6 +51,9 @@ def modal(self, ctx, event): elif event.type == 'MOUSEMOVE': if self.start != None: self.end = event.mouse_region_x, event.mouse_region_y + sx, sy = self.start + ex, ey = self.end + self.rb.create(sx, sy, ex, ey) elif event.type == 'LEFTMOUSE': if event.value == 'PRESS': @@ -69,15 +71,17 @@ def modal(self, ctx, event): # bm = bmesh.from_edit_mesh(mesh) # bm.verts[index].co - SelectVert(ctx, event, self.start != None) + select_vert(ctx, event, self.start != None) if ctx.object.data.total_vert_sel == 2: self.start = self.end = None bpy.ops.mesh.merge(type='LAST') bpy.ops.mesh.select_all(action='DESELECT') + self.rb.create(0, 0, 0, 0) return {'RUNNING_MODAL'} + elif event.type in {'RIGHTMOUSE','ESC'}: - unregister_line(self.handle) + self.rb.unregister() return {'CANCELLED'} return {'RUNNING_MODAL'} @@ -88,7 +92,7 @@ def execute(self,ctx): def invoke(self, ctx, event): if ctx.space_data.type == 'VIEW_3D': - self.handle = register_line(ctx, self, '2d', (1, 0.5, 0.5, 1)) + self.rb.register() ctx.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} return {'CANCELLED'} @@ -120,9 +124,11 @@ def draw(self, ctx): layout.prop(self, 'use_sharp_edge') def execute(self,ctx): - bpy.ops.mesh.remove_doubles(threshold=self.threshold, + bpy.ops.mesh.remove_doubles( + threshold=self.threshold, use_unselected=self.use_unselected, - use_sharp_edge_from_normals=self.use_sharp_edge) + use_sharp_edge_from_normals=self.use_sharp_edge + ) return{"FINISHED"} def invoke(self, ctx, event): diff --git a/tools/internal/object/create.py b/tools/internal/object/create.py index f7fbe8b..5ec3ea4 100644 --- a/tools/internal/object/create.py +++ b/tools/internal/object/create.py @@ -46,31 +46,31 @@ def add_parametric_primitive(type, ctx): primitiveClasses = { - 'BOX':Box(), - 'BOLT':Bolt(), - 'CAPSULE':Capsule(), - 'CYLINDER':Cylinder(), - 'CONE':Cone(), - 'ICOSPHERE':Icosphere(), - 'MONKEY':Monkey(), - 'OILTANK':OilTank(), - 'PLANE':Plane(), - 'PYRAMID':Pyramid(), - 'SPHERE':Sphere(), - 'TEAPOT':Teapot(), - 'TORUS':Torus(), - 'TORUSKNOT':TorusKnot(), - 'QUADSPHERE':QuadSphere(), - 'TUBE':Tube(), - 'ARC':Arc(), - 'CIRCLE':Circle(), - 'DONUT':Donut(), - 'ELLIPSE':Ellipse(), - 'HELIX':Helix(), - 'NGON':NGon(), - 'PROFILO': Profilo(), - 'RECTANGLE':Rectangle(), - 'STAR':Star() + 'BOX':Box(), + 'BOLT':Bolt(), + 'CAPSULE':Capsule(), + 'CYLINDER':Cylinder(), + 'CONE':Cone(), + 'ICOSPHERE':Icosphere(), + 'MONKEY':Monkey(), + 'OILTANK':OilTank(), + 'PLANE':Plane(), + 'PYRAMID':Pyramid(), + 'SPHERE':Sphere(), + 'TEAPOT':Teapot(), + 'TORUS':Torus(), + 'TORUSKNOT':TorusKnot(), + 'QUADSPHERE':QuadSphere(), + 'TUBE':Tube(), + 'ARC':Arc(), + 'CIRCLE':Circle(), + 'DONUT':Donut(), + 'ELLIPSE':Ellipse(), + 'HELIX':Helix(), + 'NGON':NGon(), + 'PROFILO': Profilo(), + 'RECTANGLE':Rectangle(), + 'STAR':Star() } obj = primitiveClasses[type] diff --git a/tools/internal/rigg/joystick.py b/tools/internal/rigg/joystick.py index 1cdfad2..2d9963b 100644 --- a/tools/internal/rigg/joystick.py +++ b/tools/internal/rigg/joystick.py @@ -20,8 +20,10 @@ from mathutils import Vector from bsmax.state import get_obj_class -from bsmax.actions import (set_origen, set_as_active_object, - catche_collection, move_to_collection) + +from bsmax.actions import ( + set_origen, set_as_active_object, catche_collection, move_to_collection +) @@ -66,7 +68,9 @@ def create_rectangle_frame_Mesh(ctx, mode, rectangle): name = "Joystic_Frame_" + str(mode) + "_" + str(width) + "X" + str(length) if name in bpy.data.objects: - bpy.ops.object.delete({'selected_objects': [rectangle]}) + bpy.ops.object.select_all(action='DESELECT') + rectangle.select_set(True) + bpy.ops.object.delete(confirm=False) return bpy.data.objects[name] rectangle.name = name @@ -166,12 +170,18 @@ def create_armature(ctx, name, frame_mesh, joy_mesh, joystick.location = frame_mesh.location joystick.data.bones['Frame'].use_deform = False joystick.pose.bones['Frame'].custom_shape = frame_mesh - joystick.pose.bones['Frame'].custom_shape_scale_xyz = [frame_radius, frame_radius, 1] + + joystick.pose.bones['Frame'].custom_shape_scale_xyz = [ + frame_radius, frame_radius, 1 + ] if joy_mesh: joystick.data.bones['Joy'].use_deform = False joystick.pose.bones['Joy'].custom_shape = joy_mesh - joystick.pose.bones['Joy'].custom_shape_scale_xyz = [joy_radius, joy_radius, 1] + + joystick.pose.bones['Joy'].custom_shape_scale_xyz = [ + joy_radius, joy_radius, 1 + ] set_as_active_object(ctx, joystick) @@ -195,11 +205,18 @@ def create_circle_joystick(ctx, circle, joy_type): joy_radius = get_handle_radius(circle, joy_type) name = circle.name - bpy.ops.object.delete({'selected_objects': [circle]}) + + bpy.ops.object.select_all(action='DESELECT') + circle.select_set(True) + bpy.ops.object.delete(confirm=False) + circle = catch_circilar_frame(ctx) joy_mesh = catche_joy_mesh(ctx) - joystick = create_armature(ctx, name, circle, joy_mesh, - frame_radius, joy_radius) + + joystick = create_armature( + ctx, name, circle, joy_mesh, frame_radius, joy_radius + ) + joystick.matrix_world = matrix_world match_transform(joystick, circle) diff --git a/tools/internal/scene/mdf.py b/tools/internal/scene/mdf.py new file mode 100644 index 0000000..e034d54 --- /dev/null +++ b/tools/internal/scene/mdf.py @@ -0,0 +1,307 @@ +############################################################################ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +############################################################################ + +import bpy +import os + +from math import radians +from bpy.types import Operator + + + +def clear_terminal(): + if os.name == "nt": + os.system("cls") + return + os.system("clear") + + + +class MDF: + def __init__(self, width, length): + self.width = width + self.length = length + self.front = False + self.back = False + self.left = False + self.right = False + self.count = 1 + self.owners = [] + + def set_band(self, front, back, left, right): + self.front = front + self.back = back + self.left = left + self.right = right + + def get_width_band_count(self): + count = 0 + if self.front: + count += 1 + if self.back: + count += 1 + return count + + def combine_owner(self, names): + for name in names: + if not name in self.owners: + self.owners.append(name) + + def get_length_band_count(self): + count = 0 + if self.left: + count += 1 + if self.right: + count += 1 + return count + + def to_string(self): + string = str(self.width) + string += " x " + string += str(self.length) + string += " * " + str(self.count) + string += " [" + if self.front: + string += "F" + if self.back: + string += "B" + if self.left: + string += "L" + if self.right: + string += "R" + string += "] " + for owner in self.owners: + string += owner + "," + return string + + def get_swaped_copy(self): + newMdf = MDF(self.length, self.width) + newMdf.front = self.left + newMdf.left = self.back + newMdf.back = self.right + newMdf.right = self.front + return newMdf + + def auto_align(self): + if self.length > self.width: + newMdf = self.get_swaped_copy() + self.width = newMdf.width + self.length = newMdf.length + self.front = newMdf.front + self.back = newMdf.back + self.left = newMdf.left + self.right = newMdf.right + + def compar(self, target): + acceptable = False + + if self.width == target.width and self.length == target.length: + acceptable = True + + if self.width == target.length and self.length == target.width: + acceptable = True + target = target.get_swaped_copy() + + if not acceptable: + return False + + if self.get_width_band_count() != target.get_width_band_count(): + return False + + if self.get_length_band_count() != target.get_length_band_count(): + return False + + return True + + + +def conver_to_unit(ctx, length): + length_unit = ctx.scene.unit_settings.length_unit + if length_unit == 'CENTIMETERS': + return round(length*100, 2) + + + +def get_instanses(obj): + return [target for target in bpy.data.objects if obj.data == target.data] + + + +def corect_rotations(ctx, objs): + bpy.ops.object.select_all(action='DESELECT') + + for obj in objs: + if obj.data.primitivedata['classname'] != 'Plane': + continue + + instanses = get_instanses(obj) + + width = float(obj.data.primitivedata.width) + length = float(obj.data.primitivedata.length) + + if length > width: + # swap size + obj.data.primitivedata.width = length + obj.data.primitivedata.length = width + + # rotate + for inst in instanses: + inst.select_set(True) + ctx.view_layer.objects.active = inst + inst.rotation_euler.rotate_axis("Z", radians(90)) + inst.select_set(False) + + + +def get_node_modifier(obj): + for modifier in obj.modifiers: + if modifier.type == 'NODES': + return modifier + return None + + + +def get_mdf_side_bands(nodes, mdf): + if not nodes: + return + + items_tree = nodes.node_group.interface.items_tree + if 'Front' in items_tree: + if nodes[items_tree['Front'].identifier]: + mdf.front = True + + if 'Back' in items_tree: + if nodes[items_tree['Back'].identifier]: + mdf.back = True + + if 'Left' in items_tree: + if nodes[items_tree['Left'].identifier]: + mdf.left = True + + if 'Right' in items_tree: + if nodes[items_tree['Right'].identifier]: + mdf.right = True + + + +def mdf_sort(mdfList): + newList, widthList = [], [] + for mdf in mdfList: + if not mdf.width in widthList: + widthList.append(mdf.width) + widthList.sort(reverse=True) + for width in widthList: + for mdf in reversed(mdfList): + if mdf.width >= width: + newList.append(mdf) + mdfList.remove(mdf) + return newList + + + +def get_owners(obj): + return [col.name for col in obj.users_collection] + + + +def mdf_print(ctx): + partList = [] + for mdf in ctx.selected_objects: + if mdf.data.primitivedata['classname'] != 'Plane': + continue + + width = float(mdf.data.primitivedata.width) + length = float(mdf.data.primitivedata.length) + + width = conver_to_unit(ctx, width) + length = conver_to_unit(ctx, length) + + newMdfPart = MDF(width, length) + newMdfPart.auto_align() + newMdfPart.owners = get_owners(mdf) + + geoNodes = get_node_modifier(mdf) + get_mdf_side_bands(geoNodes, newMdfPart) + + partList.append(newMdfPart) + + if not partList: + return + + printList = [] + while partList: + part = partList[0] + partList.remove(part) + + for mdf in reversed(partList): + if part.compar(mdf): + part.count += 1 + partList.remove(mdf) + part.combine_owner(mdf.owners) + + printList.append(part) + + printList = mdf_sort(printList) + + clear_terminal() + for part in printList: + print(part.to_string()) + print("") + + + +class Object_OT_MDF_Correct_Rotation(Operator): + bl_idname="mdf.correct_direction" + bl_label="MDF Correct Direction" + + def execute(self, ctx): + selection = ctx.selected_objects.copy() + corect_rotations(ctx, ctx.selected_objects) + for obj in selection: + obj.select_set(True) + return {"FINISHED"} + + + +class Object_OT_MDF_Print(Operator): + bl_idname="mdf.print" + bl_label="MDF Print" + + def execute(self, ctx): + mdf_print(ctx) + return {"FINISHED"} + + + +classes = ( + Object_OT_MDF_Correct_Rotation, + Object_OT_MDF_Print +) + + +def register_mdf(): + for c in classes: + bpy.utils.register_class(c) + + + +def unregister_mdf(): + for c in classes: + bpy.utils.unregister_class(c) + + + +if __name__ == "__main__": + register_mdf() diff --git a/tools/internal/transform/align_objects.py b/tools/internal/transform/align_objects.py index 596d21b..8f733a7 100644 --- a/tools/internal/transform/align_objects.py +++ b/tools/internal/transform/align_objects.py @@ -88,15 +88,19 @@ def get_bounding_box(self, obj): data = obj.data if obj.type == 'MESH': cld = [obj.matrix_world @ vert.co for vert in data.vertices] + elif obj.type == 'CURVE': for spn in data.splines: cld += [obj.matrix_world @ pts.co for pts in spn.bezier_points] + elif obj.type == 'SURFACE': for spn in data.splines: cld += [obj.matrix_world @ pts.co for pts in spn.points] + elif obj.type == 'FONT': for spn in data.splines: cld += [obj.matrix_world @ pts.co for pts in spn.bezier_points] + elif obj.type == 'ARMATURE': for bone in data.bones: cld.append(obj.matrix_world @ bone.head_local) @@ -329,25 +333,32 @@ def c_update(self, ctx, check): self.c_center = self.c_pivot = self.c_max = self.c_cursor = False public_option.current_mode = check update(self, ctx) + elif check == 'center' and self.c_center: self.c_min = self.c_pivot = self.c_max = self.c_cursor = False public_option.current_mode = check update(self, ctx) + elif check == 'pivot' and self.c_pivot: self.c_min = self.c_center = self.c_max = self.c_cursor = False public_option.current_mode = check update(self, ctx) + elif check == 'max' and self.c_max: self.c_min = self.c_center = self.c_pivot = self.c_cursor = False public_option.current_mode = check update(self, ctx) + elif check == 'cursor' and self.c_cursor: self.c_min = self.c_center = self.c_pivot = self.c_max = False public_option.current_mode = check update(self, ctx) - if not self.c_min and not self.c_center and not self.c_pivot and not self.c_max and not self.c_cursor: - if check == 'min': + if not self.c_min and not self.c_center and \ + not self.c_pivot and \ + not self.c_max and not self.c_cursor: + + if check == 'min': self.c_min = True elif check == 'center': self.c_center = True @@ -366,24 +377,31 @@ def t_update(self, ctx, check): self.t_center = self.t_pivot = self.t_max = self.t_cursor = False public_option.target_mode = check update(self, ctx) + elif check == 'center' and self.t_center: self.t_min = self.t_pivot = self.t_max = self.t_cursor = False public_option.target_mode = check update(self, ctx) + elif check == 'pivot' and self.t_pivot: self.t_min = self.t_center = self.t_max = self.t_cursor = False public_option.target_mode = check update(self, ctx) + elif check == 'max' and self.t_max: self.t_min = self.t_center = self.t_pivot = self.t_cursor = False public_option.target_mode = check update(self, ctx) + elif check == 'cursor' and self.t_cursor: self.t_min = self.t_center = self.t_pivot = self.t_max = False public_option.target_mode = check update(self, ctx) - if not self.t_min and not self.t_center and not self.t_pivot and not self.t_max and not self.t_cursor: + if not self.t_min and not self.t_center and \ + not self.t_pivot and \ + not self.t_max and not self.t_cursor: + if check == 'min': self.t_min = True elif check == 'center': @@ -405,12 +423,16 @@ class Object_OT_Align_Objects(Operator): def sub_target(self, ctx): if not align_abject.subtarget: return [('OBJECT', 'Object', '')] + if align_abject.subtarget.type == 'ARMATURE': return [('OBJECT', 'Armature', ''), ('SUB', 'Bone', '')] + elif align_abject.subtarget.type == 'CURVE': return [('OBJECT', 'Object', ''), ('SUB', 'Spline', '')] + elif align_abject.subtarget.type == 'MESH': return [('OBJECT', 'Object', ''), ('SUB', 'Vertex', '')] + return [('OBJECT', 'Object', '')] """ Props """ @@ -418,20 +440,25 @@ def sub_target(self, ctx): pos_y: BoolProperty(update=update) pos_z: BoolProperty(update=update) - c_min: BoolProperty(update=lambda self,ctx: c_update(self,ctx,'min')) - t_min: BoolProperty(update=lambda self,ctx: t_update(self,ctx,'min')) + c_min: BoolProperty(update=lambda self,ctx: c_update(self, ctx, 'min')) + t_min: BoolProperty(update=lambda self,ctx: t_update(self, ctx, 'min')) + + c_center: BoolProperty(update=lambda self,ctx: c_update(self, ctx, 'center')) + t_center: BoolProperty(update=lambda self,ctx: t_update(self, ctx, 'center')) - c_center: BoolProperty(update=lambda self,ctx: c_update(self,ctx,'center')) - t_center: BoolProperty(update=lambda self,ctx: t_update(self,ctx,'center')) + c_pivot: BoolProperty( + default=True, update=lambda self,ctx: c_update(self, ctx, 'pivot') + ) - c_pivot: BoolProperty(default=True, update=lambda self,ctx: c_update(self,ctx,'pivot')) - t_pivot: BoolProperty(default=True, update=lambda self,ctx: t_update(self,ctx,'pivot')) + t_pivot: BoolProperty( + default=True, update=lambda self,ctx: t_update(self, ctx, 'pivot') + ) - c_max: BoolProperty(update=lambda self,ctx: c_update(self,ctx,'max')) - t_max: BoolProperty(update=lambda self,ctx: t_update(self,ctx,'max')) + c_max: BoolProperty(update=lambda self,ctx: c_update(self, ctx, 'max')) + t_max: BoolProperty(update=lambda self,ctx: t_update(self, ctx, 'max')) - c_cursor: BoolProperty(update=lambda self,ctx: c_update(self,ctx,'cursor')) - t_cursor: BoolProperty(update=lambda self,ctx: t_update(self,ctx,'cursor')) + c_cursor: BoolProperty(update=lambda self,ctx: c_update(self, ctx, 'cursor')) + t_cursor: BoolProperty(update=lambda self,ctx: t_update(self, ctx, 'cursor')) target_type: EnumProperty(update=update, items=sub_target) @@ -443,8 +470,10 @@ def sub_target(self, ctx): scl_y: BoolProperty(update=update) scl_z: BoolProperty(update=update) - percent: FloatProperty(name="Percent", update=update, - soft_min=0, soft_max=1, default=1, step=0.1) + percent: FloatProperty( + name="Percent", update=update, + soft_min=0, soft_max=1, default=1, step=0.1 + ) ready: BoolProperty(default=False, description="freeze update till UI loaded") @@ -456,9 +485,9 @@ def draw(self, ctx): layout = self.layout box = layout.box() row = box.row() - row.prop(self,'pos_x',text='X Position') - row.prop(self,'pos_y',text='Y Position') - row.prop(self,'pos_z',text='Z Position') + row.prop(self, 'pos_x', text='X Position') + row.prop(self, 'pos_y', text='Y Position') + row.prop(self, 'pos_z', text='Z Position') col = box.column() row = col.row() box = row.box() @@ -472,6 +501,7 @@ def draw(self, ctx): box = row.box() col = box.column() col.label(text='Target Object') + if self.target_type == 'OBJECT': col.prop(self, 't_min', text='Minimum') col.prop(self, 't_center', text='Center') @@ -492,11 +522,13 @@ def draw(self, ctx): row.prop(self,'rot_x',text='X Rotation') row.prop(self,'rot_y',text='Y Rotation') row.prop(self,'rot_z',text='Z Rotation') + box = layout.box() row = box.row() row.prop(self,'scl_x',text='X Scale') row.prop(self,'scl_y',text='Y Scale') row.prop(self,'scl_z',text='Z Scale') + layout.prop(self, 'percent') def execute(self, ctx): diff --git a/tools/pipeline/__init__.py b/tools/pipeline/__init__.py index 6a4040a..b59019d 100644 --- a/tools/pipeline/__init__.py +++ b/tools/pipeline/__init__.py @@ -13,18 +13,23 @@ # along with this program. If not, see . ############################################################################ -from .make_ready_render import register_make_ready_render, unregister_make_ready_render -from .make_render_ready_nhj import register_make_ready_render_v2, unregister_make_ready_render_v2 +from .make_ready_render_v1 import ( + register_make_ready_render_v1, unregister_make_ready_render_v1 +) + +from .make_render_ready_v2 import ( + register_make_ready_render_v2, unregister_make_ready_render_v2 +) def register_pipeline(preferences): if preferences.nevil_stuff: - register_make_ready_render() + register_make_ready_render_v1() register_make_ready_render_v2() def unregister_pipeline(): - unregister_make_ready_render() + unregister_make_ready_render_v1() unregister_make_ready_render_v2() diff --git a/tools/pipeline/make_ready_render.py b/tools/pipeline/make_ready_render_v1.py similarity index 99% rename from tools/pipeline/make_ready_render.py rename to tools/pipeline/make_ready_render_v1.py index 88e0140..94cd925 100644 --- a/tools/pipeline/make_ready_render.py +++ b/tools/pipeline/make_ready_render_v1.py @@ -229,7 +229,7 @@ def light_check(): bpy.ops.object.select_all(action='DESELECT') for light in sun_lights: light.select_set(True) - bpy.ops.object.delete({'selected_objects': sun_lights}) + bpy.ops.object.delete(confirm=False) """ Set Sunlight settings """ if sun_light.name.lower() == 'sun': @@ -589,7 +589,7 @@ def execute(self, ctx): -def register_make_ready_render(): +def register_make_ready_render_v1(): try: bpy.utils.register_class(Render_OT_Make_Ready_Render) except: @@ -597,11 +597,11 @@ def register_make_ready_render(): -def unregister_make_ready_render(): +def unregister_make_ready_render_v1(): if hasattr(bpy.types, Render_OT_Make_Ready_Render.bl_idname): bpy.utils.unregister_class(Render_OT_Make_Ready_Render) if __name__ == '__main__': - register_make_ready_render() \ No newline at end of file + register_make_ready_render_v1() \ No newline at end of file diff --git a/tools/pipeline/make_render_ready_nhj.py b/tools/pipeline/make_render_ready_v2.py similarity index 100% rename from tools/pipeline/make_render_ready_nhj.py rename to tools/pipeline/make_render_ready_v2.py