[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3415] contrib/py/scripts/addons/ add_mesh_clusters/__init__.py:

Clemens Barth barth at root-1.de
Mon May 28 16:11:55 CEST 2012


Revision: 3415
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3415
Author:   blendphys
Date:     2012-05-28 14:11:55 +0000 (Mon, 28 May 2012)
Log Message:
-----------

1. New: Min value for lattice = 1.0 Angstroem
2. The addon is called via the menu: Add => Mesh => Atom cluster
   Only then the panel appears.

Blendphys.

Modified Paths:
--------------
    contrib/py/scripts/addons/add_mesh_clusters/__init__.py

Modified: contrib/py/scripts/addons/add_mesh_clusters/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/__init__.py	2012-05-28 13:25:16 UTC (rev 3414)
+++ contrib/py/scripts/addons/add_mesh_clusters/__init__.py	2012-05-28 14:11:55 UTC (rev 3415)
@@ -64,16 +64,41 @@
 
 from . import add_mesh_cluster
 
+ATOM_Cluster_PANEL = 0
+
 # -----------------------------------------------------------------------------
 #                                                                           GUI
 
-# The panel, which is loaded after the file has been
-# chosen via the menu 'File -> Import'
+
+class CLASS_ImportCluster(bpy.types.Operator):
+    bl_idname = "mesh.cluster"
+    bl_label = "Atom cluster"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    def execute(self, context):
+
+        global ATOM_Cluster_PANEL
+        ATOM_Cluster_PANEL = 1
+
+        return {'FINISHED'}
+
+
+
 class CLASS_atom_cluster_panel(Panel):
     bl_label       = "Atomic Blender - Cluster"
     bl_space_type  = "VIEW_3D"
     bl_region_type = "TOOL_PROPS"
 
+
+    @classmethod
+    def poll(self, context):
+        global ATOM_Cluster_PANEL
+        
+        if ATOM_Cluster_PANEL == 0:
+            return False
+        
+        return True
+
     def draw(self, context):
         layout = self.layout
         
@@ -99,7 +124,6 @@
             row = box.row()
             row.prop(scn, "skin")
 
-
         row = box.row()
         row.prop(scn, "lattice_parameter")
         row = box.row()
@@ -180,7 +204,7 @@
                ('parabolid_abc',    "Paraboloid: hex abc", "Paraboloid with abc-lattice")),
                default='sphere_square',)  
     lattice_parameter = FloatProperty(
-        name = "Lattice", default=4.0, min=0.1,
+        name = "Lattice", default=4.0, min=1.0,
         description = "Lattice parameter in Angstroem")
     element = StringProperty(name="Element",
         default="Gold", description = "Enter the name of the element")
@@ -471,6 +495,11 @@
                     if "Stick" not in obj.name:
                         obj.scale *= scale
 
+
+# The entry into the menu 'file -> import'
+def DEF_menu_func(self, context):
+    self.layout.operator(CLASS_ImportCluster.bl_idname, icon='MESH_CUBE')
+
 def register_atom_class():
     bpy.types.Scene.atom_cluster = bpy.props.CollectionProperty(type=CLASS_atom_cluster_Properties)    
     bpy.context.scene.atom_cluster.add()
@@ -478,9 +507,11 @@
 def register():
     bpy.utils.register_module(__name__)
     register_atom_class()
+    bpy.types.INFO_MT_mesh_add.append(DEF_menu_func)
     
 def unregister():
     bpy.utils.unregister_module(__name__)
+    bpy.types.INFO_MT_mesh_add.remove(DEF_menu_func)
 
 if __name__ == "__main__":
 



More information about the Bf-extensions-cvs mailing list