-
Notifications
You must be signed in to change notification settings - Fork 33
Added quick dropdown menu #26
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
Conversation
Added a dropdown menu for choosing which node tree to convert. Located in a new panel 'Node To Python' in the nodes space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: bpy documentation recommends something like "NODE_MT_node_to_python" for the bl_idname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would need to replace reference in line 507 as well
|
||
@classmethod | ||
def poll(cls, context): | ||
return not (False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: return True
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: bl_idname
should be something like NODE_PT_node_to_python
|
||
@classmethod | ||
def poll(cls, context): | ||
return not (False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: return True
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: just 'EXPAND'
here
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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