[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3406] contrib/py/scripts/addons: Hi all. Here comes my 3rd "Atomic Blender" addon:

Clemens Barth barth at root-1.de
Sun May 27 19:28:22 CEST 2012


Revision: 3406
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3406
Author:   blendphys
Date:     2012-05-27 17:28:21 +0000 (Sun, 27 May 2012)
Log Message:
-----------
Hi all. Here comes my 3rd "Atomic Blender" addon: 


                                    ________________________ 
                                    Atomic Blender - Cluster
                                    ------------------------


With this addon a cluster can be loaded, which is composed of atoms (balls) that are arranged in an ordered crystal lattice. The addon can be used to vizualise some important clusters or objects from physics and chemistry. Pyramid and octahedron shaped but also spherical clusters can be chosen. There is also the possibility to load parabolic shaped clusters. The latter have been introduced to model e.g. an atomic force microscopy (AFM) tip. 

Note that the clusters are obtained by cutting a specific bulk lattice (e.g., bcc, hcp, etc.)!

The Wiki can be found here: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Cluster

What do you think? Comments?

Blendphys.

Added Paths:
-----------
    contrib/py/scripts/addons/add_mesh_clusters/
    contrib/py/scripts/addons/add_mesh_clusters/__init__.py
    contrib/py/scripts/addons/add_mesh_clusters/__pycache__/
    contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py

Added: contrib/py/scripts/addons/add_mesh_clusters/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/__init__.py	                        (rev 0)
+++ contrib/py/scripts/addons/add_mesh_clusters/__init__.py	2012-05-27 17:28:21 UTC (rev 3406)
@@ -0,0 +1,486 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  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 2
+#  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, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+#
+#  Main author       : Clemens Barth (Blendphys at root-1.de)
+#  Authors           : Clemens Barth, ...
+#
+#  Homepage(Wiki)    : http://development.root-1.de/Atomic_Blender.php
+#  Tracker           : ...
+#
+#  Start of project              : 2012-03-25 by Clemens Barth
+#  First publication in Blender  : 2012-05-27
+#  Last modified                 : 2012-05-27
+#
+#
+#
+#  To do:
+#  ======
+#
+#  1. Include other shapes: icosahedron, dodecahedron
+#  2. ...
+#
+#
+
+bl_info = {
+    "name": "Atomic Blender - Cluster",
+    "description": "Creating cluster formed by atoms",
+    "author": "Clemens Barth",
+    "version": (0,5),
+    "blender": (2,6),
+    "location": "Panel: View 3D - Tools (left side)",
+    "warning": "",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Cluster",
+    "tracker_url": "",
+    "category": "Add mesh"
+}
+
+import os
+import io
+import bpy
+from bpy.types import Operator, Panel
+from bpy_extras.io_utils import ImportHelper, ExportHelper
+from bpy.props import (StringProperty,
+                       BoolProperty,
+                       EnumProperty,
+                       IntProperty,
+                       FloatProperty)
+
+from . import add_mesh_cluster
+
+# -----------------------------------------------------------------------------
+#                                                                           GUI
+
+# The panel, which is loaded after the file has been
+# chosen via the menu 'File -> Import'
+class CLASS_atom_cluster_panel(Panel):
+    bl_label       = "Atomic Blender - Cluster"
+    bl_space_type  = "VIEW_3D"
+    bl_region_type = "TOOL_PROPS"
+
+    def draw(self, context):
+        layout = self.layout
+        
+        if len(context.scene.atom_cluster) == 0:
+            bpy.context.scene.atom_cluster.add()
+        
+        scn = context.scene.atom_cluster[0]
+
+        row = layout.row()
+        row.label(text="Cluster properties")
+        box = layout.box()
+        row = box.row()
+        row.prop(scn, "shape")
+
+        if scn.shape in ["parabolid_square","parabolid_ab","parabolid_abc"]:
+            row = box.row()
+            row.prop(scn, "parabol_diameter")
+            row = box.row()
+            row.prop(scn, "parabol_height")
+        else:
+            row = box.row()
+            row.prop(scn, "size")
+            row = box.row()
+            row.prop(scn, "skin")
+
+
+        row = box.row()
+        row.prop(scn, "lattice_parameter")
+        row = box.row()
+        row.prop(scn, "element")
+        row = box.row()
+        row.prop(scn, "radius_type")        
+        row = box.row()
+        row.prop(scn, "scale_radius")
+        row = box.row()
+        row.prop(scn, "scale_distances")
+        
+        row = layout.row()
+        row.label(text="Load cluster")
+        box = layout.box()
+        row = box.row()    
+        row.operator("atom_cluster.load")
+        row = box.row()
+        row.label(text="Number of atoms")
+        row = box.row()
+        row.prop(scn, "atom_number_total")  
+        row = box.row()
+        row.prop(scn, "atom_number_drawn")  
+        
+        row = layout.row()
+        row.label(text="Modify cluster")
+        box = layout.box()
+        row = box.row()
+        row.label(text="All changes concern:")
+        row = box.row()
+        row.prop(scn, "radius_how")
+        row = box.row()
+        row.label(text="1. Change type of radii")
+        row = box.row()
+        row.prop(scn, "radius_type")
+        row = box.row()
+        row.label(text="2. Change atom radii by scale")
+        row = box.row()
+        col = row.column()
+        col.prop(scn, "radius_all")         
+        col = row.column(align=True)
+        col.operator( "atom_cluster.radius_all_bigger" )
+        col.operator( "atom_cluster.radius_all_smaller" )
+
+
+# The properties (gadgets) in the panel. They all go to scene
+# during initialization (see end) 
+class CLASS_atom_cluster_Properties(bpy.types.PropertyGroup):
+
+    def Callback_radius_type(self, context):
+        scn = bpy.context.scene.atom_cluster[0]
+        DEF_atom_cluster_radius_type(scn.radius_type,
+                                     scn.radius_how,)
+
+    size = FloatProperty(
+        name = "Size", default=30.0, min=0.1,
+        description = "Size of cluster in Angstroem")
+    skin = FloatProperty(
+        name = "Skin", default=1.0, min=0.0, max = 1.0,
+        description = "Skin of cluster in % of size (skin=1.0: show all atoms, skin=0.1: show only the outer atoms)")
+    parabol_diameter = FloatProperty(
+        name = "Diameter", default=30.0, min=0.1,
+        description = "Top diameter in Angstroem")
+    parabol_height = FloatProperty(
+        name = "Height", default=30.0, min=0.1, 
+        description = "Height in Angstroem")
+    shape = EnumProperty(
+        name="",
+        description="Choose the shape of the cluster",
+        items=(('sphere_square',  "Sphere - square",   "Sphere with square lattice"),
+               ('sphere_hex_ab',  "Sphere - hex ab",  "Sphere with hexagonal ab-lattice"),
+               ('sphere_hex_abc', "Sphere - hex abc", "Sphere with hexagonal abc-lattice"),
+               ('pyramide_square',  "Pyramide - Square",    "Pyramide: square (abc-lattice)"),
+               ('pyramide_hex_abc', "Pyramide - Tetraeder", "Pyramide: tetraeder (abcabc-lattice)"),
+               ('octahedron',           "Octahedron",           "Octahedron"),
+               ('truncated_octahedron', "Truncated octahedron", "Truncated octahedron"),
+               ('parabolid_square', "Paraboloid: square",  "Paraboloid with square lattice"),
+               ('parabolid_ab',     "Paraboloid: hex ab",  "Paraboloid with ab-lattice"),
+               ('parabolid_abc',    "Paraboloid: hex abc", "Paraboloid with abc-lattice")),
+               default='sphere_square',)  
+    lattice_parameter = FloatProperty(
+        name = "Lattice", default=4.0, min=0.1,
+        description = "Lattice parameter in Angstroem")
+    element = StringProperty(name="Element",
+        default="Gold", description = "Enter the name of the element")
+    radius_type = EnumProperty(
+        name="Radius",
+        description="Which type of atom radii?",
+        items=(('0',"predefined", "Use pre-defined radii"),
+               ('1',"atomic", "Use atomic radii"),
+               ('2',"van der Waals","Use van der Waals radii")),
+               default='0',)
+    scale_radius = FloatProperty(
+        name = "Scale R", default=1.0, min=0.0,
+        description = "Scale radius of atoms")
+    scale_distances = FloatProperty(
+        name = "Scale d", default=1.0, min=0.0,
+        description = "Scale distances")
+        
+    atom_number_total = StringProperty(name="Total",
+        default="---", description = "Number of all atoms in the cluster")    
+    atom_number_drawn = StringProperty(name="Drawn",
+        default="---", description = "Number of drawn atoms in the cluster")    
+        
+    radius_how = EnumProperty(
+        name="",
+        description="Which objects shall be modified?",
+        items=(('ALL_ACTIVE',"all active objects", "in the current layer"),
+               ('ALL_IN_LAYER',"all"," in active layer(s)")),
+               default='ALL_ACTIVE',)
+    radius_type = EnumProperty(
+        name="Type",
+        description="Which type of atom radii?",
+        items=(('0',"predefined", "Use pre-defined radii"),
+               ('1',"atomic", "Use atomic radii"),
+               ('2',"van der Waals","Use van der Waals radii")),
+               default='0',update=Callback_radius_type)
+    radius_all = FloatProperty(
+        name="Scale", default = 1.05, min=0.0,
+        description="Put in the scale factor")
+        
+
+# The button for reloading the atoms and creating the scene
+class CLASS_atom_cluster_load_button(Operator):
+    bl_idname = "atom_cluster.load"
+    bl_label = "Load"
+    bl_description = "Load the cluster"
+
+    def execute(self, context):
+        scn    = context.scene.atom_cluster[0]
+
+        add_mesh_cluster.DEF_atom_read_atom_data()
+        add_mesh_cluster.ATOM_CLUSTER_ALL_ATOMS[:] = []
+
+        print(scn.shape)
+
+        if scn.shape in ["parabolid_ab", "parabolid_abc", "parabolid_square"]:
+            parameter1 = scn.parabol_height
+            parameter2 = scn.parabol_diameter
+        elif scn.shape == "pyramide_hex_abc":
+            parameter1 = scn.size * 1.6
+            parameter2 = scn.skin
+        elif scn.shape == "pyramide_square":
+            parameter1 = scn.size * 1.4
+            parameter2 = scn.skin
+        elif scn.shape in ["octahedron", "truncated_octahedron"]:
+            parameter1 = scn.size * 1.4
+            parameter2 = scn.skin
+        else:
+            parameter1 = scn.size
+            parameter2 = scn.skin
+
+        if scn.shape in ["octahedron", "truncated_octahedron", "sphere_square", "pyramide_square", "parabolid_square"]:
+            numbers = add_mesh_cluster.create_square_lattice(
+                                scn.shape, 
+                                parameter1, 
+                                parameter2,
+                                (scn.lattice_parameter/2.0))
+
+        if scn.shape in ["sphere_hex_ab", "parabolid_ab"]:

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list