Replies: 2 comments 1 reply
-
Hello! I have to at first apologise for the state of the python API & the documentation around it. The plan is to eventually have everything be scriptable and easier to interact with - but currently it's all a bit messy. In short - yes this is very possible. How you would go about this is changing, with 4.2 coming for Blender 4.2 in the next week (#501). There are two different sets of data that we are working with inside of Blender / Molecular Nodes. There is the molecular data, that is accessible currently through the Once an The reason you are seeing different lengths of the arrays, is that there has been some filtering applied when creating the object (removing solvent / water atoms). >>> m = mn.io.fetch('7eow')
>>> m.get_attribute('b_factor').shape
(2600,)
>>> m.get_attribute('Color').shape
(2600, 4)
>>> m.array.b_factor.shape
(2980,) This has been discussed a bit in the #359 and like I said is being majorly overhauled in the 4.2 update #501. There is still lots to be improved, and I especially welcome and want to hear from people on use cases, and how they would like to interact with the data. What is going to change for 4.2 is that accessing attributes on the object will become the following for reading and writing from the 3D object. This brings it to better align with the node names inside of Blender / Geometry Nodes and better distinguishes it from python attributes. mol.named_attribute()
mol.store_named_attribute() The idea will be that you can generate some color values using python and store them on the Object which will be used when creating the 3D mesh. mol = mn.io.fetch('7eow')
mol.create_object(color=None) # this would stop the overriding of colors in the node tree
new_colors = some_color_function(mol.named_attribute('b_factor'))
mol.store_named_attribute(new_colors, 'Color') Currently the The new API design will be that the Like I have said previously, I would love feedback and suggestions on design, and how people would like to be using this. The priority for Molecular Nodes is to be a GUI application, aimed to be used via Blender doing pointing and clicking (mostly because Blender is mostly designed this way) - but I would like to better support usage in scripting workflows. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thank you for the quick reply! First of all, you do not have to apologize for anything, since this package is insane and I want to thank you for that :) Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am trying to customize my molecules a little bit and would like to integrate that into a python pipeline. As a starting point I would like to change the color of the molecule where different parts have varying colors. I wanted to ask for the feasibility of that, since I tried to find a solution but was not very successful with that.
Thus, I get an error when I try to assign the b_factor column to the Color attribute with set_attributes.
In another attempt I tried to just use the color flag from the fetch function but the color does not really change even if I use the create_starting_node_tree function directly with the following code snippets:
Nothing really happens for both codes. So the general goal is to parse an array with values and the molecule is colored differently according to this array. Do you have a hint what I could do? :)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions