Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added status and task info to Tray Icon and Tooltip #14

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 126 additions & 104 deletions Pandora/Plugins/Apps/Blender/Scripts/Pandora_Blender_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,121 +140,139 @@ def getExternalFiles(self, origin, isSubmitting=False):
@err_decorator
def preSubmit(self, origin, rSettings):
if origin.chb_resOverride.isChecked():
rSettings["resolutionpercent"] = bpy.context.scene.render.resolution_percentage
rSettings["width"] = bpy.context.scene.render.resolution_x
rSettings["height"] = bpy.context.scene.render.resolution_y
bpy.context.scene.render.resolution_percentage = 100
bpy.context.scene.render.resolution_x = origin.sp_resWidth.value()
bpy.context.scene.render.resolution_y = origin.sp_resHeight.value()

jobFrames = [origin.sp_rangeStart.value(), origin.sp_rangeEnd.value()]

rSettings["start"] = bpy.context.scene.frame_start
rSettings["end"] = bpy.context.scene.frame_end
rSettings["fileformat"] = bpy.context.scene.render.image_settings.file_format
rSettings["overwrite"] = bpy.context.scene.render.use_overwrite
rSettings["placeholder"] = bpy.context.scene.render.use_placeholder
rSettings["fileextension"] = bpy.context.scene.render.use_file_extension
rSettings["resolutionpercent"] = bpy.context.scene.render.resolution_percentage
rSettings["origOutputName"] = rSettings["outputName"]
rSettings["camera"] = bpy.context.scene.camera.name
rSettings["origOutputName"] = bpy.context.scene.render.filepath

#rSettings["fileformat"] = bpy.context.scene.render.image_settings.file_format
#rSettings["resolutionpercent"] = bpy.context.scene.render.resolution_percentage
#rSettings["origOutputName"] = rSettings["outputName"]
# bpy.context.scene.render.image_settings.file_format = "OPEN_EXR"
# bpy.context.scene.render.image_settings.color_depth = "16"
# bpy.context.scene.render.resolution_percentage = 100

bpy.context.scene["PrismIsRendering"] = True
bpy.context.scene.render.filepath = rSettings["outputName"]
bpy.context.scene.render.image_settings.file_format = "OPEN_EXR"
bpy.context.scene.render.image_settings.color_depth = "16"
bpy.context.scene.render.use_file_extension = True
bpy.context.scene.render.use_overwrite = False
bpy.context.scene.render.use_placeholder = False
bpy.context.scene.frame_start = jobFrames[0]
bpy.context.scene.frame_end = jobFrames[1]
bpy.context.scene.render.use_overwrite = True
bpy.context.scene.render.use_file_extension = False
bpy.context.scene.render.resolution_percentage = 100
if origin.cb_cam.currentText() in bpy.context.scene.objects:
bpy.context.scene.camera = bpy.context.scene.objects[
origin.cb_cam.currentText()
]

usePasses = False
if bpy.context.scene.node_tree is not None and bpy.context.scene.use_nodes:
outNodes = [
x for x in bpy.context.scene.node_tree.nodes if x.type == "OUTPUT_FILE"
]
rlayerNodes = [
x for x in bpy.context.scene.node_tree.nodes if x.type == "R_LAYERS"
]

bName = os.path.splitext(os.path.basename(rSettings["outputName"]))
if bName[0].endswith(self.plugin.frameString):
bName = "%s.beauty%s%s" % (bName[0][:-5], bName[0][-5:], bName[1])
else:
bName = "%s.beauty%s" % (bName[0], bName[1])
rSettings["outputName"] = os.path.join(
os.path.dirname(rSettings["outputName"]), "beauty", bName
)

for m in outNodes:
connections = []
for idx, i in enumerate(m.inputs):
if len(list(i.links)) > 0:
connections.append([i.links[0], idx])

m.base_path = os.path.dirname(rSettings["outputName"])

for i, idx in connections:
passName = i.from_socket.name

if passName == "Image":
passName = "beauty"

if i.from_node.type == "R_LAYERS":
if len(rlayerNodes) > 1:
passName = "%s_%s" % (i.from_node.layer, passName)

else:
if hasattr(i.from_node, "label") and i.from_node.label != "":
passName = i.from_node.label

extensions = {
"PNG": ".png",
"JPEG": ".jpg",
"JPEG2000": "jpg",
"TARGA": ".tga",
"TARGA_RAW": ".tga",
"OPEN_EXR_MULTILAYER": ".exr",
"OPEN_EXR": ".exr",
"TIFF": ".tif",
}
nodeExt = extensions[m.format.file_format]
curSlot = m.file_slots[idx]
if curSlot.use_node_format:
ext = nodeExt
else:
ext = extensions[curSlot.format.file_format]

curSlot.path = "../%s/%s" % (
passName,
os.path.splitext(os.path.basename(rSettings["outputName"]))[
0
].replace("beauty", passName)
+ ext,
)
newOutputPath = os.path.abspath(
os.path.join(
rSettings["outputName"],
"../..",
passName,
os.path.splitext(os.path.basename(rSettings["outputName"]))[
0
].replace("beauty", passName)
+ ext,
)
)
if passName == "beauty":
rSettings["outputName"] = newOutputPath
usePasses = True

if usePasses:
import platform

if platform.system() == "Windows":
tmpOutput = os.path.join(os.environ["temp"], "PrismRender", "tmp.####.exr")
bpy.context.scene.render.filepath = tmpOutput
if not os.path.exists(os.path.dirname(tmpOutput)):
os.makedirs(os.path.dirname(tmpOutput))
bpy.context.scene.camera = bpy.context.scene.objects[origin.cb_cam.currentText()]

# Output Path
bName = os.path.splitext(rSettings["outputName"])[0]

if not bName.endswith(self.plugin.frameString):
bName += self.plugin.frameString

bName += bpy.context.scene.render.file_extension
rSettings["outputName"] = bName
bpy.context.scene.render.filepath = rSettings["outputName"]

if not os.path.exists(os.path.dirname(rSettings["outputName"])):
os.makedirs(os.path.dirname(rSettings["outputName"]))

# usePasses = False
# if bpy.context.scene.node_tree is not None and bpy.context.scene.use_nodes:
# outNodes = [
# x for x in bpy.context.scene.node_tree.nodes if x.type == "OUTPUT_FILE"
# ]
# rlayerNodes = [
# x for x in bpy.context.scene.node_tree.nodes if x.type == "R_LAYERS"
# ]

# bName = os.path.splitext(os.path.basename(rSettings["outputName"]))
# if bName[0].endswith(self.plugin.frameString):
# bName = "%s.beauty%s%s" % (bName[0][:-5], bName[0][-5:], bName[1])
# else:
# bName = "%s.beauty%s" % (bName[0], bName[1])
# rSettings["outputName"] = os.path.join(
# os.path.dirname(rSettings["outputName"]), "beauty", bName
# )

# for m in outNodes:
# connections = []
# for idx, i in enumerate(m.inputs):
# if len(list(i.links)) > 0:
# connections.append([i.links[0], idx])

# m.base_path = os.path.dirname(rSettings["outputName"])

# for i, idx in connections:
# passName = i.from_socket.name

# if passName == "Image":
# passName = "beauty"

# if i.from_node.type == "R_LAYERS":
# if len(rlayerNodes) > 1:
# passName = "%s_%s" % (i.from_node.layer, passName)

# else:
# if hasattr(i.from_node, "label") and i.from_node.label != "":
# passName = i.from_node.label

# extensions = {
# "PNG": ".png",
# "JPEG": ".jpg",
# "JPEG2000": "jpg",
# "TARGA": ".tga",
# "TARGA_RAW": ".tga",
# "OPEN_EXR_MULTILAYER": ".exr",
# "OPEN_EXR": ".exr",
# "TIFF": ".tif",
# }
# nodeExt = extensions[m.format.file_format]
# curSlot = m.file_slots[idx]
# if curSlot.use_node_format:
# ext = nodeExt
# else:
# ext = extensions[curSlot.format.file_format]

# curSlot.path = "../%s/%s" % (
# passName,
# os.path.splitext(os.path.basename(rSettings["outputName"]))[
# 0
# ].replace("beauty", passName)
# + ext,
# )
# newOutputPath = os.path.abspath(
# os.path.join(
# rSettings["outputName"],
# "../..",
# passName,
# os.path.splitext(os.path.basename(rSettings["outputName"]))[
# 0
# ].replace("beauty", passName)
# + ext,
# )
# )
# if passName == "beauty":
# rSettings["outputName"] = newOutputPath
# usePasses = True

# if usePasses:
# import platform

# if platform.system() == "Windows":
# tmpOutput = os.path.join(os.environ["temp"], "PrismRender", "tmp.####.png")
# bpy.context.scene.render.filepath = tmpOutput
# if not os.path.exists(os.path.dirname(tmpOutput)):
# os.makedirs(os.path.dirname(tmpOutput))

@err_decorator
def undoRenderSettings(self, origin, rSettings):
Expand All @@ -266,14 +284,18 @@ def undoRenderSettings(self, origin, rSettings):
bpy.context.scene.frame_start = rSettings["start"]
if "end" in rSettings:
bpy.context.scene.frame_end = rSettings["end"]
if "fileformat" in rSettings:
bpy.context.scene.render.image_settings.file_format = rSettings["fileformat"]
if "overwrite" in rSettings:
bpy.context.scene.render.use_overwrite = rSettings["overwrite"]
if "fileextension" in rSettings:
bpy.context.scene.render.use_file_extension = rSettings["fileextension"]
if "resolutionpercent" in rSettings:
bpy.context.scene.render.resolution_percentage = rSettings["resolutionpercent"]
if "overwrite" in rSettings:
bpy.context.scene.render.use_overwrite = rSettings["overwrite"]
if "placeholder" in rSettings:
bpy.context.scene.render.use_placeholder = rSettings["placeholder"]
if "camera" in rSettings:
bpy.context.scene.camera = bpy.context.scene.objects[rSettings["camera"]]
if "origOutputName" in rSettings:
bpy.context.scene.render.filepath = rSettings["origOutputName"]

@err_decorator
def preSubmitChecks(self, origin, jobData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,49 +152,49 @@ def startJob(self, origin, jobData={}):
bpy.ops.file.unpack_all(method='USE_LOCAL')
bpy.ops.file.find_missing_files(\'EXEC_DEFAULT\', directory=\'%s\')

usePasses = False
if bpy.context.scene.node_tree is not None and bpy.context.scene.use_nodes:
outNodes = [x for x in bpy.context.scene.node_tree.nodes if x.type == 'OUTPUT_FILE']
rlayerNodes = [x for x in bpy.context.scene.node_tree.nodes if x.type == 'R_LAYERS']
# usePasses = False
# if bpy.context.scene.node_tree is not None and bpy.context.scene.use_nodes:
# outNodes = [x for x in bpy.context.scene.node_tree.nodes if x.type == 'OUTPUT_FILE']
# rlayerNodes = [x for x in bpy.context.scene.node_tree.nodes if x.type == 'R_LAYERS']

for m in outNodes:
connections = []
for idx, i in enumerate(m.inputs):
if len(list(i.links)) > 0:
connections.append([i.links[0], idx])
# for m in outNodes:
# connections = []
# for idx, i in enumerate(m.inputs):
# if len(list(i.links)) > 0:
# connections.append([i.links[0], idx])

m.base_path = os.path.dirname("%s")
# m.base_path = os.path.dirname("%s")

for i, idx in connections:
passName = i.from_socket.name
# for i, idx in connections:
# passName = i.from_socket.name

if passName == "Image":
passName = "beauty"
# if passName == "Image":
# passName = "beauty"

if i.from_node.type == "R_LAYERS":
if len(rlayerNodes) > 1:
passName = "%%s_%%s" %% (i.from_node.layer, passName)

else:
if hasattr(i.from_node, "label") and i.from_node.label != "":
passName = i.from_node.label

extensions = {"PNG": ".png", "JPEG": ".jpg", "JPEG2000": "jpg", "TARGA": ".tga", "TARGA_RAW": ".tga", "OPEN_EXR_MULTILAYER": ".exr", "OPEN_EXR": ".exr", "TIFF": ".tif" }
nodeExt = extensions[m.format.file_format]
curSlot = m.file_slots[idx]
if curSlot.use_node_format:
ext = nodeExt
else:
ext = extensions[curSlot.format.file_format]
# if i.from_node.type == "R_LAYERS":
# if len(rlayerNodes) > 1:
# passName = "%%s_%%s" %% (i.from_node.layer, passName)

# else:
# if hasattr(i.from_node, "label") and i.from_node.label != "":
# passName = i.from_node.label

# extensions = {"PNG": ".png", "JPEG": ".jpg", "JPEG2000": "jpg", "TARGA": ".tga", "TARGA_RAW": ".tga", "OPEN_EXR_MULTILAYER": ".exr", "OPEN_EXR": ".exr", "TIFF": ".tif" }
# nodeExt = extensions[m.format.file_format]
# curSlot = m.file_slots[idx]
# if curSlot.use_node_format:
# ext = nodeExt
# else:
# ext = extensions[curSlot.format.file_format]

# curSlot.path = "../%%s/%%s" %% (passName, os.path.splitext(os.path.basename("%s"))[0].replace("beauty", passName) + ext)
usePasses = True

if usePasses:
tmpOutput = os.path.join(os.environ["temp"], "PrismRender", "tmp.####.exr")
bpy.context.scene.render.filepath = tmpOutput
if not os.path.exists(os.path.dirname(tmpOutput)):
os.makedirs(os.path.dirname(tmpOutput))
# # # curSlot.path = "../%%s/%%s" %% (passName, os.path.splitext(os.path.basename("%s"))[0].replace("beauty", passName) + ext)
# usePasses = True

# if usePasses:
# tmpOutput = os.path.join(os.environ["temp"], "PrismRender", "tmp.####.exr")
# bpy.context.scene.render.filepath = tmpOutput
# if not os.path.exists(os.path.dirname(tmpOutput)):
# os.makedirs(os.path.dirname(tmpOutput))

bpy.ops.wm.save_mainfile()

Expand Down
Loading