代码拉取完成,页面将自动刷新
import bpy
import os, sys, subprocess
class op(bpy.types.Operator):
bl_idname = "uv.textools_texture_open"
bl_label = "Open Texture"
bl_description = "Open the texture on the system"
name : bpy.props.StringProperty(
name="image name",
default = ""
)
@classmethod
def poll(cls, context):
return True
def execute(self, context):
open_texture(self, context)
return {'FINISHED'}
def open_texture(self, context):
if self.name in bpy.data.images:
image = bpy.data.images[self.name]
if image.filepath != "":
path = bpy.path.abspath(image.filepath)
# https://meshlogic.github.io/posts/blender/addons/extra-image-list/
# https://docs.blender.org/api/blender_python_api_2_78_release/bpy.ops.image.html
print("Open: {}".format(path))
if sys.platform == "win32":
os.startfile(path)
else:
opener ="open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, path])
bpy.utils.register_class(op)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。