[Bf-extensions-cvs] [352254d5] master: Implementation change object after creation. Adding context menu "Change Geodesic Dome"

Spivak Vladimir cwolf3d noreply at git.blender.org
Mon Apr 29 00:49:57 CEST 2019


Commit: 352254d5c84eec8b2ef1922e9ccec25516f6d8c2
Author: Spivak Vladimir (cwolf3d)
Date:   Mon Apr 29 01:47:43 2019 +0300
Branches: master
https://developer.blender.org/rBA352254d5c84eec8b2ef1922e9ccec25516f6d8c2

Implementation change object after creation.
Adding context menu "Change Geodesic Dome"

===================================================================

M	add_mesh_geodesic_domes/__init__.py
M	add_mesh_geodesic_domes/third_domes_panel_271.py

===================================================================

diff --git a/add_mesh_geodesic_domes/__init__.py b/add_mesh_geodesic_domes/__init__.py
index b1954214..4b3d8fc1 100644
--- a/add_mesh_geodesic_domes/__init__.py
+++ b/add_mesh_geodesic_domes/__init__.py
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "Geodesic Domes2",
     "author": "Noctumsolis, PKHG, Meta Androcto, Andy Houston",
-    "version": (0, 3, 3),
+    "version": (0, 3, 4),
     "blender": (2, 80, 0),
     "location": "View3D > Add > Mesh",
     "description": "Create geodesic dome type objects.",
@@ -45,6 +45,140 @@ else:
 
 import bpy
 
+def Geodesic_contex_menu(self, context):
+    bl_label = 'Change'
+    
+    obj = context.object
+    layout = self.layout
+    
+    if 'GeodesicDome' in obj.keys():
+        props = layout.operator("mesh.generate_geodesic_dome", text="Change Geodesic Dome")
+        props.change = True
+        props.delete = obj.name
+        props.location = obj.location
+        props.rotation_euler = obj.rotation_euler
+        props.save_parameters = obj["save_parameters"]
+        props.load_parameters = obj["load_parameters"]
+        props.gd_help_text_width = obj["gd_help_text_width"]
+        props.mainpages = obj["mainpages"]
+        props.facetype_menu = obj["facetype_menu"]
+        props.facetoggle = obj["facetoggle"]
+        props.face_use_imported_object = obj["face_use_imported_object"]
+        props.facewidth = obj["facewidth"]
+        props.fwtog = obj["fwtog"]
+        props.faceheight = obj["faceheight"]
+        props.fhtog = obj["fhtog"]
+        props.face_detach = obj["face_detach"]
+        props.fmeshname = obj["fmeshname"]
+        props.geodesic_types = obj["geodesic_types"]
+        props.import_mesh_name = obj["import_mesh_name"]
+        props.base_type = obj["base_type"]
+        props.orientation = obj["orientation"]
+        props.geodesic_class = obj["geodesic_class"]
+        props.tri_hex_star = obj["tri_hex_star"]
+        props.spherical_flat = obj["spherical_flat"]
+        props.use_imported_mesh = obj["use_imported_mesh"]
+        props.cyxres = obj["cyxres"]
+        props.cyyres = obj["cyyres"]
+        props.cyxsz = obj["cyxsz"]
+        props.cyysz = obj["cyysz"]
+        props.cyxell = obj["cyxell"]
+        props.cygap = obj["cygap"]
+        props.cygphase = obj["cygphase"]
+        props.paxres = obj["paxres"]
+        props.payres = obj["payres"]
+        props.paxsz = obj["paxsz"]
+        props.paysz = obj["paysz"]
+        props.paxell = obj["paxell"]
+        props.pagap = obj["pagap"]
+        props.pagphase = obj["pagphase"]
+        props.ures = obj["ures"]
+        props.vres = obj["vres"]
+        props.urad = obj["urad"]
+        props.vrad = obj["vrad"]
+        props.uellipse = obj["uellipse"]
+        props.vellipse = obj["vellipse"]
+        props.upart = obj["upart"]
+        props.vpart = obj["vpart"]
+        props.ugap = obj["ugap"]
+        props.vgap = obj["vgap"]
+        props.uphase = obj["uphase"]
+        props.vphase = obj["vphase"]
+        props.uexp = obj["uexp"]
+        props.vexp = obj["vexp"]
+        props.usuper = obj["usuper"]
+        props.vsuper = obj["vsuper"]
+        props.utwist = obj["utwist"]
+        props.vtwist = obj["vtwist"]
+        props.bures = obj["bures"]
+        props.bvres = obj["bvres"]
+        props.burad = obj["burad"]
+        props.bupart = obj["bupart"]
+        props.bvpart = obj["bvpart"]
+        props.buphase = obj["buphase"]
+        props.bvphase = obj["bvphase"]
+        props.buellipse = obj["buellipse"]
+        props.bvellipse = obj["bvellipse"]
+        props.grxres = obj["grxres"]
+        props.gryres = obj["gryres"]
+        props.grxsz = obj["grxsz"]
+        props.grysz = obj["grysz"]
+        props.cart = obj["cart"]
+        props.frequency = obj["frequency"]
+        props.eccentricity = obj["eccentricity"]
+        props.squish = obj["squish"]
+        props.radius = obj["radius"]
+        props.squareness = obj["squareness"]
+        props.squarez = obj["squarez"]
+        props.baselevel = obj["baselevel"]
+        props.dual = obj["dual"]
+        props.rotxy = obj["rotxy"]
+        props.rotz = obj["rotz"]
+        props.uact = obj["uact"]
+        props.vact = obj["vact"]
+        props.um = obj["um"]
+        props.un1 = obj["un1"]
+        props.un2 = obj["un2"]
+        props.un3 = obj["un3"]
+        props.ua = obj["ua"]
+        props.ub = obj["ub"]
+        props.vm = obj["vm"]
+        props.vn1 = obj["vn1"]
+        props.vn2 = obj["vn2"]
+        props.vn3 = obj["vn3"]
+        props.va = obj["va"]
+        props.vb = obj["vb"]
+        props.uturn = obj["uturn"]
+        props.vturn = obj["vturn"]
+        props.utwist = obj["utwist"]
+        props.vtwist = obj["vtwist"]
+        props.struttype = obj["struttype"]
+        props.struttoggle = obj["struttoggle"]
+        props.strutimporttoggle = obj["strutimporttoggle"]
+        props.strutimpmesh = obj["strutimpmesh"]
+        props.strutwidth = obj["strutwidth"]
+        props.swtog = obj["swtog"]
+        props.strutheight = obj["strutheight"]
+        props.shtog = obj["shtog"]
+        props.strutshrink = obj["strutshrink"]
+        props.sstog = obj["sstog"]
+        props.stretch = obj["stretch"]
+        props.lift = obj["lift"]
+        props.smeshname = obj["smeshname"]
+        props.hubtype = obj["hubtype"]
+        props.hubtoggle = obj["hubtoggle"]
+        props.hubimporttoggle = obj["hubimporttoggle"]
+        props.hubimpmesh = obj["hubimpmesh"]
+        props.hubwidth = obj["hubwidth"]
+        props.hwtog = obj["hwtog"]
+        props.hubheight = obj["hubheight"]
+        props.hhtog = obj["hhtog"]
+        props.hublength = obj["hublength"]
+        props.hstog = obj["hstog"]
+        props.hmeshname = obj["hmeshname"]
+
+        layout.separator()
+
 # Define "Extras" menu
 def menu_func(self, context):
     lay_out = self.layout
@@ -68,10 +202,12 @@ def register():
 
     # Add "Extras" menu to the "Add Mesh" menu
     bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
+    bpy.types.VIEW3D_MT_object_context_menu.prepend(Geodesic_contex_menu)
 
 
 def unregister():
     # Remove "Extras" menu from the "Add Mesh" menu.
+    bpy.types.VIEW3D_MT_object_context_menu.remove(Geodesic_contex_menu)
     bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
 
     from bpy.utils import unregister_class
diff --git a/add_mesh_geodesic_domes/third_domes_panel_271.py b/add_mesh_geodesic_domes/third_domes_panel_271.py
index 2a5a4409..41a3cf5d 100644
--- a/add_mesh_geodesic_domes/third_domes_panel_271.py
+++ b/add_mesh_geodesic_domes/third_domes_panel_271.py
@@ -12,9 +12,13 @@ from bpy.props import (
         FloatProperty,
         StringProperty,
         BoolProperty,
+        FloatVectorProperty,
         )
 from math import pi
-from mathutils import Vector  # used for vertex.vector values
+from mathutils import (
+        Vector,
+        Matrix,
+        )
 
 # global #
 last_generated_object = None
@@ -27,12 +31,68 @@ geodesic_not_yet_called = True
 
 # ###### EIND FOR SHAPEKEYS ######
 
+##------------------------------------------------------------
+# calculates the matrix for the new object
+# depending on user pref
+def align_matrix(context, location):
+
+    loc = Matrix.Translation(location)
+    obj_align = context.preferences.edit.object_align
+    if (context.space_data.type == 'VIEW_3D'
+        and obj_align == 'VIEW'):
+        rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4()
+    else:
+        rot = Matrix()
+    align_matrix = loc @ rot
+
+    return align_matrix
+
+#### Delete object
+def ObjectDelete(self, context, delete):
+
+    bpy.context.scene.update()
+    bpy.ops.object.mode_set(mode = 'OBJECT')
+    bpy.ops.object.delete()
+    bpy.context.scene.update()
+
+    return
+
 
 class GenerateGeodesicDome(Operator):
     bl_label = "Modify Geodesic Objects"
     bl_idname = "mesh.generate_geodesic_dome"
     bl_description = "Create Geodesic Object Types"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
+    
+    # align_matrix for the invoke
+    align_matrix : Matrix()
+
+    GeodesicDome : BoolProperty(name = "Geodesic Dome",
+                default = True,
+                description = "Geodesic Dome")
+
+    #### change properties
+    name : StringProperty(name = "Name",
+                    description = "Name")
+                    
+    change : BoolProperty(name = "Change",
+                default = False,
+                description = "change Gear")
+
+    delete : StringProperty(name = "Delete",
+                    description = "Delete Gear")
+    
+    location : FloatVectorProperty(name = "",
+                description = "Location",
+                default = (0.0, 0.0, 0.0),
+                subtype = 'XYZ')
+
+    rotation_euler : FloatVectorProperty(
+            name="",
+            description="Rotation",
+            default=(0.0, 0.0, 0.0),
+            subtype='EULER'
+            )
 
     # PKHG_NEW saving and loading parameters
     save_parameters: BoolProperty(
@@ -977,6 +1037,12 @@ class GenerateGeodesicDome(Operator):
                     row.prop(self, "vturn")
                     row = layout.row()
                     row.prop(self, "vtwist")
+            box = layout.box()
+            box.label(text="Location:")
+            box.prop(self, "location")
+            box = layout.box()
+            box.label(text="Rotation:")
+            box.prop(self, "rotation_euler")
         # einde superform
         elif which_mainpages == "Hubs":
             row = layout.row()
@@ -1088,6 +1154,10 @@ class GenerateGeodesicDome(Operator):
             multi_label(help_text, box, text_width)
 
     def execute(self, context):
+        
+        if self.change:
+            ObjectDelete(self, context, self.delete)
+    
         global last_generated_object, last_imported_mesh, basegeodesic, imported_hubmesh_to_use, error_message
         # default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]]
         superformparam = [self.um, self.un1, self.un2, self.un3, self.ua,
@@ -1121,14 +1191,14 @@ class GenerateGeodesicDome(Operator):
                 vefm_271.finalfill(basegeodesic, mesh)  # always! for 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list