diff --git a/io_mesh_pdb/__init__.py b/io_mesh_pdb/__init__.py index a7552352ac8ec78d1e33a74bedc5bd7d31cd1d5d..bed41f996463b3d564500fadfc57491b43a1f9a0 100644 --- a/io_mesh_pdb/__init__.py +++ b/io_mesh_pdb/__init__.py @@ -194,7 +194,7 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup): scnn.atom_pdb_radius_how, ) - # In the file dialog window + # In the file dialog window - Import scn = bpy.types.Scene scn.use_atom_pdb_cam = BoolProperty( name="Camera", default=False, @@ -249,6 +249,14 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup): ('2', "van der Waals", "Use van der Waals radius")), default='0',) + # In the file dialog window - Export + scn.atom_pdb_export_type = EnumProperty( + name="Type of Objects", + description="Choose type of objects", + items=(('0', "All", "Export all active objects"), + ('1', "Elements", "Export only those active objects which have a proper element name")), + default='1',) + # In the panel scn.atom_pdb_datafile = StringProperty( name = "", description="Path to your custom data file", @@ -612,12 +620,15 @@ class ExportPDB(Operator, ExportHelper): layout = self.layout scn = bpy.context.scene + row = layout.row() + row.prop(scn, "atom_pdb_export_type") + def execute(self, context): scn = bpy.context.scene # This is in order to solve this strange 'relative path' thing. export_pdb.ATOM_PDB_FILEPATH = bpy.path.abspath(self.filepath) - export_pdb.DEF_atom_pdb_export() + export_pdb.DEF_atom_pdb_export(scn.atom_pdb_export_type) return {'FINISHED'} diff --git a/io_mesh_pdb/export_pdb.py b/io_mesh_pdb/export_pdb.py index 22d1f01508cd496f2f837726c4e5658f81654a5b..a23d0fd9c09d3aace35d9483c8ac7c555813fae1 100644 --- a/io_mesh_pdb/export_pdb.py +++ b/io_mesh_pdb/export_pdb.py @@ -25,7 +25,7 @@ # # Start of project : 2011-08-31 by Clemens Barth # First publication in Blender : 2011-11-11 -# Last modified : 2012-02-27 +# Last modified : 2012-02-29 # # Acknowledgements: Thanks to ideasman, meta_androcto, truman, kilon, # dairin0d, PKHG, Valter, etc @@ -61,7 +61,7 @@ class CLASS_atom_pdb_atoms_export(object): -def DEF_atom_pdb_export(): +def DEF_atom_pdb_export(obj_type): list_atoms = [] for obj in bpy.context.selected_objects: @@ -71,27 +71,37 @@ def DEF_atom_pdb_export(): if obj.type != "SURFACE" and obj.type != "MESH": continue - - for element in import_pdb.ATOM_PDB_ELEMENTS: - if element.name in obj.name: - if element.short_name == "Vac": + + name = "" + for element in import_pdb.ATOM_PDB_ELEMENTS_DEFAULT: + if element[1] in obj.name: + if element[2] == "Vac": name = "X" else: - name = element.short_name - - if len(obj.children) != 0: - for vertex in obj.data.vertices: - list_atoms.append(CLASS_atom_pdb_atoms_export( + name = element[2] + elif element[1][:3] in obj.name: + if element[2] == "Vac": + name = "X" + else: + name = element[2] + + if name == "": + if obj_type == "0": + name = "?" + else: + continue + + if len(obj.children) != 0: + for vertex in obj.data.vertices: + list_atoms.append(CLASS_atom_pdb_atoms_export( name, obj.location+vertex.co)) - - else: - if not obj.parent: - list_atoms.append(CLASS_atom_pdb_atoms_export( + else: + if not obj.parent: + list_atoms.append(CLASS_atom_pdb_atoms_export( name, obj.location)) - - + pdb_file_p = open(ATOM_PDB_FILEPATH, "w") pdb_file_p.write(ATOM_PDB_PDBTEXT) diff --git a/io_mesh_pdb/import_pdb.py b/io_mesh_pdb/import_pdb.py index 2491d4fc2357680ee41dd698be30dce88074450d..1c2abe0506b4181bbf664594799624d6f818c8e5 100644 --- a/io_mesh_pdb/import_pdb.py +++ b/io_mesh_pdb/import_pdb.py @@ -25,7 +25,7 @@ # # Start of project : 2011-08-31 by Clemens Barth # First publication in Blender : 2011-11-11 -# Last modified : 2012-02-27 +# Last modified : 2012-02-29 # # Acknowledgements: Thanks to ideasman, meta_androcto, truman, kilon, # dairin0d, PKHG, Valter, etc @@ -1170,7 +1170,7 @@ def DEF_atom_pdb_main(use_mesh,Ball_azimuth,Ball_zenith, if atom[0] == "Vacancy": ball.name = "Cube_"+atom[0] else: - ball.name = "Ball (NURBS)_"+atom[0] + ball.name = "Ball_"+atom[0] ball.active_material = atom[1] ball.parent = new_atom_mesh new_atom_mesh.dupli_type = 'VERTS'