Added quick dropdown menu - #26
Conversation
Added a dropdown menu for choosing which node tree to convert. Located in a new panel 'Node To Python' in the nodes space
BrendanParmer
left a comment
There was a problem hiding this comment.
Awesome stuff! This is just what I was envisioning for the UI.
I've only got a few stylistic concerns, but I'm comfortable replacing the old system with this. I'll go ahead and make a few tweaks I outlined here
Thanks for your contribution!
| return {'FINISHED'} | ||
|
|
||
| class NodeToPythonMenu(bpy.types.Menu): | ||
| bl_idname = "NodeToPythonMenu" |
There was a problem hiding this comment.
style: bpy documentation recommends something like "NODE_MT_node_to_python" for the bl_idname
There was a problem hiding this comment.
would need to replace reference in line 507 as well
|
|
||
| @classmethod | ||
| def poll(cls, context): | ||
| return not (False) |
| geo_node_groups = [node for node in bpy.data.node_groups if node.type == 'GEOMETRY'] | ||
|
|
||
| layout = self.layout.column_flow(columns=1) | ||
| layout.operator_context = "INVOKE_DEFAULT" |
There was a problem hiding this comment.
style: use single-quotes for enum INVOKE_DEFAULT
|
|
||
| layout = self.layout.column_flow(columns=1) | ||
| layout.operator_context = "INVOKE_DEFAULT" | ||
| for i in range(len(geo_node_groups)): |
There was a problem hiding this comment.
style: use something like for geo_ng in geo_node_groups: instead of iterating through the indices and accessing each element of the list
|
|
||
| class NodeToPythonPanel(bpy.types.Panel): | ||
| bl_label = 'Node To Python' | ||
| bl_idname = 'NodeToPythonPanel' |
There was a problem hiding this comment.
style: bl_idname should be something like NODE_PT_node_to_python
|
|
||
| @classmethod | ||
| def poll(cls, context): | ||
| return not (False) |
| col = layout.column() | ||
| row = col.row() | ||
| row.enabled = geo_node_groups_exist # Disables menu when len of geometry nodes is 0 | ||
| row.alignment = 'Expand'.upper() |
| layout = self.layout | ||
|
|
||
| def draw(self, context): | ||
| geo_node_groups_exist = len([node for node in bpy.data.node_groups if node.type == 'GEOMETRY']) > 0 |
There was a problem hiding this comment.
style: would move this logic closer to the row.enabled line. would be a little more legible if we make this list its own variable like in the menu class
|
|
||
| def draw(self, context): | ||
| geo_node_groups_exist = len([node for node in bpy.data.node_groups if node.type == 'GEOMETRY']) > 0 | ||
| menu_text = 'Nodes' |
There was a problem hiding this comment.
style: would use "Geometry Node Groups" instead, double-quotes for non-enum strings. it's simple enough where I'd just explicitly set the text in the row.menu() line
| row = col.row() | ||
| row.enabled = geo_node_groups_exist # Disables menu when len of geometry nodes is 0 | ||
| row.alignment = 'Expand'.upper() | ||
| row.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT" |
There was a problem hiding this comment.
style: just 'INVOKE_DEFAULT'
Added a dropdown menu to easily choose which node tree to convert.
Located in a new panel 'Node To Python' in the nodes space