[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4173] contrib/py/scripts/addons/ io_atomblend_utilities:

Clemens Barth barth at root-1.de
Thu Jan 17 21:33:49 CET 2013


Revision: 4173
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4173
Author:   blendphys
Date:     2013-01-17 20:33:48 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------

New and very useful feature: when separating atoms from a dupliverts structure
same type of objects (NURBS, mesh and meta) were used. Now, one can explicitly
use other type of objects: cube, plane, circle, torus, cylinder, etc. 

This new option is quite useful for creating 'defects' in atomic structures, 
which shall appear in a different shape.

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 17:51:16 UTC (rev 4172)
+++ contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2013-01-17 20:33:48 UTC (rev 4173)
@@ -103,8 +103,8 @@
         col.label(text="3. Radii by scale")
         col.prop(scn, "radius_all")
         row = col.row()
-        row.operator( "atom_blend.radius_all_smaller" )
-        row.operator( "atom_blend.radius_all_bigger" )
+        row.operator("atom_blend.radius_all_smaller")
+        row.operator("atom_blend.radius_all_bigger")
         
         box = layout.box()
         col = box.column(align=True)
@@ -119,7 +119,9 @@
         col.label(text="Separate atoms")
         col2 = col.column()
         col2.active = (bpy.context.mode == 'EDIT_MESH')
-        col2.operator( "atom_blend.separate_atom" )
+        col2.prop(scn, "separate_objs")
+        col2.operator("atom_blend.separate_atom")
+        
 
 
 # The properties of buttons etc. in the panel.
@@ -201,8 +203,19 @@
     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"),
+               ('1',"Cube", "Replace with a cube"),
+               ('2',"Plane", "Replace with a plane"),
+               ('3',"Circle", "Replace with a circle"),
+               ('4',"Icosphere", "Replace with a icosphere"),              
+               ('5',"Cylinder", "Replace with a cylinder"),
+               ('6',"Cone", "Replace with a cone"),
+               ('7',"Torus", "Replace with a torus")),
+               default='0',)     
 
-
 # Button loading a custom data file
 class DatafileApply(Operator):
     bl_idname = "atom_blend.datafile_apply"

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 17:51:16 UTC (rev 4172)
+++ contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2013-01-17 20:33:48 UTC (rev 4173)
@@ -437,6 +437,7 @@
     return True
 
 
+
 # Separating atoms from a dupliverts strucutre.
 def separate_atoms(scn):
 
@@ -479,44 +480,146 @@
     # For all selected positions do:
     for location in locations:
         # For any ball do ...
-        if "Vacancy" not in name:
-            # NURBS ball
-            if obj.children[0].type == "SURFACE":
-                bpy.ops.surface.primitive_nurbs_surface_sphere_add(
+        
+        # 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)                   
+
+    bpy.context.scene.objects.active = obj
+    #bpy.ops.object.select_all(action='DESELECT')
+    
+
+def separate_draw_other_standard(obj_type, name, location, scale, material):
+
+    current_layers=bpy.context.scene.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       
+        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
+        bpy.ops.mesh.primitive_circle_add(
+            vertices=32, 
+            radius=1, 
+            fill_type='NOTHING', 
+            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, 
+            view_align=False, 
+            enter_editmode=False, 
+            location=location, 
+            rotation=(0, 0, 0), 
+            layers=current_layers)                
+    if obj_type =='5': #Cylinder
+        bpy.ops.mesh.primitive_cylinder_add(
+            vertices=32, 
+            radius=1, 
+            depth=2, 
+            end_fill_type='NGON', 
+            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, 
+            radius2=0, 
+            depth=2, 
+            end_fill_type='NGON', 
+            view_align=False, 
+            enter_editmode=False, 
+            location=location, 
+            rotation=(0, 0, 0), 
+            layers=current_layers)
+    if obj_type =='7': #Torus
+        bpy.ops.mesh.primitive_torus_add(
+            rotation=(0, 0, 0), 
+            location=location, 
+            view_align=False, 
+            major_radius=1, 
+            minor_radius=0.25, 
+            major_segments=48, 
+            minor_segments=12, 
+            use_abso=False, 
+            abso_major_rad=1, 
+            abso_minor_rad=0.5)     
+
+    new_atom = bpy.context.scene.objects.active
+    # Scale, material and name it.
+    new_atom.scale = scale
+    new_atom.active_material = material
+    new_atom.name = name + "_sep"
+    new_atom.select = True        
+
+
+
+def separate_draw_regular(name, child, location, scale, material):
+
+    current_layers=bpy.context.scene.layers
+    if "Vacancy" not in name:
+        # NURBS ball
+        if child.type == "SURFACE":
+            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)
-                # Mesh ball                    
-            elif obj.children[0].type == "MESH":
-                bpy.ops.mesh.primitive_uv_sphere_add(
+        # Mesh ball                    
+        elif child.type == "MESH":
+            bpy.ops.mesh.primitive_uv_sphere_add(
                                 segments=32,
                                 ring_count=32,                    
-                                #segments=scn.mesh_azimuth,
-                                #ring_count=scn.mesh_zenith,
                                 size=1, view_align=False, enter_editmode=False,
                                 location=location,
                                 rotation=(0, 0, 0),
                                 layers=current_layers)
-                # Metaball
-            elif obj.children[0].type == "META":
-                bpy.ops.object.metaball_add(type='BALL', view_align=False, 
+        # Metaball
+        elif child.type == "META":
+            bpy.ops.object.metaball_add(type='BALL', view_align=False, 
                             enter_editmode=False, location=location, 
                             rotation=(0, 0, 0), layers=current_layers)
-        # If it is a vacancy create a cube ...                    
-        else:
-            bpy.ops.mesh.primitive_cube_add(
+    # If it is a vacancy create a cube ...                    
+    else:
+        bpy.ops.mesh.primitive_cube_add(
                            view_align=False, enter_editmode=False,
                            location=location,
                            rotation=(0.0, 0.0, 0.0),
                            layers=current_layers)
-                               
-        new_atom = bpy.context.scene.objects.active
-        # Scale, material and name it.
-        new_atom.scale = scale
-        new_atom.active_material = material
-        new_atom.name = name + "_sep"
-        new_atom.select = True
-
-    bpy.context.scene.objects.active = obj
-    #bpy.ops.object.select_all(action='DESELECT')
+                           
+    new_atom = bpy.context.scene.objects.active
+    # Scale, material and name it.
+    new_atom.scale = scale
+    new_atom.active_material = material
+    new_atom.name = name + "_sep"
+    new_atom.select = True
+                           



More information about the Bf-extensions-cvs mailing list