What are the necessary elements for creating a new node #262
Replies: 1 comment 1 reply
-
The majority of the nodes don't involve python at all, but because GN is still in its infancy, things that involved loops and text parsing all require some calls to python scripts. Creating New NodesThere are two types of nodes that I have created so far. The majority of the nodes are pre-made by hand, and live inside of the The other types of nodes are the ones that need to be structure-specific, so basically anything that would require a loop. You can't loop currently inside of GN, so in creating those nodes I have to make the loops myself when generating them using python. Those are the majority of the nodes defined inside of
A new custom selection string nodeThere isn't yet useful text parsing inside of GN, so the text needs to be parsed by python then a custom node group created. If you look at If you want to implement a new custom selection that would mimic that of ChimeraX, I would certain welcome it but it might be a bit finnicky. You would have to write your own text parses to take the inputted text, then createa new node group which combines the boolean selections of It's kind of all over the place, and ideally at some point text parsing will be possible inside of GN which will avoid this back and forth, but currently I believe this is what we are limited to doing. Hopefully this clears up some of how the logic of the nodes work. Happy to talk about it plenty more! |
Beta Was this translation helpful? Give feedback.
-
Let's say, hypothetically, that someone wanted to write a new node that let you select atoms/residues/what have you by their ChimeraX selection string. That person might be confused with where to start writing a node.
It seems that the business logic for a node involves building a node tree in
nodes.py
. For instance, the chain selection logic lives innodes.py
, lines 446--534.To get this new node to appear, you then need to add two things to
ui.py
. First, alayout_function
subclass which describes how the menu looks, and abpy.types.Operator
subclass which describes what happens. This would bemenu_chain_selection_custom
andMOL_OT_Chain_Selection_Custom
, respectively.This is where it gets confusing for me. Modifying what you've got in (e.g.)
menu_chain_selection_custom
does modify what is displayed in the addon, but trying to add a new box or whatever doesn't work. Working on PDB caching made me wonder if I also would need to add abpy.props.StringProperty
toload.py
?But then I looked for
MOL_color_element
and I can't even find where that's defined at all!I guess my question is: for any given node, what properties need to be added to what files for what functionality. I've tried googling around but it seems like a lot of blender addons are just single-file
__init__.py
things, which muddy the waters.Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions