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


Python bpy.data方法代码示例

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


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

示例1: filter_items

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

        coll_list = getattr(data, property)
        filter_name = self.filter_name.lower()

        flt_flags = [self.bitflag_filter_item
            if filter_name in item.name.lower()
            else 0 for i, item in enumerate(coll_list, 1)
        ]

        if self.use_filter_sort_alpha:
            flt_neworder = [x[1] for x in sorted(
                    zip(
                        [x[0] for x in sorted(enumerate(coll_list), key=lambda x: x[1].name)],
                        range(len(coll_list))
                    )
                )
            ]
        else:
            flt_neworder = []

        return flt_flags, flt_neworder 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:24,代码来源:custom_ui.py

示例2: move_verts

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def move_verts(self,obj,ratio_x,ratio_y):
        bpy.ops.object.mode_set(mode="EDIT")
        bpy.ops.mesh.reveal()
        bpy.ops.object.mode_set(mode="OBJECT")
        
        shapekeys = [obj.data.vertices]
        if obj.data.shape_keys != None:
            shapekeys = []
            for shapekey in obj.data.shape_keys.key_blocks:
                shapekeys.append(shapekey.data)
        
        for shapekey in shapekeys:
            for vert in shapekey:
                co_x = vert.co[0] * ratio_x
                co_y = vert.co[2] * ratio_y
                vert.co = Vector((co_x,0,co_y))
            
            
        obj.coa_sprite_dimension = Vector((get_local_dimension(obj)[0],0,get_local_dimension(obj)[1]))
        obj.coa_tiles_x = self.tiles_x
        obj.coa_tiles_y = self.tiles_y 
开发者ID:ndee85,项目名称:coa_tools,代码行数:23,代码来源:import_sprites.py

示例3: remove_data

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def remove_data(target_data):
	try: target_data = target_data[:]
	except: target_data = [target_data]
	
	for data in target_data:
		if data.__class__.__name__ == 'Object':
			if data.name in bpy.context.scene.objects:
				bpy.context.scene.objects.unlink(data)
	
	for data in target_data:
		if 'users' in dir(data) and 'user_clear' in dir(data):
			if data.users: data.user_clear()
	
	for data in target_data:
		for data_str in dir(bpy.data):
			if data_str[-1] != "s": continue
			try:
				if data.__class__.__name__ == eval('bpy.data.%s[0].__class__.__name__' % data_str):
					exec('bpy.data.%s.remove(data, do_unlink=True)' % data_str)
					break
			except: pass

# オブジェクトのマテリアルを削除/復元するクラス 
开发者ID:CM3D2user,项目名称:Blender-CM3D2-Converter,代码行数:25,代码来源:common.py

示例4: __init__

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def __init__(self, ob):
		override = bpy.context.copy()
		override['object'] = ob
		self.object = ob
		
		self.slots = []
		for slot in ob.material_slots:
			if slot: self.slots.append(slot.material)
			else: self.slots.append(None)
		
		self.mesh_data = []
		for index, slot in enumerate(ob.material_slots):
			self.mesh_data.append([])
			for face in ob.data.polygons:
				if face.material_index == index:
					self.mesh_data[-1].append(face.index)
		
		for slot in ob.material_slots[:]:
			bpy.ops.object.material_slot_remove(override) 
开发者ID:CM3D2user,项目名称:Blender-CM3D2-Converter,代码行数:21,代码来源:common.py

示例5: restore

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def restore(self):
		override = bpy.context.copy()
		override['object'] = self.object
		
		for slot in self.object.material_slots[:]:
			bpy.ops.object.material_slot_remove(override)
		
		for index, mate in enumerate(self.slots):
			bpy.ops.object.material_slot_add(override)
			slot = self.object.material_slots[index]
			if slot:
				slot.material = mate
			for face_index in self.mesh_data[index]:
				self.object.data.polygons[face_index].material_index = index

# 現在のレイヤー内のオブジェクトをレンダリングしなくする/戻す 
开发者ID:CM3D2user,项目名称:Blender-CM3D2-Converter,代码行数:18,代码来源:common.py

示例6: run

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def run(self):
        scriptCode = bpy.data.texts[self.textBlockName].as_string()
        scriptLocals = {}
        if len(self.inputs) > 1:
            for socket in self.inputs[1:]:
                if socket.isLinked:
                    scriptLocals[socket.text] = socket.getFromSocket.value
            for socket in self.outputs:
                scriptLocals[socket.text] = None

            comiledScript = compile(scriptCode, '<string>', 'exec')

            exec(comiledScript, None, scriptLocals)

            for socket in self.outputs:
                socket.value = str(scriptLocals[socket.text]) 
开发者ID:hsab,项目名称:GrowthNodes,代码行数:18,代码来源:script.py

示例7: initOutputData

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def initOutputData(self, resolution):
        D = bpy.data
        textureName = self.nodeTree.name + " - " + self.node.name + " - " + str(
            self.index)
        if textureName not in D.textures:
            texture = D.textures.new(textureName, "IMAGE")
        else:
            texture = D.textures[textureName]

        if textureName in D.images:
            D.images.remove(D.images[textureName])

        image = D.images.new(textureName, resolution, resolution, alpha = False,
                             float_buffer = True)

        texture.image = image
        self.value = texture.name 
开发者ID:hsab,项目名称:GrowthNodes,代码行数:19,代码来源:texture2.py

示例8: invoke

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def invoke(self, context, event):
        if self.armatures:
            armature = context.scene.objects[self.armatures]
            bpy.ops.object.mode_set(mode="OBJECT")

            bpy.ops.object.select_all(action='DESELECT')
            armature.select_set(state=True)
            context.view_layer.objects.active = armature

            bpy.ops.object.mode_set(mode="EDIT")
            data = armature.data
            self.armature = data.name

            bones_builder.nuke_mixamo_prefix(data.edit_bones)

            bpy.ops.object.mode_set(mode="OBJECT")
            automatic_bind_bones(self, data.bones)

        return context.window_manager.invoke_props_dialog(self, width=600) 
开发者ID:Menithal,项目名称:Blender-Metaverse-Addon,代码行数:21,代码来源:custom.py

示例9: __enter__

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def __enter__(self):
        project_file = tempfile.NamedTemporaryFile(
            delete=False,
            # Temporary project files has to be in the
            # same directory to ensure relative paths work.
            dir=bpy.path.abspath("//"),
            prefix='parallel_render_copy_{}_'.format(os.path.splitext(os.path.basename(bpy.data.filepath))[0]),
            suffix='.blend',
        )
        project_file.close()
        try:
            self.path = project_file.name

            bpy.ops.wm.save_as_mainfile(
                filepath=self.path,
                copy=True,
                check_existing=False,
                relative_remap=True,
            )

            assert os.path.exists(self.path)
            return self
        except:
            self._cleanup()
            raise 
开发者ID:elmopl,项目名称:ktba,代码行数:27,代码来源:parallel_render.py

示例10: _run

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def _run(self, scn):
        props = scn.parallel_render_panel
        props.last_run_result = 'pending'

        if _need_temporary_file(bpy.data):
            work_project_file = TemporaryProjectCopy()
        else:
            work_project_file = CurrentProjectFile()

        try:
            with work_project_file:
                self._render_project_file(scn, work_project_file.path)
            props.last_run_result = 'done' if self.state == ParallelRenderState.RUNNING else 'failed'
        except Exception as exc:
            LOGGER.exception(exc)
            props.last_run_result = 'failed' 
开发者ID:elmopl,项目名称:ktba,代码行数:18,代码来源:parallel_render.py

示例11: users_id

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def users_id(self):
        """ID data blocks which use this library"""
        import bpy

        # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE,
        # we could make this an attribute in rna.
        attr_links = ("actions", "armatures", "brushes", "cameras",
                      "curves", "grease_pencil", "groups", "images",
                      "lamps", "lattices", "materials", "metaballs",
                      "meshes", "node_groups", "objects", "scenes",
                      "sounds", "speakers", "textures", "texts",
                      "fonts", "worlds")

        return tuple(id_block
                     for attr in attr_links
                     for id_block in getattr(bpy.data, attr)
                     if id_block.library == self) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:bpy_types.py

示例12: do_clear_previews

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def do_clear_previews(do_objects, do_groups, do_scenes, do_data_intern):
    if do_data_intern:
        bpy.ops.wm.previews_clear(id_type=INTERN_PREVIEW_TYPES)

    if do_objects:
        for ob in ids_nolib(bpy.data.objects):
            ob.preview.image_size = (0, 0)

    if do_groups:
        for grp in ids_nolib(bpy.data.groups):
            grp.preview.image_size = (0, 0)

    if do_scenes:
        for scene in ids_nolib(bpy.data.scenes):
            scene.preview.image_size = (0, 0)

    print("Saving %s..." % bpy.data.filepath)
    bpy.ops.wm.save_mainfile() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:bl_previews_render.py

示例13: relpath

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def relpath(path, start=None):
    """
    Returns the path relative to the current blend file using the "//" prefix.

    :arg path: An absolute path.
    :type path: string or bytes
    :arg start: Relative to this path,
       when not set the current filename is used.
    :type start: string or bytes
    """
    if isinstance(path, bytes):
        if not path.startswith(b"//"):
            if start is None:
                start = _os.path.dirname(_getattr_bytes(_bpy.data, "filepath"))
            return b"//" + _os.path.relpath(path, start)
    else:
        if not path.startswith("//"):
            if start is None:
                start = _os.path.dirname(_bpy.data.filepath)
            return "//" + _os.path.relpath(path, start)

    return path 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:path.py

示例14: execute

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def execute(self, context):
        value = self.value
        data_path = self.data_path

        # match the pointer type from the target property to bpy.data.*
        # so we lookup the correct list.
        data_path_base, data_path_prop = data_path.rsplit(".", 1)
        data_prop_rna = eval("context.%s" % data_path_base).rna_type.properties[data_path_prop]
        data_prop_rna_type = data_prop_rna.fixed_type

        id_iter = None

        for prop in bpy.data.rna_type.properties:
            if prop.rna_type.identifier == "CollectionProperty":
                if prop.fixed_type == data_prop_rna_type:
                    id_iter = prop.identifier
                    break

        if id_iter:
            value_id = getattr(bpy.data, id_iter).get(value)
            exec("context.%s = value_id" % data_path)

        return operator_path_undo_return(context, data_path) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:wm.py

示例15: _values_store

# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import data [as 别名]
def _values_store(self, context):
        data_path_iter = self.data_path_iter
        data_path_item = self.data_path_item

        self._values = values = {}

        for item in getattr(context, data_path_iter):
            try:
                value_orig = eval("item." + data_path_item)
            except:
                continue

            # check this can be set, maybe this is library data.
            try:
                exec("item.%s = %s" % (data_path_item, value_orig))
            except:
                continue

            values[item] = value_orig 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:wm.py


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