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

Clemens Barth barth at root-1.de
Sun Dec 18 19:14:03 CET 2011


Revision: 2788
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2788
Author:   blendphys
Date:     2011-12-18 18:13:56 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------


Dear all.

So this is my second project and importer for Blender: 

                          Atomic Blender - XYZ

Atomic Blender - XYZ imports all atoms, which are described in a xyz file 
(*.xyz). It even imports all frames, and it links each frame to a shape key such 
that nice animations can be done with Blender. The importer is probably not 
that exciting for the normal user but very useful for scientists (especially 
theorists) who store atom positions and snapshots of calculations into these 
type of files.

Here are some links:

Atomic Blender
==============
http://development.root-1.de/Atomic_Blender.php

Description 
============
http://development.root-1.de/Atomic_Blender_XYZ.php

Wiki
====
http://development.root-1.de/Atomic_Blender_XYZ_Wiki.php

Examples
========
http://development.root-1.de/Atomic_Blender_XYZ_Examples.php


Have fun with the movies! :-) 

Tell me what you think.

Cheers,

Blendphys 

Added Paths:
-----------
    contrib/py/scripts/addons/io_mesh_xyz/
    contrib/py/scripts/addons/io_mesh_xyz/__init__.py
    contrib/py/scripts/addons/io_mesh_xyz/atom_info.dat
    contrib/py/scripts/addons/io_mesh_xyz/import_xyz.py

Added: contrib/py/scripts/addons/io_mesh_xyz/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_mesh_xyz/__init__.py	                        (rev 0)
+++ contrib/py/scripts/addons/io_mesh_xyz/__init__.py	2011-12-18 18:13:56 UTC (rev 2788)
@@ -0,0 +1,728 @@
+# ##### 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 #####
+
+bl_info = {
+    "name": "XYZ Atomic Blender",
+    "description": "Loading and manipulating atoms from XYZ files",
+    "author": "Clemens Barth",
+    "version": (0,5),
+    "blender": (2,6),
+    "api": 31236,
+    "location": "File -> Import -> XYZ (.xyz), Panel: View 3D - Tools",
+    "warning": "",
+    "wiki_url": "http://development.root-1.de/Atomic_Blender.php",
+    "tracker_url": "http://projects.blender.org/tracker/"
+                   "index.php?func=detail&aid=29646&group_id=153&atid=468",
+    "category": "Import-Export"
+}
+
+
+import bpy
+from bpy.types import Operator, Panel
+from bpy_extras.io_utils import ImportHelper
+from bpy.props import (StringProperty,
+                       BoolProperty,
+                       EnumProperty,
+                       IntProperty,
+                       FloatProperty)
+
+
+
+from . import import_xyz
+ATOM_XYZ_ERROR = ""
+
+# -----------------------------------------------------------------------------
+#                                                                           GUI
+
+# This is the panel, which can be used to prepare the scene.
+# It is loaded after the file has been chosen via the menu 'File -> Import'
+class CLASS_atom_xyz_prepare_panel(Panel):
+    bl_label       = "XYZ - Atomic Blender"
+    #bl_space_type  = "PROPERTIES"
+    #bl_region_type = "WINDOW"
+    #bl_context     = "physics"
+    # This could be also an option ... :
+    bl_space_type  = "VIEW_3D"
+    bl_region_type = "TOOL_PROPS"
+
+    @classmethod
+    def poll(self, context):
+        if import_xyz.ATOM_XYZ_FILEPATH == "":
+            return False
+        else:
+            return True
+
+    def draw(self, context):
+        layout = self.layout
+        scn    = bpy.context.scene
+
+        row = layout.row()
+        row.label(text="Outputs and custom data file")
+
+        box = layout.box()
+        row = box.row()
+        row.label(text="Custom data file")
+        row = box.row()
+        col = row.column()
+        col.prop(scn, "atom_xyz_datafile")
+        col.operator("atom_xyz.datafile_apply")
+        row = box.row()
+        col = row.column(align=True)
+        col.prop(scn, "atom_xyz_XYZ_file")
+        row = box.row()
+        # TODO, use lanel() instead
+        row.prop(scn, "atom_xyz_number_atoms")
+        row = box.row()
+        row.operator("atom_xyz.button_distance")
+        row.prop(scn, "atom_xyz_distance")
+
+        row = layout.row()
+        row.label(text="Choice of atom radii")
+        box = layout.box()
+
+        row = box.row()
+        row.label(text="All changes concern:")
+        row = box.row()
+        row.prop(scn, "atom_xyz_radius_how")
+
+        row = box.row()
+        row.label(text="1. Change type of radii")
+        row = box.row()
+        row.prop(scn, "atom_xyz_radius_type")
+
+        row = box.row()
+        row.label(text="2. Change atom radii in pm")
+        row = box.row()
+        row.prop(scn, "atom_xyz_radius_pm_name")
+        row = box.row()
+        row.prop(scn, "atom_xyz_radius_pm")
+
+        row = box.row()
+        row.label(text="3. Change atom radii by scale")
+        row = box.row()
+        col = row.column()
+        col.prop(scn, "atom_xyz_radius_all")
+        col = row.column(align=True)
+        col.operator( "atom_xyz.radius_all_bigger" )
+        col.operator( "atom_xyz.radius_all_smaller" )
+
+        if bpy.context.mode == 'EDIT_MESH':
+
+            layout.separator()
+            row = box.row()
+            row.operator( "atom_xyz.separate_atom" )
+
+        row = layout.row()
+        row.label(text="Loading frames")
+
+        box = layout.box()
+        row = box.row()
+        col = row.column()
+        col.label(text="Frames")
+        col = row.column()
+        col.prop(scn, "atom_xyz_number_frames")
+        row = box.row()
+        col = row.column()
+        col.label(text="Skip frames")
+        col = row.column()
+        col.prop(scn, "atom_xyz_skip_frames")
+        row = box.row()
+        col = row.column()
+        col.label(text="Frames/key")
+        col = row.column()
+        col.prop(scn, "atom_xyz_images_per_key")        
+        
+        row = box.row()
+        row.operator("atom_xyz.load_frames")
+        row = box.row()
+        row.operator("atom_xyz.delete_keys")
+        row = box.row()
+        row.operator( "atom_xyz.create_command")
+        row = box.row()
+        row.operator( "atom_xyz.render")
+
+
+class CLASS_atom_xyz_IO(bpy.types.PropertyGroup):
+
+    def Callback_radius_type(self, context):
+        scnn = bpy.context.scene
+        import_xyz.DEF_atom_xyz_radius_type(
+                scnn.atom_xyz_radius_type,
+                scnn.atom_xyz_radius_how,
+                )
+
+    def Callback_radius_pm(self, context):
+        scnn = bpy.context.scene
+        import_xyz.DEF_atom_xyz_radius_pm(
+                scnn.atom_xyz_radius_pm_name,
+                scnn.atom_xyz_radius_pm,
+                scnn.atom_xyz_radius_how,
+                )
+
+    # In the file dialog window
+    scn = bpy.types.Scene
+    scn.use_atom_xyz_cam = BoolProperty(
+        name="Camera", default=False,
+        description="Do you need a camera?")
+    scn.use_atom_xyz_lamp = BoolProperty(
+        name="Lamp", default=False,
+        description = "Do you need a lamp?")
+    scn.use_atom_xyz_mesh = BoolProperty(
+        name = "Mesh balls", default=False,
+        description = "Do you want to use mesh balls instead of NURBS?")
+    scn.atom_xyz_mesh_azimuth = IntProperty(
+        name = "Azimuth", default=32, min=0,
+        description = "Number of sectors (azimuth)")
+    scn.atom_xyz_mesh_zenith = IntProperty(
+        name = "Zenith", default=32, min=0,
+        description = "Number of sectors (zenith)")
+    scn.atom_xyz_scale_ballradius = FloatProperty(
+        name = "Balls", default=1.0, min=0.0,
+        description = "Scale factor for all atom radii")
+    scn.atom_xyz_scale_distances = FloatProperty (
+        name = "Distances", default=1.0, min=0.0,
+        description = "Scale factor for all distances")
+    scn.use_atom_xyz_center = BoolProperty(
+        name = "Object to origin", default=False,
+        description = "Shall the object first put into the global origin "
+        "before applying the offsets on the left?")
+    scn.atom_xyz_atomradius = EnumProperty(
+        name="Type of radius",
+        description="Choose type of atom radius",
+        items=(('0', "Pre-defined", "Use pre-defined radii"),
+               ('1', "Atomic", "Use atomic radii"),
+               ('2', "van der Waals", "Use van der Waals radii")),
+               default='0',)
+
+    # In the panel, first part
+    scn.atom_xyz_datafile = StringProperty(
+        name = "", description="Path to your custom data file",
+        maxlen = 256, default = "", subtype='FILE_PATH')
+    scn.atom_xyz_XYZ_file = StringProperty(
+        name = "Path to file", default="",
+        description = "Path of the XYZ file")
+    # TODO, remove this property, its used for display only!
+    scn.atom_xyz_number_atoms = StringProperty(name="",
+        default="Number", description = "This output shows "
+        "the number of atoms which have been loaded")
+    scn.atom_xyz_distance = StringProperty(
+        name="", default="Distance (A)",
+        description="Distance of 2 objects in Angstrom")
+    scn.atom_xyz_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',)
+    scn.atom_xyz_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)
+    scn.atom_xyz_radius_pm_name = StringProperty(
+        name="", default="Atom name",
+        description="Put in the name of the atom (e.g. Hydrogen)")
+    scn.atom_xyz_radius_pm = FloatProperty(
+        name="", default=100.0, min=0.0,
+        description="Put in the radius of the atom (in pm)",
+        update=Callback_radius_pm)
+    scn.atom_xyz_radius_all = FloatProperty(
+        name="Scale", default = 1.05, min=1.0,
+        description="Put in the scale factor")
+
+
+    # In the panel, second part
+    scn.atom_xyz_number_frames = StringProperty(
+        name="", default="0",
+        description="This is the total number of frames stored in the xyz file")
+    scn.atom_xyz_skip_frames = IntProperty(
+        name="", default=0, min=0,
+        description="Number of frames you want to skip.")
+    scn.atom_xyz_images_per_key = IntProperty(
+        name="", default=1, min=0,
+        description="Choose the number of images between 2 keys.")
+
+
+
+# Button for creating a file that contains the command for rendering
+class CLASS_atom_xyz_create_command(Operator):
+    bl_idname = "atom_xyz.create_command"
+    bl_label = "Create command"
+    bl_description = "Create a shell command for rendering the scene"
+
+    def execute(self, context):
+        global ATOM_XYZ_ERROR
+        import os
+ 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list