本文整理汇总了Python中nodeitems_utils.NodeItem方法的典型用法代码示例。如果您正苦于以下问题:Python nodeitems_utils.NodeItem方法的具体用法?Python nodeitems_utils.NodeItem怎么用?Python nodeitems_utils.NodeItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nodeitems_utils
的用法示例。
在下文中一共展示了nodeitems_utils.NodeItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: node_enum_items
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def node_enum_items(self, context):
enum_items = NODE_OT_add_search._enum_item_hack
enum_items.clear()
for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
if isinstance(item, nodeitems_utils.NodeItem):
nodetype = getattr(bpy.types, item.nodetype, None)
if nodetype:
enum_items.append(
(str(index),
item.label,
nodetype.bl_rna.description,
index,
))
return enum_items
# Look up the item based on index
示例2: node_group_items
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def node_group_items(context):
if context is None:
return
space = context.space_data
if not space:
return
ntree = space.edit_tree
if not ntree:
return
yield NodeItemCustom(draw=group_tools_draw)
def contains_group(nodetree, group):
if nodetree == group:
return True
else:
for node in nodetree.nodes:
if node.bl_idname in node_tree_group_type.values() and node.node_tree is not None:
if contains_group(node.node_tree, group):
return True
return False
for group in context.blend_data.node_groups:
if group.bl_idname != ntree.bl_idname:
continue
# filter out recursive groups
if contains_group(group, ntree):
continue
yield NodeItem(node_tree_group_type[group.bl_idname],
group.name,
{"node_tree": "bpy.data.node_groups[%r]" % group.name})
# only show input/output nodes inside node groups
示例3: register_nodes
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def register_nodes():
global registered_nodes
# Re-register all nodes for now..
if len(registered_nodes) > 0:
unregister_nodes()
for n in arm_nodes.nodes:
registered_nodes.append(n)
bpy.utils.register_class(n)
node_categories = []
for category in sorted(arm_nodes.category_items):
if category == 'Layout':
# Handled separately
continue
sorted_items = sorted(arm_nodes.category_items[category], key=lambda item: item.nodetype)
node_categories.append(
LogicNodeCategory('Logic' + category + 'Nodes', category, items=sorted_items)
)
# Add special layout nodes known from Blender's node editors
if 'Layout' in arm_nodes.category_items:
# Clone with [:] to prevent double entries
layout_items = arm_nodes.category_items['Layout'][:]
else:
layout_items = []
layout_items += [NodeItem('NodeReroute'), NodeItem('NodeFrame')]
layout_items = sorted(layout_items, key=lambda item: item.nodetype)
node_categories.append(
LogicNodeCategory('LogicLayoutNodes', 'Layout', description='Layout Nodes', items=layout_items)
)
nodeitems_utils.register_node_categories('ArmLogicNodes', node_categories)
示例4: add_node
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def add_node(node_class, category):
global nodes
nodes.append(node_class)
if category_items.get(category) == None:
category_items[category] = []
category_items[category].append(NodeItem(node_class.bl_idname))
示例5: register
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def register():
print("-------------REGISTER SORCAR-------------")
path = repr([i for i in addon_utils.modules() if i.bl_info['name'] == "Sorcar"][0]).split("from '")[1].split("__init__.py'>")[0]
classes_ops = import_ops(path)
classes_sockets = import_sockets(path)
classes_ui = import_ui(path)
classes_nodes = import_nodes(path)
global all_classes, addon_keymaps
all_classes = [ScNodeTree]
all_classes.extend(classes_ops)
all_classes.extend(classes_sockets)
all_classes.extend(classes_ui)
all_classes.append(SorcarPreferences)
total_nodes = 0
node_categories = []
for cat in classes_nodes:
total_nodes += len(classes_nodes[cat])
node_categories.append(ScNodeCategory(identifier="sc_"+cat, name=bpy.path.display_name(cat), items=[NodeItem(i.bl_idname) for i in classes_nodes[cat]]))
all_classes.extend(classes_nodes[cat])
for i in all_classes:
bpy.utils.register_class(i)
nodeitems_utils.register_node_categories("sc_node_categories", node_categories)
if not (update_each_frame in bpy.app.handlers.frame_change_post):
bpy.app.handlers.frame_change_post.append(update_each_frame)
if (not bpy.app.background):
km, kmi = init_keymaps()
for k in kmi:
k.active = True
addon_keymaps.append((km, k))
addon_updater_ops.register(bl_info)
print_log("REGISTERED", msg="{} operators, {} sockets, {} UI, {} keymaps & {} nodes ({} categories)".format(len(classes_ops), len(classes_sockets), len(classes_ui), len(addon_keymaps), total_nodes, len(classes_nodes)))
示例6: node_categories
# 需要导入模块: import nodeitems_utils [as 别名]
# 或者: from nodeitems_utils import NodeItem [as 别名]
def node_categories(osl_nodes):
osl_surface = []
osl_shaders = []
osl_2d_textures = []
osl_3d_textures = []
osl_color = []
osl_utilities = []
osl_other = []
from ..translators.cycles_shaders import cycles_nodes
cyc_nodes = [nodeitems_utils.NodeItem(key) for key in cycles_nodes.keys()]
for node in osl_nodes:
node_item = nodeitems_utils.NodeItem(node[0])
node_category = node[1]
if node_category == 'shader':
osl_shaders.append(node_item)
elif node_category == 'texture2d':
osl_2d_textures.append(node_item)
elif node_category == 'utility':
osl_utilities.append(node_item)
elif node_category == 'texture3d':
osl_3d_textures.append(node_item)
elif node_category == 'surface':
osl_surface.append(node_item)
elif node_category == 'color':
osl_color.append(node_item)
else:
osl_other.append(node_item)
appleseed_node_categories = [
AppleseedOSLNodeCategory("OSL_Surfaces", "appleseed - Surface", items=osl_surface),
AppleseedOSLNodeCategory("OSL_Shaders", "appleseed - Shader", items=osl_shaders),
AppleseedOSLNodeCategory("OSL_3D_Textures", "appleseed - Texture3D", items=osl_3d_textures),
AppleseedOSLNodeCategory("OSL_2D_Textures", "appleseed - Texture2D", items=osl_2d_textures),
AppleseedOSLNodeCategory("OSL_Color", "appleseed - Color", items=osl_color),
AppleseedOSLNodeCategory("OSL_Utilities", "appleseed - Utility", items=osl_utilities),
AppleseedOSLNodeCategory("OSL_Script", "appleseed - Script", items=[nodeitems_utils.NodeItem("AppleseedOSLScriptBaseNode")]),
AppleseedOSLNodeCategory("OSL_Other", "appleseed - No Category", items=osl_other),
AppleseedOSLNodeCategory("OSL_Cycles", "Cycles - Utility", items=cyc_nodes)]
return appleseed_node_categories