Skip to content
Snippets Groups Projects
Commit 0b4e923d authored by Clemens Barth's avatar Clemens Barth
Browse files

1. New: NURBS, mesh and meta balls can now be chosen as atoms.

   I also updated the Wiki page.
2. There was a small mistake introduced by the last commits. This has been 
   fixed.
3. Code cleaning

Blendphys
parent cdab4a56
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ bl_info = { ...@@ -50,7 +50,7 @@ bl_info = {
} }
import bpy import bpy
from bpy.types import Operator, Panel from bpy.types import Operator
from bpy_extras.io_utils import ImportHelper, ExportHelper from bpy_extras.io_utils import ImportHelper, ExportHelper
from bpy.props import (StringProperty, from bpy.props import (StringProperty,
BoolProperty, BoolProperty,
...@@ -79,9 +79,13 @@ class ImportPDB(Operator, ImportHelper): ...@@ -79,9 +79,13 @@ class ImportPDB(Operator, ImportHelper):
use_lamp = BoolProperty( use_lamp = BoolProperty(
name="Lamp", default=False, name="Lamp", default=False,
description = "Do you need a lamp?") description = "Do you need a lamp?")
use_mesh = BoolProperty( ball = EnumProperty(
name = "Mesh balls", default=False, name="Type of ball",
description = "Use mesh balls instead of NURBS") description="Choose ball",
items=(('0', "NURBS", "NURBS balls"),
('1', "Mesh" , "Mesh balls"),
('2', "Meta" , "Metaballs")),
default='0',)
mesh_azimuth = IntProperty( mesh_azimuth = IntProperty(
name = "Azimuth", default=32, min=1, name = "Azimuth", default=32, min=1,
description = "Number of sectors (azimuth)") description = "Number of sectors (azimuth)")
...@@ -139,9 +143,10 @@ class ImportPDB(Operator, ImportHelper): ...@@ -139,9 +143,10 @@ class ImportPDB(Operator, ImportHelper):
row.prop(self, "use_lamp") row.prop(self, "use_lamp")
row = layout.row() row = layout.row()
col = row.column() col = row.column()
col.prop(self, "use_mesh") col.prop(self, "ball")
col = row.column(align=True) row = layout.row()
col.active = self.use_mesh row.active = (self.ball == "1")
col = row.column(align=True)
col.prop(self, "mesh_azimuth") col.prop(self, "mesh_azimuth")
col.prop(self, "mesh_zenith") col.prop(self, "mesh_zenith")
row = layout.row() row = layout.row()
...@@ -179,8 +184,8 @@ class ImportPDB(Operator, ImportHelper): ...@@ -179,8 +184,8 @@ class ImportPDB(Operator, ImportHelper):
filepath_pdb = bpy.path.abspath(self.filepath) filepath_pdb = bpy.path.abspath(self.filepath)
# Execute main routine # Execute main routine
atom_number = import_pdb.import_pdb( import_pdb.import_pdb(
self.use_mesh, self.ball,
self.mesh_azimuth, self.mesh_azimuth,
self.mesh_zenith, self.mesh_zenith,
self.scale_ballradius, self.scale_ballradius,
......
...@@ -35,7 +35,7 @@ def export_pdb(obj_type, filepath_pdb): ...@@ -35,7 +35,7 @@ def export_pdb(obj_type, filepath_pdb):
if "Stick" in obj.name: if "Stick" in obj.name:
continue continue
if obj.type != "SURFACE" and obj.type != "MESH": if obj.type not in {'MESH', 'SURFACE', 'META'}:
continue continue
name = "" name = ""
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
import bpy import bpy
import os
from math import pi, cos, sin, sqrt, ceil from math import pi, cos, sin, sqrt, ceil
from mathutils import Vector, Matrix from mathutils import Vector, Matrix
from copy import copy from copy import copy
...@@ -245,11 +244,12 @@ def read_pdb_file(filepath_pdb, radiustype): ...@@ -245,11 +244,12 @@ def read_pdb_file(filepath_pdb, radiustype):
color = [0,0,0] color = [0,0,0]
location = Vector((0,0,0)) location = Vector((0,0,0))
# Append the TER into the list. Material remains empty so far. # Append the TER into the list. Material remains empty so far.
all_atoms.append(AtomProp(short_name, all_atoms.append(AtomProp(short_name,
name, name,
location, location,
radius, radius,
color,[])) color,[]))
# If 'ATOM or 'HETATM' appears in the line then do ... # If 'ATOM or 'HETATM' appears in the line then do ...
elif "ATOM" in line or "HETATM" in line: elif "ATOM" in line or "HETATM" in line:
...@@ -345,7 +345,7 @@ def read_pdb_file(filepath_pdb, radiustype): ...@@ -345,7 +345,7 @@ def read_pdb_file(filepath_pdb, radiustype):
return (Number_of_total_atoms, all_atoms) return (Number_of_total_atoms, all_atoms)
def read_pdb_file_sticks(filepath_pdb, use_sticks_bonds): def read_pdb_file_sticks(filepath_pdb, use_sticks_bonds, all_atoms):
# The list of all sticks. # The list of all sticks.
all_sticks = [] all_sticks = []
...@@ -529,7 +529,7 @@ def build_stick(radius, length, sectors): ...@@ -529,7 +529,7 @@ def build_stick(radius, length, sectors):
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# The main routine # The main routine
def import_pdb(use_mesh, def import_pdb(Ball_type,
Ball_azimuth, Ball_azimuth,
Ball_zenith, Ball_zenith,
Ball_radius_factor, Ball_radius_factor,
...@@ -623,7 +623,9 @@ def import_pdb(use_mesh, ...@@ -623,7 +623,9 @@ def import_pdb(use_mesh,
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# READING DATA OF STICKS # READING DATA OF STICKS
all_sticks = read_pdb_file_sticks(filepath_pdb, use_sticks_bonds) all_sticks = read_pdb_file_sticks(filepath_pdb,
use_sticks_bonds,
all_atoms)
# So far, all atoms, sticks and materials have been registered. # So far, all atoms, sticks and materials have been registered.
...@@ -828,18 +830,23 @@ def import_pdb(use_mesh, ...@@ -828,18 +830,23 @@ def import_pdb(use_mesh,
layers=current_layers) layers=current_layers)
else: else:
# NURBS balls # NURBS balls
if use_mesh == False: if Ball_type == "0":
bpy.ops.surface.primitive_nurbs_surface_sphere_add( bpy.ops.surface.primitive_nurbs_surface_sphere_add(
view_align=False, enter_editmode=False, view_align=False, enter_editmode=False,
location=(0,0,0), rotation=(0.0, 0.0, 0.0), location=(0,0,0), rotation=(0.0, 0.0, 0.0),
layers=current_layers) layers=current_layers)
# UV balls # UV balls
else: elif Ball_type == "1":
bpy.ops.mesh.primitive_uv_sphere_add( bpy.ops.mesh.primitive_uv_sphere_add(
segments=Ball_azimuth, ring_count=Ball_zenith, segments=Ball_azimuth, ring_count=Ball_zenith,
size=1, view_align=False, enter_editmode=False, size=1, view_align=False, enter_editmode=False,
location=(0,0,0), rotation=(0, 0, 0), location=(0,0,0), rotation=(0, 0, 0),
layers=current_layers) layers=current_layers)
# Meta balls
elif Ball_type == "2":
bpy.ops.object.metaball_add(type='BALL', view_align=False,
enter_editmode=False, location=(0, 0, 0),
rotation=(0, 0, 0), layers=current_layers)
ball = bpy.context.scene.objects.active ball = bpy.context.scene.objects.active
ball.scale = (atom[3]*Ball_radius_factor,) * 3 ball.scale = (atom[3]*Ball_radius_factor,) * 3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment