From 200a9bbbd480251d774424700a424f105022535a Mon Sep 17 00:00:00 2001 From: lijenstina Date: Sat, 17 Jun 2017 02:09:38 +0200 Subject: Add Advanced Objects: Fix missing import, small cleanup Oscurart Chain Maker was missing from the menu init Small cleanup Remove unused imports Drop To Ground: fix a few issues with the object types crashes Better tooltips, logging and help description Clear the reported variable on reruns --- add_advanced_objects_menu/__init__.py | 12 +-- add_advanced_objects_menu/arrange_on_curve.py | 4 +- add_advanced_objects_panels/__init__.py | 27 +++-- add_advanced_objects_panels/delaunay_voronoi.py | 7 +- add_advanced_objects_panels/drop_to_ground.py | 109 +++++++++++++-------- .../object_laplace_lightning.py | 10 +- add_advanced_objects_panels/object_mangle_tools.py | 2 +- .../oscurart_constellation.py | 10 +- add_advanced_objects_panels/unfold_transition.py | 4 +- 9 files changed, 112 insertions(+), 73 deletions(-) diff --git a/add_advanced_objects_menu/__init__.py b/add_advanced_objects_menu/__init__.py index b1d86454..cacf8419 100644 --- a/add_advanced_objects_menu/__init__.py +++ b/add_advanced_objects_menu/__init__.py @@ -24,8 +24,8 @@ bl_info = { "name": "Add Advanced Objects", - "author": "Meta Androcto,", - "version": (0, 1, 3), + "author": "Meta Androcto", + "version": (0, 1, 4), "blender": (2, 78, 0), "location": "View3D > Add ", "description": "Add Object & Camera extras", @@ -44,6 +44,7 @@ if "bpy" in locals(): importlib.reload(trilighting) importlib.reload(pixelate_3d) importlib.reload(object_add_chain) + importlib.reload(oscurart_chain_maker) importlib.reload(circle_array) importlib.reload(copy2) importlib.reload(make_struts) @@ -63,6 +64,7 @@ else: from . import trilighting from . import pixelate_3d from . import object_add_chain + from . import oscurart_chain_maker from . import circle_array from . import copy2 from . import make_struts @@ -82,10 +84,8 @@ from bpy.types import ( ) from bpy.props import ( BoolProperty, - BoolVectorProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, StringProperty, PointerProperty, @@ -241,7 +241,6 @@ class AdvancedObjPreferences(AddonPreferences): box.label(text="Physics Tools:", icon="LAYER_ACTIVE") box.label(text="Drop to Ground, Wrecking Ball and Cloth Rope", icon="LAYER_USED") - icon_2 = "TRIA_RIGHT" if not self.show_panel_list else "TRIA_DOWN" box = layout.box() box.prop(self, "show_panel_list", emboss=False, icon=icon_2) @@ -250,7 +249,8 @@ class AdvancedObjPreferences(AddonPreferences): box.label(text="Panels located in 3D View Tools Region > Create", icon="LAYER_ACTIVE") box.label(text="CubeSter", icon="LAYER_USED") - + box.label(text="Duplicate on Curve (Shown if an Active Curve Object is it the 3D View)", + icon="LAYER_USED") # Cubester update functions diff --git a/add_advanced_objects_menu/arrange_on_curve.py b/add_advanced_objects_menu/arrange_on_curve.py index 14017480..b811263b 100644 --- a/add_advanced_objects_menu/arrange_on_curve.py +++ b/add_advanced_objects_menu/arrange_on_curve.py @@ -5,7 +5,7 @@ bl_info = { "author": "Mano-Wii", "version": (6, 3, 0), "blender": (2, 7, 7), - "location": "View3D > TOOLS", + "location": "3D View > Toolshelf > Create > Arrange on Curve", "description": "Arrange objects along a curve", "warning": "Select curve", "wiki_url": "", @@ -35,7 +35,7 @@ class PanelDupliCurve(Panel): bl_region_type = "TOOLS" bl_context = "objectmode" bl_category = "Create" - bl_label = "Duplicate on curve" + bl_label = "Arrange on Curve" bl_options = {'DEFAULT_CLOSED'} @classmethod diff --git a/add_advanced_objects_panels/__init__.py b/add_advanced_objects_panels/__init__.py index 81950727..439f9e41 100644 --- a/add_advanced_objects_panels/__init__.py +++ b/add_advanced_objects_panels/__init__.py @@ -24,20 +24,19 @@ bl_info = { "name": "Add Advanced Object Panels", - "author": "meta-androcto,", + "author": "meta-androcto", "version": (1, 1, 4), "blender": (2, 7, 7), "description": "Individual Create Panel Activation List", "location": "Addons Preferences", "warning": "", - "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" - "Scripts/3D_interaction/viewport_pies", + "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6" + "/Py/Scripts/Object/Add_Advanced", "category": "Object" } import bpy from bpy.types import ( - Menu, AddonPreferences, PropertyGroup, ) @@ -66,7 +65,7 @@ sub_modules = [__import__(__package__ + "." + submod, {}, {}, submod) for submod sub_modules.sort(key=lambda mod: (mod.bl_info['category'], mod.bl_info['name'])) -#Addons Preferences +# Add-ons Preferences def _get_pref_class(mod): import inspect @@ -160,7 +159,7 @@ class AdvancedObjPreferences1(AddonPreferences): split = col.row().split(percentage=0.15) split.label('Location:') split.label(info['location']) - if info.get('author') and info.get('author') != 'chromoly': + if info.get('author'): split = col.row().split(percentage=0.15) split.label('Author:') split.label(info['author']) @@ -195,12 +194,14 @@ class AdvancedObjPreferences1(AddonPreferences): try: prefs.draw(context) except: + import traceback traceback.print_exc() - box.label(text='Error (see console)', icon='ERROR') + box.label(text="Error (see console)", icon="ERROR") del prefs.layout row = layout.row() - row.label("End of Panel Activations") + row.label(text="End of Advanced Object Panels Activations", + icon="FILE_PARENT") for mod in sub_modules: @@ -218,10 +219,10 @@ for mod in sub_modules: return update prop = BoolProperty( - name=info['name'], - description=info.get('description', ''), - update=gen_update(mod), - ) + name=info['name'], + description=info.get('description', ''), + update=gen_update(mod), + ) setattr(AdvancedObjPreferences1, 'use_' + mod_name, prop) prop = BoolProperty() setattr(AdvancedObjPreferences1, 'show_expanded_' + mod_name, prop) @@ -229,8 +230,6 @@ for mod in sub_modules: class AdvancedObjProperties1(PropertyGroup): - # main properties - # object_laplace_lighting props ORIGIN = FloatVectorProperty( name="Origin charge" diff --git a/add_advanced_objects_panels/delaunay_voronoi.py b/add_advanced_objects_panels/delaunay_voronoi.py index 02768232..0537bf6f 100644 --- a/add_advanced_objects_panels/delaunay_voronoi.py +++ b/add_advanced_objects_panels/delaunay_voronoi.py @@ -25,14 +25,12 @@ bl_info = { "author": "Domlysz, Oscurart", "version": (1, 3), "blender": (2, 7, 0), - "location": "View3D > Tools > GIS", + "location": "3D View > Toolshelf > Create > Delaunay Voronoi", "warning": "", "wiki_url": "https://github.com/domlysz/BlenderGIS/wiki", "category": "Add Mesh" } - - import bpy from .DelaunayVoronoi import ( computeVoronoiDiagram, @@ -100,7 +98,6 @@ class ToolsPanelDelaunay(Panel): def draw(self, context): layout = self.layout - adv_obj = context.scene.advanced_objects1 box = layout.box() col = box.column(align=True) @@ -294,6 +291,7 @@ class OBJECT_OT_VoronoiButton(Operator): return {'FINISHED'} + # Register def register(): bpy.utils.register_class(OBJECT_OT_VoronoiButton) @@ -309,4 +307,3 @@ def unregister(): if __name__ == "__main__": register() - diff --git a/add_advanced_objects_panels/drop_to_ground.py b/add_advanced_objects_panels/drop_to_ground.py index 35020020..e6facbcf 100644 --- a/add_advanced_objects_panels/drop_to_ground.py +++ b/add_advanced_objects_panels/drop_to_ground.py @@ -20,7 +20,7 @@ bl_info = { "name": "Drop to Ground1", "author": "Unnikrishnan(kodemax), Florian Meyer(testscreenings)", "blender": (2, 71, 0), - "location": "3D View > Toolshelf > Tools Tab", + "location": "3D View > Toolshelf > Create > Drop To Ground", "description": "Drop selected objects on active object", "warning": "", "category": "Object"} @@ -39,6 +39,12 @@ from bpy.types import ( from bpy.props import BoolProperty +def test_ground_object(ground): + if ground.type in {'MESH', 'FONT', 'META', 'CURVE', 'SURFACE'}: + return True + return False + + def get_align_matrix(location, normal): up = Vector((0, 0, 1)) angle = normal.angle(up) @@ -99,7 +105,7 @@ def get_lowest_world_co(context, ob, mat_parent=None): def drop_objectsall(self, context): - ground = bpy.context.active_object + ground = context.active_object name = ground.name for obs in bpy.context.scene.objects: @@ -119,7 +125,8 @@ def drop_objectsall(self, context): lowest_world_co = get_lowest_world_co(context, ob) if not lowest_world_co: - message = "Type {} is not supported. Failed to drop {}".format(ob.type, ob.name) + message = "Object {} is of type {} works only with Use Center option " \ + "checked".format(ob.name, ob.type) self.reported.append(message) continue is_hit, hit_location, hit_normal, hit_index = tmp_ground.ray_cast(lowest_world_co, down) @@ -159,9 +166,12 @@ def drop_objectsall(self, context): def drop_objects(self, context): - ground = context.object + ground = context.active_object + obs = context.selected_objects - obs.remove(ground) + if ground in obs: + obs.remove(ground) + tmp_ground = transform_ground_to_world(context.scene, ground) down = Vector((0, 0, -10000)) @@ -172,13 +182,14 @@ def drop_objects(self, context): lowest_world_co = get_lowest_world_co(context, ob) if not lowest_world_co: - message = "Type {} is not supported. Failed to drop {}".format(ob.type, ob.name) + message = "Object {} is of type {} works only with Use Center option " \ + "checked".format(ob.name, ob.type) self.reported.append(message) continue is_hit, hit_location, hit_normal, hit_index = tmp_ground.ray_cast(lowest_world_co, down) if not is_hit: - message = ob.name + " did not hit the Ground" + message = ob.name + " did not hit the Active Object" self.reported.append(message) continue @@ -211,77 +222,83 @@ def drop_objects(self, context): ground.select = True -class OBJECT_OT_drop_to_ground(Operator): - bl_idname = "object.drop_on_active" - bl_label = "Drop to Ground" - bl_description = "Drop selected objects on the active object" - bl_options = {'REGISTER', 'UNDO'} - +# define base dummy class for inheritance +class DropBaseAtributes: align = BoolProperty( name="Align to ground", - description="Aligns the object to the ground", + description="Aligns the objects' rotation to the ground", default=True) use_origin = BoolProperty( - name="Use Center", - description="Drop to objects origins", + name="Use Origins", + description="Drop to objects' origins\n" + "Use this option for dropping all types of Objects", default=False) + + +class OBJECT_OT_drop_to_ground(Operator, DropBaseAtributes): + bl_idname = "object.drop_on_active" + bl_label = "Drop to Ground" + bl_description = ("Drop selected objects on the Active object\n" + "Active Object has to be of following the types:\n" + "Mesh, Font, Metaball, Curve, Surface") + bl_options = {'REGISTER', 'UNDO'} + reported = [] @classmethod def poll(cls, context): - return len(context.selected_objects) >= 2 + act_obj = context.active_object + return (len(context.selected_objects) >= 2 and + act_obj and test_ground_object(act_obj)) def execute(self, context): drop_objects(self, context) if self.reported: self.report({"INFO"}, - "Operation failed on some objects. See the Console for more Info") + "Some objects could not be dropped (See the Console for more Info)") report_items = " \n".join(self.reported) print("\n[Drop to Ground Report]\n{}\n".format(report_items)) - self.reported = [] + self.reported[:] = [] return {'FINISHED'} -class OBJECT_OT_drop_all_ground(Operator): +class OBJECT_OT_drop_all_ground(Operator, DropBaseAtributes): bl_idname = "object.drop_all_active" bl_label = "Drop All to Ground (Active Object)" - bl_description = "Drop selected objects on active object" + bl_description = ("Drop all other objects onto Active Object\n" + "Active Object has to be of following the types:\n" + "Mesh, Font, Metaball, Curve, Surface") bl_options = {'REGISTER', 'UNDO'} - align = BoolProperty( - name="Align to ground", - description="Aligns the object to the ground", - default=True) - use_origin = BoolProperty( - name="Use Center", - description="Drop to objects origins", - default=False) reported = [] @classmethod def poll(cls, context): - return context.active_object is not None + act_obj = context.active_object + return act_obj and test_ground_object(act_obj) def execute(self, context): drop_objectsall(self, context) if self.reported: self.report({"INFO"}, - "Operation failed on some objects. See the Console for more Info") + "Some objects could not be dropped (See the Console for more Info)") report_items = " \n".join(self.reported) print("\n[Drop All to Ground Report]\n{}\n".format(report_items)) - self.reported = [] + self.reported[:] = [] return {'FINISHED'} class Drop_help(Operator): bl_idname = "help.drop" - bl_label = "" + bl_label = "Drop to Ground Help" + bl_description = "Clik for some information about Drop to Ground" + bl_options = {"REGISTER", "INTERNAL"} is_all = BoolProperty( default=True, @@ -290,14 +307,28 @@ class Drop_help(Operator): def draw(self, context): layout = self.layout + + layout.label("General Info:") + layout.label("The Active Object has to be of a Mesh, Font,") + layout.label("Metaball, Curve or Surface type and") + layout.label("be at the lowest Z location") + layout.label("The option Use Origins must be enabled to drop") + layout.label("objects that are not of a Mesh or DupliGroup type") + layout.label("The Active Object has to be big enough to catch them") + layout.label("To check that, use the Orthographic Top View") + layout.separator() + layout.label("To use:") if self.is_all is False: - layout.label("Name the base object 'Ground'") - layout.label("Select the object's to drop") - layout.label("Then Shift Select 'Ground'") + layout.label("Select objects to drop") + layout.label("Then Shift Select the object to be the ground") + layout.label("Drops Selected Object to the Active one") else: - layout.label("Select the ground mesh and press Drop all") + layout.label("Select the ground Mesh and press Drop all") + layout.label("The unselected Objects will be moved straight") + layout.label("down the Z axis, so they have to be above") + layout.label("the Selected / Active one to fall") def execute(self, context): return {'FINISHED'} @@ -320,12 +351,12 @@ class Drop_Operator_Panel(Panel): row = layout.split(percentage=0.8, align=True) row.operator(OBJECT_OT_drop_to_ground.bl_idname, text="Drop Selected") - row.operator("help.drop", icon="LAYER_USED").is_all = False + row.operator("help.drop", text="", icon="LAYER_USED").is_all = False row = layout.split(percentage=0.8, align=True) row.operator(OBJECT_OT_drop_all_ground.bl_idname, text="Drop All") - row.operator("help.drop", icon="LAYER_USED").is_all = True + row.operator("help.drop", text="", icon="LAYER_USED").is_all = True # Register diff --git a/add_advanced_objects_panels/object_laplace_lightning.py b/add_advanced_objects_panels/object_laplace_lightning.py index 3e71c29b..f33ed935 100644 --- a/add_advanced_objects_panels/object_laplace_lightning.py +++ b/add_advanced_objects_panels/object_laplace_lightning.py @@ -17,13 +17,13 @@ # ##### END GPL LICENSE BLOCK ##### # NOTE: moved the winmgr properties to __init__ and scene -# search for context.scene.advanced_objects +# search for context.scene.advanced_objects1 bl_info = { "name": "Laplacian Lightning", "author": "teldredge", "blender": (2, 78, 0), - "location": "View3D > Toolshelf > Create Tab", + "location": "3D View > Toolshelf > Create > Laplacian Lightning", "description": "Lightning mesh generator using laplacian growth algorithm", "warning": "", "category": "Object"} @@ -967,9 +967,11 @@ def getGrowthProbability_KEEPFORREFERENCE(uN, aList): PdL = [] E = 0 E = notZero # divisor for (fslg - eqn. 12) + for o in oList: Uj = (o - Omin) / (Omax - Omin) # (fslg - eqn. 13) E += pow(Uj, uN) + for oi in range(len(oList)): o = oList[oi] Ui = (o - Omin) / (Omax - Omin) @@ -1025,6 +1027,7 @@ def updatePointCharges(p, cList, eList=[]): # Out: list of new charge at candidate sites r1 = 1 / 2 # (FSLG - Eqn. 10) nOiL = [] + for oi in range(len(cList)): o = cList[oi][1] c = cList[oi][0] @@ -1042,10 +1045,13 @@ def initialPointCharges(pList, cList, eList=[]): # Out: cList -with potential calculated r1 = 1 / 2 # (FSLG - Eqn. 10) npList = [] + for p in pList: npList.append(((p[0], p[1], p[2]), 1.0)) + for e in eList: npList.append(((e[0], e[1], e[2]), e[3])) + OiL = [] for i in cList: Oi = 0 diff --git a/add_advanced_objects_panels/object_mangle_tools.py b/add_advanced_objects_panels/object_mangle_tools.py index 60438eca..0796fea6 100644 --- a/add_advanced_objects_panels/object_mangle_tools.py +++ b/add_advanced_objects_panels/object_mangle_tools.py @@ -24,7 +24,7 @@ bl_info = { "name": "Mangle Tools", "author": "Phil Cote", "blender": (2, 71, 0), - "location": "View3D > Toolshelf > Tools Tab", + "location": "3D View > Toolshelf > Create > Mangle Tools", "description": "Set of tools to mangle curves, meshes, and shape keys", "warning": "", "wiki_url": "", diff --git a/add_advanced_objects_panels/oscurart_constellation.py b/add_advanced_objects_panels/oscurart_constellation.py index f2caa423..4e477a35 100644 --- a/add_advanced_objects_panels/oscurart_constellation.py +++ b/add_advanced_objects_panels/oscurart_constellation.py @@ -17,10 +17,10 @@ # ##### END GPL LICENSE BLOCK ##### bl_info = { - "name": "Mesh: Constellation", + "name": "Constellation", "author": "Oscurart", "blender": (2, 67, 0), - "location": "Add > Mesh > Constellation", + "location": "3D View > Toolshelf > Create > Constellation", "description": "Create a new Mesh From Selected", "warning": "", "wiki_url": "", @@ -37,6 +37,7 @@ from bpy.types import ( Panel, ) + def VertDis(a, b): dst = sqrt(pow(a.co.x - b.co.x, 2) + pow(a.co.y - b.co.y, 2) + @@ -109,6 +110,7 @@ class Oscurart_Constellation(Operator): return {'FINISHED'} + class Constellation_Operator_Panel(Panel): bl_label = "Constellation" bl_region_type = "TOOLS" @@ -126,8 +128,9 @@ class Constellation_Operator_Panel(Panel): col.label("Constellation:") col.operator("mesh.constellation", text="Cross Section") col.prop(adv_obj, "constellation_limit") -# Register + +# Register def register(): bpy.utils.register_class(Oscurart_Constellation) bpy.utils.register_class(Constellation_Operator_Panel) @@ -137,5 +140,6 @@ def unregister(): bpy.utils.unregister_class(Oscurart_Constellation) bpy.utils.unregister_class(Constellation_Operator_Panel) + if __name__ == "__main__": register() diff --git a/add_advanced_objects_panels/unfold_transition.py b/add_advanced_objects_panels/unfold_transition.py index 9b196810..42d8c3ba 100644 --- a/add_advanced_objects_panels/unfold_transition.py +++ b/add_advanced_objects_panels/unfold_transition.py @@ -3,7 +3,7 @@ bl_info = { "name": "Unfold transition", "author": "Liero, Atom", - "location": "Tool bar > Animation tab > UnFold Transition", + "location": "3D View > Toolshelf > Create > Unfold Transition", "description": "Simple unfold transition / animation, will " "separate faces and set up an armature", "category": "Animation"} @@ -326,12 +326,14 @@ class PanelFOLD(Panel): if not adv_obj.unfold_flip: row.prop(adv_obj, "unfold_from_point") + classes = ( Set_Up_Fold, Animate_Fold, PanelFOLD, ) + def register(): for cls in classes: bpy.utils.register_class(cls) -- cgit v1.2.3