-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A discussion on scripting with Molecular Nodes and Blender more generally #734
Comments
Great idea! I would also add video tutorial resources, e.g. and here's bpy gallery with scripts and their corresponding visual output: edit: we could even bring this list to a website similar to https://matplotlib.org/thirdpartypackages/#animations |
Brady, thank you for this post and for all of your great work. And thank you for connecting this talented group; I admire the work of the other coders here. I will respond in more depth but at a minumum I would connect to this discussion I had started for prettymol. In my case I am intending to use Blender/MN as the render platform but otherwise leave selection control to the user letting them get most of Blender's benefit without having to learn more that small additional API. |
Brady, I've tried a few different approaches to scripting in Blender on top of Molecular Nodes and have formed some opinions on how to get the 80% benefit with 20% effort. Here are a few thoughts. Blender Creates Opportunity
Blender Presents Challenges
Molecular Nodes Opportunity/challengeMolecular Nodes masterfully embraces Blender's power but comes with all of its challenges. From a scripting perspective there are the installation/environment challenges, as well as the ergonomic challenge of programming against 1) the generic trickiness of node programming and 2) that the nodes themselves are not normal python objects - e.g. they are accessible as Blender components loaded from a .blend file. I've tried a few different approaches to solving the problem and have come to believe the ideal scripting setup for Molecular Nodes is as follows:
ZCP's Approach.My brief MN scripting trajectory is as follows:
How I hope prettymol can fit the bill of the points above:
General Thoughts.
This got a bit longer than I expected so I'll close with a thank you to Brady and an offer to help incorporate any of the ideas above as we see fit. |
Hi Brady, thanks, as always, for putting so much thought into things. I agree that being able to write scripts that produce visualizations is a great and important workflow. But being able to use the Blender GUI itself is nice, too. There are two workflows that I often use: Create visualization using GUI and then convert to script.
Use the GUI to edit the underlying data
Sorry this is all a bit of a random mix of thoughts. Happy to follow up with more concrete examples. |
Thanks for the comments @zachcp and@jojoelfe! I can see some main areas that need improvement, separate to MN, to better enable both MN and in general more incorporation of Blender into workflows: An improved scripting API for nodesThis is a major pain point of the API. It's overly verbose and particular, with the user having to keep a mental model in their head of how the node tree is going to look at the end of it. There are a couple of projects that try to address this (geometry-script, geonodes) but I have found both of them to not quite work how I would like them to. One possible solution is for another project to attempt to address this, creating our own API which better fits our use cases. Would require a lot of work though. Scripting vs GUIBlender itself is built first and foremost as a GUI tool for artists. While the python API and our ability to write and run scripts is still high up there on their priorities, it is still secondary to it being a GUI program, which is why we run into so many problems trying to approach this. The same applies for Molecular Nodes, with the primary design and tools being around GUI usage (mostly being Geometry Nodes based), which presents some quirks around scripting, but ultimately I would like to work them out as much as possible. Ideally everything would be able to be cleanly done through code, and the GUI is just point-and-click access to that. Related to this, when I was first developing MN I had to discard all data and python objects after initial import, which is now no longer the case with the I'm interested to @jojoelfe to hear more about what kind of data editing you are doing. There has been a bunch of experimentation with the GPU module for drawing custom UIs the viewport, potentially making more of a custom GUI experience similar to a dedicated molecular graphics program. Blender Apps would in theory also solve that issue, but that project keeps getting pushed back because they don't have the development team to support it. |
Hi Team,
[pypi-dependencies]
# note these git coords define a packageable fork of geonodes
geonodes = { git = "https://github.com/zachcp/geonodes", rev = "main" }
biotite = ">=1.1"
blender_notebook = "*"
bpy = "*"
databpy = "*"
molecularnodes = "*"
blendersynth = ">=0.3.0, <0.4"
|
Yes I've found both geonodes and geometry-script to be 90% of the way there, but not actually be setup to be used internally inside of other add-ons / packages. I think we could take large portions / inspiration from each of them and combine into another package that is intended for this purpose. Would require a fair amount of work, but would be one aspect of improving this whole process so that node groups are ultimately saved as code. |
Potential Contributions I'd like to make to MN:
@BradyAJohnston LMK if any of these seem reasonable an I can make specific issues to discuss implementation. |
This is an attempt to collect thoughts and projects related to scientific scripting and rendering with Blender. It would better fit in a more general-purpose place for scientific interaction & visualisation with Blender (like a GitHub organisation for such), but as it currently doesn't exist I figured here would be a good a place as any to collect links, thoughts and comments from projects and people working in the space.
The text below on this initial post will be updated with additional links to projects that are relevant as they are found.
Molecular Nodes related projects
gpu
module inside of Blender with MDAnalysis to visualise data & results in the viewport, enabling better interaction & feedbackMolecular data related:
General science-related:
numpy
arraysdatabpy
andpolars
bpy
API and their resultsGeneral and useful Blender related:
What I want to try and get out of creating this is to for myself, but also for others collate what people are trying out and how they are approaching different data and visualisation tasks inside of Blender. For a more specific point currently, there are now several different approaches to potentially scripting with Molecular Nodes and Blender, as well as several different approaches to linking Jupyter Notebooks and Blender. I think it better if we tried to coordinate and work on one single approach, rather than replicating work in different projects.
This is something that I have attempted to remedy with
databpy
, splitting out the data & mesh handling code into it's own package for use with other projects.The first step in trying to better coordinate these efforts is for everyone to become more aware of what other approaches are being attempted, and I'm hoping that here we can try and discuss what might be the best thing to do going forward. I'm not looking to try and police anybodies projects or there approaches, but if people are open to working collectively then it'll likely work out better than working separately.
I'm tagging some users to ping and potentially get some discussion going, but if you aren't interested then please mute the thread & I can remove you from the post. Please feel free to ping others to get them to join the conversation also.
Pinging: @yuxuanzhuang @PardhavMaradani @kolibril13 @jojoelfe @corredD @so-rose @zachcp @paulmelis @
The text was updated successfully, but these errors were encountered: