本文整理汇总了Python中bpy.types.Operator方法的典型用法代码示例。如果您正苦于以下问题:Python types.Operator方法的具体用法?Python types.Operator怎么用?Python types.Operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bpy.types
的用法示例。
在下文中一共展示了types.Operator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invoke
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def invoke(self, context, event):
wm = context.window_manager
data_path = self.data_path
prop_string = self.prop_string
# same as eval("bpy.ops." + data_path)
op_mod_str, ob_id_str = data_path.split(".", 1)
op = getattr(getattr(bpy.ops, op_mod_str), ob_id_str)
del op_mod_str, ob_id_str
try:
op_rna = op.get_rna()
except KeyError:
self.report({'ERROR'}, "Operator not found: bpy.ops.%s" % data_path)
return {'CANCELLED'}
def draw_cb(self, context):
layout = self.layout
pie = layout.menu_pie()
pie.operator_enum(data_path, prop_string)
wm.popup_menu_pie(draw_func=draw_cb, title=op_rna.bl_rna.name, event=event)
return {'FINISHED'}
示例2: execute
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def execute(self, context):
d = archipack_fence.datablock(context.active_object)
if d is None:
self.report({'WARNING'}, "Archipack: Operator only valid with fence")
return {'CANCELLED'}
if self.part == "SUB":
part_obj = bpy.data.objects.get(d.user_defined_subs)
if part_obj is None:
self.report({'WARNING'}, "Archipack: User defined sub object not found")
return {'CANCELLED'}
d.subs_x, d.subs_y, d.subs_z = part_obj.dimensions.x, part_obj.dimensions.y, part_obj.dimensions.z
else:
part_obj = bpy.data.objects.get(d.user_defined_post)
if part_obj is None:
self.report({'WARNING'}, "Archipack: User defined post object not found")
return {'CANCELLED'}
d.post_x, d.post_y, d.post_z = part_obj.dimensions.x, part_obj.dimensions.y, part_obj.dimensions.z
return {'FINISHED'}
示例3: menu_func_export
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def menu_func_export(self, context):
self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
示例4: menu_func_import
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def menu_func_import(self, context):
self.layout.operator(ImportSomeData.bl_idname, text="Text Import Operator")
示例5: preset_values
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def preset_values(self):
properties_blacklist = Operator.bl_rna.properties.keys()
prefix, suffix = self.operator.split("_OT_", 1)
op = getattr(getattr(bpy.ops, prefix.lower()), suffix)
operator_rna = op.get_rna().bl_rna
del op
ret = []
for prop_id, prop in operator_rna.properties.items():
if not (prop.is_hidden or prop.is_skip_save):
if prop_id not in properties_blacklist:
ret.append("op.%s" % prop_id)
return ret
示例6: invoke
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def invoke(self, context, event):
"""
Args:
context:
event:
Returns:
"""
self.filepath = bUtils.getPhobosPreferences().modelsfolder
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
# TODO use it or delete it... Own dev branch?
# class ViewExportOperator(Operator):
# """Open a file explorer window in the export path"""
# bl_idname = "phobos.view_export"
# bl_label = "Export Scene"
# bl_options = {'REGISTER', 'UNDO'}
#
# def execute(self, context):
# bpy.ops.wm.path_open(filepath=bpy.types.World.path)
# return {'FINISHED'}
# FIXME: parameter?
示例7: _wm_doc_get_id
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
id_split = doc_id.split(".")
url = rna = None
if len(id_split) == 1: # rna, class
if do_url:
url = "%s/bpy.types.%s.html" % (url_prefix, id_split[0])
else:
rna = "bpy.types.%s" % id_split[0]
elif len(id_split) == 2: # rna, class.prop
class_name, class_prop = id_split
# an operator (common case - just button referencing an op)
if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop):
if do_url:
url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop))
else:
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
rna_class = getattr(bpy.types, class_name)
# an operator setting (selected from a running operator), rare case
# note: Py defined operators are subclass of Operator,
# C defined operators are subclass of OperatorProperties.
# we may need to check on this at some point.
if issubclass(rna_class, (bpy.types.Operator, bpy.types.OperatorProperties)):
# note: ignore the prop name since we don't have a way to link into it
class_name, class_prop = class_name.split("_OT_", 1)
class_name = class_name.lower()
if do_url:
url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop))
else:
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
# an RNA setting, common case
# detect if this is a inherited member and use that name instead
rna_parent = rna_class.bl_rna
rna_prop = rna_parent.properties[class_prop]
rna_parent = rna_parent.base
while rna_parent and rna_prop == rna_parent.properties.get(class_prop):
class_name = rna_parent.identifier
rna_parent = rna_parent.base
if do_url:
url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop))
else:
rna = ("bpy.types.%s.%s" % (class_name, class_prop))
return url if do_url else rna
示例8: execute
# 需要导入模块: from bpy import types [as 别名]
# 或者: from bpy.types import Operator [as 别名]
def execute(self, context):
"""
Args:
context:
Returns:
"""
newroot = context.active_object
oldroot = sUtils.getRoot(obj=context.active_object)
if newroot == oldroot:
log("Object is already root.", 'INFO')
return {'CANCELLED'}
# gather model information from old root
modelprops = eUtils.getProperties(oldroot, category='model')
oldroot.pose.bones[0].custom_shape = None
# assign joint resource to oldroot if applicable
if 'joint/type' in oldroot:
oldroot.pose.bones[0].custom_shape = ioUtils.getResource(
('joint', oldroot['joint/type'])
)
eUtils.restructureKinematicTree(newroot)
# write model information to new root
newroot.pose.bones[0].custom_shape = ioUtils.getResource(('link', 'root'))
eUtils.setProperties(newroot, modelprops, category='model')
# remove model information from old root
eUtils.removeProperties(oldroot, ['model/*'])
return {'FINISHED'}
# TODO remove or use? Give it a dev branch
# class SelectErrorOperator(Operator):
# """Select an object with check errors"""
# bl_idname = "phobos.select_error"
# bl_label = "Select Erroneous Object"
# bl_options = {'REGISTER', 'UNDO'}
#
# errorObj = EnumProperty(
# name="Erroneous Objects",
# items=defs.generateCheckMessages,
# description="The objects containing errors")
#
# def execute(self, context):
# sUtils.selectByName(self.errorObj)
# for message in vUtils.checkMessages[self.errorObj]:
# log(message, 'INFO')
#
# return {'FINISHED'}