-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,14 +462,62 @@ def create_main(): | |
file.close() | ||
return {'FINISHED'} | ||
|
||
class NodeToPythonMenu(bpy.types.Menu): | ||
bl_idname = "NodeToPythonMenu" | ||
bl_label = "" | ||
|
||
@classmethod | ||
def poll(cls, context): | ||
return not (False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: |
||
|
||
def draw(self, context): | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. style: use single-quotes for enum |
||
for i in range(len(geo_node_groups)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: use something like |
||
op = layout.operator(NodeToPython.bl_idname, text=geo_node_groups[i].name) | ||
op.node_group_name = geo_node_groups[i].name | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. style: |
||
bl_space_type = 'NODE_EDITOR' | ||
bl_region_type = 'UI' | ||
bl_context = '' | ||
bl_category = 'NodeToPython' | ||
|
||
@classmethod | ||
def poll(cls, context): | ||
return not (False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: |
||
|
||
def draw_header(self, context): | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. style: would move this logic closer to the |
||
menu_text = 'Nodes' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: would use |
||
|
||
layout = self.layout | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. style: just |
||
row.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: just |
||
row.menu('NodeToPythonMenu', text=menu_text) | ||
|
||
def menu_func(self, context): | ||
self.layout.operator(NodeToPython.bl_idname, text=NodeToPython.bl_label) | ||
|
||
def register(): | ||
bpy.utils.register_class(NodeToPythonMenu) | ||
bpy.utils.register_class(NodeToPythonPanel) | ||
bpy.utils.register_class(NodeToPython) | ||
bpy.types.VIEW3D_MT_object.append(menu_func) | ||
|
||
def unregister(): | ||
bpy.utils.unregister_class(NodeToPythonMenu) | ||
bpy.utils.unregister_class(NodeToPythonPanel) | ||
bpy.utils.unregister_class(NodeToPython) | ||
bpy.types.VIEW3D_MT_object.remove(menu_func) | ||
|
||
|
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