Created
February 24, 2015 13:34
-
-
Save anonymous/85691b7c3bc8bb23a466 to your computer and use it in GitHub Desktop.
test
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: for every vertex on surface mesh find closest | |
vertex in proxy_ob, and MLP value | |
''' | |
# step 01 | |
proxy_obj = defaultdict(list) | |
nstr = '_4GE.001' | |
objs = bpy.data.objects[nstr].children | |
for o in objs: | |
# coincides and is a relatively fast lookup | |
element_name = o.active_material.name | |
co = o.location[:] | |
proxy_obj[element_name].append(co) | |
# step 03 | |
mapper_obj = {} | |
verts = [] | |
for key in sorted(proxy_obj.keys()): | |
start = len(verts) | |
verts.extend(proxy_obj[key]) | |
end = len(verts) | |
mapper_obj[key] = (start, end) | |
# {'C': (0, 98), 'N': (98, 125), 'O': (125, 154)} | |
# 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