diff --git a/io_mesh_atomic/pdb_import.py b/io_mesh_atomic/pdb_import.py index 635c3c0901e8cdeceb26e41fe7c300890bc62b3a..11bdb9728cea4ab630fd9d06b453d1980bff3d07 100644 --- a/io_mesh_atomic/pdb_import.py +++ b/io_mesh_atomic/pdb_import.py @@ -542,7 +542,7 @@ def build_stick(radius, length, sectors, element_name): # Attention: the linking will be done a few moments later, after this # is done definition. - return (new_cylinder, new_cups) + return new_cylinder, new_cups # Rotate an object. @@ -864,7 +864,8 @@ def draw_sticks_dupliverts(all_atoms, faces = [] i = 0 - # What follows is school mathematics! :-) + # What follows is school mathematics! :-) We construct equidistant + # planes, on which the stcik sections (cylinders) are perpendicular on. for stick in stick_list: dv = stick[2] @@ -881,11 +882,15 @@ def draw_sticks_dupliverts(all_atoms, for j in range(loops): + # The plane, which is normal to the length of the cylinder, + # will have a 1/100 of the stick diameter. => When decreasing + # the size of the stick diameter, the plane will not be visible. + f = 0.01 g = v1 - n * dl / 2.0 - n * dl * j - p1 = g + n_b * Stick_diameter - p2 = g - n_b * Stick_diameter - p3 = g - n_b.cross(n) * Stick_diameter - p4 = g + n_b.cross(n) * Stick_diameter + p1 = g + n_b * Stick_diameter * f + p2 = g - n_b * Stick_diameter * f + p3 = g - n_b.cross(n) * Stick_diameter * f + p4 = g + n_b.cross(n) * Stick_diameter * f vertices.append(p1) vertices.append(p2) @@ -914,19 +919,17 @@ def draw_sticks_dupliverts(all_atoms, # Link active object to the new collection coll.objects.link(new_mesh) - # Build the object. - # Get the cylinder from the 'build_stick' function. - object_stick = build_stick(Stick_diameter, - dl, - Stick_sectors, - stick[0][1:]) - # Link active object to the new collection - coll.objects.link(object_stick[0]) - coll.objects.link(object_stick[1]) + # Build the object. Get the cylinder from the 'build_stick' function. + stick_cylinder, stick_cups = build_stick(Stick_diameter, + dl, + Stick_sectors, + stick[0][1:]) + # Link active object to the new collection. + coll.objects.link(stick_cylinder) + coll.objects.link(stick_cups) - stick_cylinder = object_stick[0] + # Assign the material. stick_cylinder.active_material = stick[3] - stick_cups = object_stick[1] stick_cups.active_material = stick[3] # Smooth the cylinders.