[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4175] contrib/py/scripts/addons/ io_atomblend_utilities: 1. Separating single atoms by other type of objects : I added NURBS objects and

Clemens Barth barth at root-1.de
Fri Jan 18 20:01:01 CET 2013


Revision: 4175
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4175
Author:   blendphys
Date:     2013-01-18 19:01:00 +0000 (Fri, 18 Jan 2013)
Log Message:
-----------
1. Separating single atoms by other type of objects: I added NURBS objects and 
some useful 'special' objects, which can serve for displaying defects in 
atomic structures. By time, I will add some other of 'special' objects.

2. Code cleaning

Blendphys.

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

Modified: contrib/py/scripts/addons/io_atomblend_utilities/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2013-01-17 20:36:47 UTC (rev 4174)
+++ contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2013-01-18 19:01:00 UTC (rev 4175)
@@ -24,12 +24,12 @@
 #
 #  Start of project              : 2011-12-01 by Clemens Barth
 #  First publication in Blender  : 2012-11-03
-#  Last modified                 : 2013-01-17
+#  Last modified                 : 2013-01-18
 #
 #  Acknowledgements 
 #  ================
 #
-#  Blender: ideasman, meta_androcto, truman, kilon, CoDEmanX, dairin0d, PKHG, 
+#  Blender: ideasman_42, meta_androcto, truman, kilon, CoDEmanX, dairin0d, PKHG, 
 #           Valter, ...
 #  Other: Frank Palmino
 #
@@ -53,7 +53,8 @@
 from bpy.types import Operator, Panel
 from bpy.props import (StringProperty,
                        EnumProperty,
-                       FloatProperty)
+                       FloatProperty,
+                       BoolProperty)
 
 from . import io_atomblend_utilities
 
@@ -119,11 +120,10 @@
         col.label(text="Separate atoms")
         col2 = col.column()
         col2.active = (bpy.context.mode == 'EDIT_MESH')
-        col2.prop(scn, "separate_objs")
+        col2.prop(scn, "draw_objs")
         col2.operator("atom_blend.separate_atom")
         
 
-
 # The properties of buttons etc. in the panel.
 class PanelProperties(bpy.types.PropertyGroup):
 
@@ -203,19 +203,30 @@
     sticks_all = FloatProperty(
         name="Scale", default = 1.05, min=1.0, max=5.0,
         description="Put in the scale factor")
-    separate_objs = EnumProperty(
-        name="Object",
-        description="Replace ball by another object.",
-        items=(('0',"Unchanged", "Use again a ball"),
+    draw_objs = EnumProperty(
+        name="Type",
+        description="Replace the balls by another type of object.",
+        items=(('-1',"Unchanged", "Use again a ball"),
+               ('0a',"Sphere", "Replace with a sphere"),
+               ('0b',"Sphere (NURBS)", "Replace with a sphere (NURBS)"),        
                ('1',"Cube", "Replace with a cube"),
                ('2',"Plane", "Replace with a plane"),
-               ('3',"Circle", "Replace with a circle"),
+               ('3a',"Circle", "Replace with a circle"),
+               ('3b',"Circle (NURBS)", "Replace with a circle (NURBS)"),               
                ('4',"Icosphere", "Replace with a icosphere"),              
-               ('5',"Cylinder", "Replace with a cylinder"),
+               ('5a',"Cylinder", "Replace with a cylinder"),
+               ('5b',"Cylinder (NURBS)", "Replace with a cylinder (NURBS)"),               
                ('6',"Cone", "Replace with a cone"),
-               ('7',"Torus", "Replace with a torus")),
-               default='0',)     
+               ('7a',"Torus", "Replace with a torus"),
+               ('7b',"Torus (NURBS)", "Replace with a torus (NURBS)"),
+               ('8',"Transparent cube", "Replace with a transparent cube"),      
+               ('9',"Transparent sphere", "Replace with a transparent sphere"),
+               ('10',"Transparent sphere (NURBS)", 
+                                  "Replace with a transparent sphere (NURBS)"),               
+               ('11',"Halo cloud", "Replace with a halo cloud")),
+               default='-1',)     
 
+
 # Button loading a custom data file
 class DatafileApply(Operator):
     bl_idname = "atom_blend.datafile_apply"
@@ -237,8 +248,8 @@
 # Button for separating single atoms from a dupliverts structure
 class SeparateAtom(Operator):
     bl_idname = "atom_blend.separate_atom"
-    bl_label = "Separate atoms"
-    bl_description = ("Separate atoms you have selected. "
+    bl_label = "Separate"
+    bl_description = ("Separate selected atoms in a dupliverts structure. "
                       "You have to be in the 'Edit Mode'")
 
     def execute(self, context):
@@ -299,6 +310,7 @@
                                               None)                                     
         return {'FINISHED'}
 
+
 # Button for increasing the radii of all selected sticks
 class SticksAllBiggerButton(Operator):
     bl_idname = "atom_blend.sticks_all_bigger"
@@ -338,8 +350,7 @@
 def register():
     io_atomblend_utilities.read_elements()  
     bpy.utils.register_module(__name__)
-    bpy.types.Scene.atom_blend = bpy.props.PointerProperty(type=
-                                                   PanelProperties)
+    bpy.types.Scene.atom_blend = bpy.props.PointerProperty(type=PanelProperties)
 
 def unregister():
     bpy.utils.unregister_module(__name__)

Modified: contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2013-01-17 20:36:47 UTC (rev 4174)
+++ contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2013-01-18 19:01:00 UTC (rev 4175)
@@ -154,6 +154,7 @@
 # data file.
 ELEMENTS = []
 
+
 # This is the class, which stores the properties for one element.
 class ElementProp(object):
     __slots__ = ('number', 'name', 'short_name', 'color', 'radii', 'radii_ionic')
@@ -437,7 +438,6 @@
     return True
 
 
-
 # Separating atoms from a dupliverts strucutre.
 def separate_atoms(scn):
 
@@ -479,47 +479,55 @@
 
     # For all selected positions do:
     for location in locations:
-        # For any ball do ...
-        
+        # For any selected ball do ...
+      
         # Draw same object
-        if scn.separate_objs in {'0'}:
-            separate_draw_regular(
-                                name, 
-                                obj.children[0], 
-                                location,
-                                scale, 
-                                material)
-        if scn.separate_objs in {'1','2','3','4','5','6','7'}:       
-            separate_draw_other_standard(
-                                scn.separate_objs, 
-                                name, 
-                                location, 
-                                scale, 
-                                material)                   
+        if scn.draw_objs == '-1':
+            draw_regular_obj(name,obj.children[0],location,scale,material)                
+        # Draw selected standard object
+        if scn.draw_objs in {'0a','0b','1','2','3a','3b','4','5a','5b','6',
+                             '7a','7b','8', '9', '10', '11'}:       
+            draw_obj(scn.draw_objs,name,location,scale,material)  
 
     bpy.context.scene.objects.active = obj
-    #bpy.ops.object.select_all(action='DESELECT')
-    
 
-def separate_draw_other_standard(obj_type, name, location, scale, material):
 
+# Draw an object (e.g. cube, sphere, cylinder, ...)
+def draw_obj(obj_type, name, location, scale, material):
+
     current_layers=bpy.context.scene.layers
 
-    if obj_type =='1': #Cube
+    if obj_type == '0a': #Sphere mesh
+        bpy.ops.mesh.primitive_uv_sphere_add(
+            segments=32,
+            ring_count=32,                    
+            size=1, view_align=False, 
+            enter_editmode=False,
+            location=location,
+            rotation=(0, 0, 0),
+            layers=current_layers)
+    if obj_type == '0b': #Sphere NURBS
+        bpy.ops.surface.primitive_nurbs_surface_sphere_add(
+            view_align=False, 
+            enter_editmode=False,
+            location=location,
+            rotation=(0.0, 0.0, 0.0),
+            layers=current_layers)
+    if obj_type == '1': #Cube
         bpy.ops.mesh.primitive_cube_add(
             view_align=False, 
             enter_editmode=False,
             location=location,
             rotation=(0.0, 0.0, 0.0),
             layers=current_layers)
-    if obj_type =='2': #Plane       
+    if obj_type == '2': #Plane       
         bpy.ops.mesh.primitive_plane_add(
             view_align=False, 
             enter_editmode=False, 
             location=location, 
             rotation=(0.0, 0.0, 0.0), 
             layers=current_layers)
-    if obj_type =='3': #Circle
+    if obj_type == '3a': #Circle
         bpy.ops.mesh.primitive_circle_add(
             vertices=32, 
             radius=1, 
@@ -529,7 +537,14 @@
             location=location, 
             rotation=(0, 0, 0), 
             layers=current_layers)      
-    if obj_type =='4': #Icosphere         
+    if obj_type == '3b': #Circle NURBS
+        bpy.ops.surface.primitive_nurbs_surface_circle_add(
+            view_align=False, 
+            enter_editmode=False, 
+            location=location, 
+            rotation=(0, 0, 0), 
+            layers=current_layers)                
+    if obj_type == '4': #Icosphere         
         bpy.ops.mesh.primitive_ico_sphere_add(
             subdivisions=2, 
             size=1, 
@@ -538,7 +553,7 @@
             location=location, 
             rotation=(0, 0, 0), 
             layers=current_layers)                
-    if obj_type =='5': #Cylinder
+    if obj_type == '5a': #Cylinder
         bpy.ops.mesh.primitive_cylinder_add(
             vertices=32, 
             radius=1, 
@@ -549,7 +564,14 @@
             location=location, 
             rotation=(0, 0, 0), 
             layers=current_layers)
-    if obj_type =='6': #Cone
+    if obj_type == '5b': #Cylinder NURBS
+        bpy.ops.surface.primitive_nurbs_surface_cylinder_add(
+            view_align=False, 
+            enter_editmode=False, 
+            location=location, 
+            rotation=(0, 0, 0), 
+            layers=current_layers)          
+    if obj_type == '6': #Cone
         bpy.ops.mesh.primitive_cone_add(
             vertices=32, 
             radius1=1, 
@@ -561,7 +583,7 @@
             location=location, 
             rotation=(0, 0, 0), 
             layers=current_layers)
-    if obj_type =='7': #Torus
+    if obj_type == '7a': #Torus
         bpy.ops.mesh.primitive_torus_add(
             rotation=(0, 0, 0), 
             location=location, 
@@ -573,18 +595,87 @@
             use_abso=False, 
             abso_major_rad=1, 
             abso_minor_rad=0.5)     
+    if obj_type == '7b': #Torus NURBS
+        bpy.ops.surface.primitive_nurbs_surface_torus_add(
+            view_align=False, 
+            enter_editmode=False, 
+            location=location, 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list