当前位置: 首页>>代码示例>>Python>>正文


Python bpy.ops方法代码示例

本文整理汇总了Python中bpy.ops方法的典型用法代码示例。如果您正苦于以下问题:Python bpy.ops方法的具体用法?Python bpy.ops怎么用?Python bpy.ops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bpy的用法示例。


在下文中一共展示了bpy.ops方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updater_run_success_popup_handler

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def updater_run_success_popup_handler(scene):
    global ran_update_sucess_popup
    ran_update_sucess_popup = True

    # in case of error importing updater
    if updater.invalidupdater == True:
        return

    try:
        bpy.app.handlers.scene_update_post.remove(
                updater_run_success_popup_handler)
    except:
        pass

    atr = addon_updater_updated_successful.bl_idname.split(".")
    getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT') 
开发者ID:ndee85,项目名称:coa_tools,代码行数:18,代码来源:addon_updater_ops.py

示例2: post_update_callback

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def post_update_callback(res=None):

    # in case of error importing updater
    if updater.invalidupdater == True:
        return

    if res==None:
        # this is the same code as in conditional at the end of the register function
        # ie if "auto_reload_post_update" == True, comment out this code
        if updater.verbose: print("{} updater: Running post update callback".format(updater.addon))
        #bpy.app.handlers.scene_update_post.append(updater_run_success_popup_handler)

        atr = addon_updater_updated_successful.bl_idname.split(".")
        getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
        global ran_update_sucess_popup
        ran_update_sucess_popup = True
    else:
        # some kind of error occured and it was unable to install,
        # offer manual download instead
        atr = addon_updater_updated_successful.bl_idname.split(".")
        getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT',error=res)
    return


# function for asynchronous background check, which *could* be called on register 
开发者ID:ndee85,项目名称:coa_tools,代码行数:27,代码来源:addon_updater_ops.py

示例3: __repr__

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def __repr__(self):  # useful display, repr(op)
        # import bpy
        idname = self.idname()
        as_string = op_as_string(idname)
        # XXX You never quite know what you get from bpy.types,
        # with operators... Operator and OperatorProperties
        # are shadowing each other, and not in the same way for
        # native ops and py ones! See T39158.
        # op_class = getattr(bpy.types, idname)
        op_class = op_get_rna(idname)
        descr = op_class.bl_rna.description
        # XXX, workaround for not registering
        # every __doc__ to save time on load.
        if not descr:
            descr = op_class.__doc__
            if not descr:
                descr = ""

        return "# %s\n%s" % (descr, as_string) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:ops.py

示例4: set_cameras

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def set_cameras(self, current_scene, new_scene, wall):  
        camera_data = bpy.data.cameras.new(new_scene.name)
        camera_obj = bpy.data.objects.new(name=camera_data.name + " Camera", 
                                          object_data=camera_data)
         
        current_scene.objects.link(camera_obj)    
        current_scene.camera = camera_obj
        camera_obj.data.type = 'ORTHO'
        camera_obj.rotation_euler.x = math.radians(90.0) 
        camera_obj.rotation_euler.z = wall.obj_bp.rotation_euler.z    
        camera_obj.location = wall.obj_bp.location       
        
        bpy.ops.object.select_all(action='DESELECT')
        wall.get_wall_mesh().select = True
        bpy.ops.view3d.camera_to_view_selected()     
        
        current_scene.camera = None
        current_scene.objects.unlink(camera_obj)
        new_scene.objects.link(camera_obj)
        new_scene.camera = camera_obj
        new_scene.render.resolution_y = 1280
        bpy.data.cameras[new_scene.name].ortho_scale += self.padding 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:fd_scene.py

示例5: clear_and_collect_data

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def clear_and_collect_data(self,context):
        for product in self.products:
            self.products.remove(product)
        
        for wall in self.walls:
            self.walls.remove(wall)

        bpy.ops.fd_material.get_materials()
        for scene in bpy.data.scenes:
            if not scene.mv.plan_view_scene and not scene.mv.elevation_scene:
                for obj in scene.objects:
                    if not obj.mv.dont_export:
                        if obj.mv.type == 'BPWALL':
                            self.walls.append(obj)
                        if obj.mv.type == 'BPASSEMBLY':
                            if obj.mv.type_group == 'PRODUCT':
                                self.products.append(obj)
                        if obj.cabinetlib.type_mesh == 'BUYOUT' and obj.parent is None:
                            self.buyout_products.append(obj) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:fd_scene.py

示例6: invoke

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [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'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:wm.py

示例7: execute

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def execute(self, context):
        op_strings = []
        tot = 0
        for op_module_name in dir(bpy.ops):
            op_module = getattr(bpy.ops, op_module_name)
            for op_submodule_name in dir(op_module):
                op = getattr(op_module, op_submodule_name)
                text = repr(op)
                if text.split("\n")[-1].startswith("bpy.ops."):
                    op_strings.append(text)
                    tot += 1

            op_strings.append('')

        textblock = bpy.data.texts.new("OperatorList.txt")
        textblock.write('# %d Operators\n\n' % tot)
        textblock.write('\n'.join(op_strings))
        self.report({'INFO'}, "See OperatorList.txt textblock")
        return {'FINISHED'}


# -----------------------------------------------------------------------------
# Add-on Operators 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:wm.py

示例8: execute

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def execute(self, context):
        from os.path import basename, splitext
        filepath = self.filepath

        # change the menu title to the most recently chosen option
        preset_class = getattr(bpy.types, self.menu_idname)
        preset_class.bl_label = bpy.path.display_name(basename(filepath))

        ext = splitext(filepath)[1].lower()

        # execute the preset using script.python_file_run
        if ext == ".py":
            bpy.ops.script.python_file_run(filepath=filepath)
        elif ext == ".xml":
            import rna_xml
            rna_xml.xml_file_run(context,
                                 filepath,
                                 preset_class.preset_xml_map)
        else:
            self.report({'ERROR'}, "unknown filetype: %r" % ext)
            return {'CANCELLED'}

        return {'FINISHED'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:presets.py

示例9: importMesh_PointSet

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def importMesh_PointSet(geom, ancestry, _):
    # VRML not x3d
    coord = geom.getChildBySpec('Coordinate')  # works for x3d and vrml
    if coord:
        points = coord.getFieldAsArray('point', 3, ancestry)
    else:
        points = []

    # vcolor = geom.getChildByName('color')
    # blender dosnt have per vertex color

    bpymesh = bpy.data.meshes.new("PointSet")
    bpymesh.vertices.add(len(points))
    bpymesh.vertices.foreach_set("co", [a for v in points for a in v])

    # No need to validate
    bpymesh.update()
    return bpymesh


# -----------------------------------------------------------------------------------
# Primitives
# SA: they used to use bpy.ops for primitive creation. That was
# unbelievably slow on complex scenes. I rewrote to generate meshes
# by hand. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:import_x3d.py

示例10: execute

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def execute(self, context):
        import addon_utils

        module_name = self.module

        modules = addon_utils.modules(refresh=False)
        mod = addon_utils.addons_fake_modules.get(module_name)
        if mod is not None:
            info = addon_utils.module_bl_info(mod)
            info["show_expanded"] = True

            bpy.context.user_preferences.active_section = 'ADDONS'
            context.window_manager.addon_filter = 'All'
            context.window_manager.addon_search = info["name"]
            bpy.ops.screen.userpref_show('INVOKE_DEFAULT')

        return {'FINISHED'}


# Note: shares some logic with WM_OT_addon_install
# but not enough to de-duplicate. Fixes here may apply to both. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:wm.py

示例11: updater_run_success_popup_handler

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def updater_run_success_popup_handler(scene):
	global ran_update_sucess_popup
	ran_update_sucess_popup = True

	# in case of error importing updater
	if updater.invalidupdater == True:
		return

	try:
		bpy.app.handlers.scene_update_post.remove(
				updater_run_success_popup_handler)
	except:
		pass

	atr = addon_updater_updated_successful.bl_idname.split(".")
	getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT') 
开发者ID:blenderskool,项目名称:kaleidoscope,代码行数:18,代码来源:addon_updater_ops.py

示例12: still_registered

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def still_registered(self, oplist):
    if getattr(still_registered, 'is_broken', False): return False
    def is_registered():
        cur = bpy.ops
        for n in oplist:
            if not hasattr(cur, n): return False
            cur = getattr(cur, n)
        try:    StructRNA.path_resolve(self, "properties")
        except:
            print('no properties!')
            return False
        return True
    if is_registered(): return True
    still_registered.is_broken = True
    print('bpy.ops.%s is no longer registered!' % '.'.join(oplist))
    return False 
开发者ID:CGCookie,项目名称:addon_common,代码行数:18,代码来源:utils.py

示例13: iter_exporters

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def iter_exporters():
    #categories = dir(bpy.ops)
    categories = ["export_anim", "export_mesh", "export_scene"]
    for category_name in categories:
        op_category = getattr(bpy.ops, category_name)
        
        for name in dir(op_category):
            total_name = category_name + "." + name
            
            if total_name == ExportSelected.bl_idname:
                continue
            
            if "export" in total_name:
                op = getattr(op_category, name)
                
                yield total_name, op 
开发者ID:ros-naoqi,项目名称:naoqi_bridge,代码行数:18,代码来源:io_export_selected.py

示例14: execute

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def execute(self, context):
        with ToggleObjectMode(undo=None):
            self.clear_world(context)
            
            if self.format:
                props = {}
                for key in CurrentFormatProperties._keys():
                    props[key] = getattr(self.format_props, key)
                props["filepath"] = self.filepath
                
                op = get_op(self.format)
                
                op(**props)
            else:
                bpy.ops.wm.save_as_mainfile(
                    filepath=self.filepath,
                    copy=True,
                )
            
            bpy.ops.ed.undo()
            bpy.ops.ed.undo_push(message="Export Selected")
        
        return {'FINISHED'} 
开发者ID:ros-naoqi,项目名称:naoqi_bridge,代码行数:25,代码来源:io_export_selected.py

示例15: post_update_callback

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import ops [as 别名]
def post_update_callback():

	# in case of error importing updater
	if updater.invalidupdater == True:
		return

	# this is the same code as in conditional at the end of the register function
	# ie if "auto_reload_post_update" == True, comment out this code
	if updater.verbose: print("{} updater: Running post update callback".format(updater.addon))
	#bpy.app.handlers.scene_update_post.append(updater_run_success_popup_handler)

	atr = addon_updater_updated_successful.bl_idname.split(".")
	getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
	global ran_update_sucess_popup
	ran_update_sucess_popup = True
	return


# function for asynchronous background check, which *could* be called on register 
开发者ID:johnroper100,项目名称:CrowdMaster,代码行数:21,代码来源:addon_updater_ops.py


注:本文中的bpy.ops方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。