-
-
Save zeffii/c2ea0971d7fc4424eef0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kdArrange | |
import bpy | |
from collections import defaultdict | |
''' | |
[x] step 01: first store atoms as {element_name: [co,..], } | |
[ ] step 02: generate singular ordered mesh by adding vertices | |
in clumps of element types. (H,H,H,H,H,H,O,O,O,O,O,O..) | |
[ ] step 03: track start and end index for each element into mapper_obj | |
[ ] step 04: get surface mesh. | |
[ ] step 05: for every vertex on surface mesh find closest | |
vertex in proxy_ob, and MLP value | |
''' | |
# step 01 | |
# attrs = [a for a in dir(o) if a.startswith('bb2')] | |
attrs = [ | |
'bb2_objectType', | |
'bb2_outputOptions', | |
'bb2_pdbID', | |
'bb2_pdbPath', | |
'bb2_subID', | |
'BBInfo' | |
] | |
proxy_obj = defaultdict(list) | |
nstr = '_4GE.001' | |
objs = bpy.data.objects[nstr].children | |
count = 0 | |
for o in objs: | |
if count > 120: | |
break | |
for a in attrs: | |
print(a, ':', getattr(o, a)) | |
# coincides and is a relatively fast lookup | |
element_name = o.active_material.name | |
co = o.location[:] | |
proxy_obj[element_name].append(co) | |
count += 1 | |
# step 03 | |
mapper_obj = {} | |
verts = [] | |
for key in sorted(proxy_obj.keys()): | |
start = len(verts) | |
verts.extend(proxy_obj[key]) | |
end = len(verts)-1 | |
mapper_obj[key] = (start, end) | |
# print(mapper_obj) | |
# {'C': (0, 97), 'N': (98, 124), 'O': (125, 153)} | |
# step 02 | |
mesh = bpy.data.meshes.new("mesh_name") | |
mesh.from_pydata(verts, edges=[], faces=[]) | |
mesh.update() | |
obj = bpy.data.objects.new("obj_name", mesh) | |
scene = bpy.context.scene | |
scene.objects.link(obj) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment