[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2809] trunk/py/scripts/addons/ io_mesh_pdb:
Clemens Barth
barth at root-1.de
Mon Dec 26 18:20:52 CET 2011
Revision: 2809
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2809
Author: blendphys
Date: 2011-12-26 17:20:44 +0000 (Mon, 26 Dec 2011)
Log Message:
-----------
... only small changes, that's it ...
Cheers,
Blendphys
Modified Paths:
--------------
trunk/py/scripts/addons/io_mesh_pdb/__init__.py
trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py
Modified: trunk/py/scripts/addons/io_mesh_pdb/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/__init__.py 2011-12-26 08:14:24 UTC (rev 2808)
+++ trunk/py/scripts/addons/io_mesh_pdb/__init__.py 2011-12-26 17:20:44 UTC (rev 2809)
@@ -45,6 +45,8 @@
# TODO, allow reload
from . import import_pdb
+ATOM_PDB_ERROR = ""
+
# -----------------------------------------------------------------------------
# GUI
@@ -201,7 +203,7 @@
description = "Do you need a lamp?")
scn.use_atom_pdb_mesh = BoolProperty(
name = "Mesh balls", default=False,
- description = "Do you want to use mesh balls instead of NURBS?")
+ description = "Use mesh balls instead of NURBS")
scn.atom_pdb_mesh_azimuth = IntProperty(
name = "Azimuth", default=32, min=0,
description = "Number of sectors (azimuth)")
@@ -216,11 +218,10 @@
description = "Scale factor for all distances")
scn.use_atom_pdb_center = BoolProperty(
name = "Object to origin", default=True,
- description = "Shall the object first put into the global origin "
- "before applying the offsets on the left?")
+ description = "Put the object into the global origin")
scn.use_atom_pdb_sticks = BoolProperty(
name="Use sticks", default=False,
- description="Do you want to display also the sticks?")
+ description="Do you want to display the sticks?")
scn.atom_pdb_sticks_sectors = IntProperty(
name = "Sector", default=20, min=0,
description="Number of sectors of a stick")
@@ -228,8 +229,8 @@
name = "Radius", default=0.1, min=0.0,
description ="Radius of a stick")
scn.use_atom_pdb_sticks_color = BoolProperty(
- name="Color of atoms", default=False,
- description="Shall the sticks appear in the color of the atoms?")
+ name="Color", default=False,
+ description="The sticks appear in the color of the atoms")
scn.atom_pdb_atomradius = EnumProperty(
name="Type of radius",
description="Choose type of atom radius",
@@ -281,7 +282,7 @@
class CLASS_atom_pdb_datafile_apply(Operator):
bl_idname = "atom_pdb.datafile_apply"
bl_label = "Apply"
- bl_description = "Use color and radii values stored in a custom file"
+ bl_description = "Use color and radii values stored in the custom file"
def execute(self, context):
scn = bpy.context.scene
@@ -386,7 +387,7 @@
class CLASS_atom_pdb_distance_button(Operator):
bl_idname = "atom_pdb.button_distance"
bl_label = "Measure ..."
- bl_description = "Measure the distance between two objects"
+ bl_description = "Measure the distance between two objects (only in Object Mode)"
def execute(self, context):
scn = bpy.context.scene
@@ -443,11 +444,19 @@
bl_description = "Show only the sticks (atom radii = stick radii)"
def execute(self, context):
+ global ATOM_PDB_ERROR
+
scn = bpy.context.scene
- import_pdb.DEF_atom_pdb_radius_sticks(
+
+ result = import_pdb.DEF_atom_pdb_radius_sticks(
scn.atom_pdb_sticks_radius,
scn.atom_pdb_radius_how,
)
+
+ if result == False:
+ ATOM_PDB_ERROR = "No sticks => no changes"
+ bpy.ops.atom_pdb.error_dialog('INVOKE_DEFAULT')
+
return {'FINISHED'}
@@ -562,6 +571,21 @@
return {'FINISHED'}
+class CLASS_atom_pdb_error_dialog(bpy.types.Operator):
+ bl_idname = "atom_pdb.error_dialog"
+ bl_label = "Attention !"
+
+ def draw(self, context):
+ layout = self.layout
+ row = layout.row()
+ row.label(text=" "+ATOM_PDB_ERROR)
+ def execute(self, context):
+ print("Atomic Blender - Error: "+ATOM_PDB_ERROR+"\n")
+ return {'FINISHED'}
+ def invoke(self, context, event):
+ return context.window_manager.invoke_props_dialog(self)
+
+
# The entry into the menu 'file -> import'
def menu_func(self, context):
self.layout.operator(ImportPDB.bl_idname, text="Protein Data Bank (.pdb)")
Modified: trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py 2011-12-26 08:14:24 UTC (rev 2808)
+++ trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py 2011-12-26 17:20:44 UTC (rev 2809)
@@ -415,6 +415,8 @@
# for showing the sticks.
def DEF_atom_pdb_radius_sticks(radius, how):
+ # Are there any sticks?
+ Found = False
if how == "ALL_IN_LAYER":
layers = []
@@ -428,7 +430,44 @@
if obj.layers[layer] == True:
change_objects.append(obj)
+ for obj in change_objects:
+ if len(obj.children) != 0:
+ if obj.children[0].type == "SURFACE" or obj.children[0].type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+ else:
+ if obj.type == "SURFACE" or obj.type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+ if how == "ALL_ACTIVE":
+ for obj in bpy.context.selected_objects:
+ if len(obj.children) != 0:
+ if obj.children[0].type == "SURFACE" or obj.children[0].type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+ else:
+ if obj.type == "SURFACE" or obj.type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+
+ if Found == False:
+ return False
+
+ if how == "ALL_IN_LAYER":
+
+ layers = []
+ for i in range(20):
+ if bpy.context.scene.layers[i] == True:
+ layers.append(i)
+
+ change_objects = []
+ for obj in bpy.context.scene.objects:
+ for layer in layers:
+ if obj.layers[layer] == True:
+ change_objects.append(obj)
+
+
for obj in change_objects:
if len(obj.children) != 0:
if obj.children[0].type == "SURFACE" or obj.children[0].type == "MESH":
@@ -450,6 +489,7 @@
if "Stick" not in obj.name:
obj.scale = (radius,) * 3
+ return True
# This reads a custom data file.
More information about the Bf-extensions-cvs
mailing list