I think i sort of understand now. In this addon the preview is somehow hardcoded into the main render fucntion.
I added this part to render engine, its the part of the simple render from that api page.
def render_preview(self, scene):
pixel_count = self.size_x * self.size_y
# The framebuffer is defined as a list of pixels, each pixel
# itself being a list of R,G,B,A values
green_rect = [[1.0, 1.0, 0.0, 1.0]] * pixel_count
#green_rect = [[bpy.data.materials[bpy.context.object.active_material.name].diffuse_color]] * pixel_count
# Here we write the pixel values to the RenderResult
result = self.begin_result(0, 0, self.size_x, self.size_y)
layer = result.layers[0].passes["Combined"]
layer.rect = green_rect
self.end_result(result)
I noticed the preview show the green and than later was added as an icon. So im now gonna try to add the preview render part which is in the main render engine function.
See here is the top part of the main render funcion. I think the preview part should not be here but in the render_preview function. Its not there now but with the test i did, than the icon seems to be updating
def render(self, scene):
def testBreak(self):
if self.test_break():
thea_globals.log.debug("## KILL ENGINE")
global exporter, tmpTheaRenderFile, imgTheaRenderFile, scn, outputImage, selectedObjects, dataPath, materialUpdated
(exportPath, theaPath, theaDir, dataPath, currentBlendDir, currentBlendFile) = setPaths(scene)
scale = scene.render.resolution_percentage / 100.0
self.size_x = int(scene.render.resolution_x * scale)
self.size_y = int(scene.render.resolution_y * scale)
if self.is_preview:
self.render_preview(scene)
if scene.name != "preview":
world = bpy.context.scene.world
# CHECK IF PATH existS
expPath = os.path.exists(exportPath)
if expPath == False:
self.report({'ERROR'}, "Please check export path, See Render>Output panel")
return {'FINISHED'}
if world is None:
self.report({'ERROR'}, "Please add atleast 1 world in World tab. ")
return {'FINISHED'}
if not camCheck():
self.report({'ERROR'}, "Please make sure scene camera is visible")
return {'FINISHED'}
if len(currentBlendFile) < 2:
self.report({'ERROR'}, "Please save the scene before exporting!")
return {'FINISHED'}
if (checkTheaMaterials() == False):
self.report({'ERROR'}, "Please set materials and lights to get proper render")
# return {'FINISHED'}
if (checkTheaExtMat() == False):
self.report({'ERROR'}, "Please check linked materials")
# thea_globals.log.debug("*** CheckMaterials = %s ***" % checkTheaExtMat())
return {'FINISHED'}
if not os.path.isdir(exportPath):
self.report({'ERROR'}, "Please set proper output path before exporting!")
return {'FINISHED'}
if scene.thea_Selected:
obList = [ o for o in bpy.context.scene.objects if o.select ]
if len(obList) == 0:
self.report({'ERROR'}, "Selection Only needs atleast 1 object")
return {'FINISHED'}
checkTheaExtMat()
valuesExt = checkTheaExtMat()
if scene.thea_useExtMatCheck:
if (valuesExt[0] == False):
# self.report({'ERROR'}, "Please link Material: %s > Object: %s" % (valuesExt[1], valuesExt[2]))
missing_Mat = ""
for mat in valuesExt[3]:
missing_Mat = missing_Mat + "\n" + mat
self.report({'ERROR'}, "Please link Material:%s" % missing_Mat)
# thea_globals.log.debug("*** CheckMaterials = %s ***" % valuesExt[1])
return {'FINISHED'}
calculatePreview = True
previewGeneratorPort = 30001
renderInProgress = False
r = scene.render
material = False
# return
# compute resolution
x = int(r.resolution_x * r.resolution_percentage * 0.01)
y = int(r.resolution_y * r.resolution_percentage * 0.01)
if (x <= 80) or (y <= 80):
return
def update_image(image, layer, sx, sy, x, y):
result = self.begin_result(sx, sy, x, y)
lay = result.layers[layer]
# time.sleep(0.1)
try:
lay.load_from_file(image)
except:
pass
self.end_result(result)
I probably sound fuzzy… hope you understand what im trying to explain