Skip to content

Commit

Permalink
remove access to bpy.context in filesaver code (LuxCoreRender#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theverat committed Nov 5, 2018
1 parent 93cabfa commit d090b86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doc/project_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ It's also responsible for scene and session updates during viewport render sessi
Note: If we have a context (i.e. `context is not None`) then we are in viewport render mode.
If we have no context (`context is None`) then we are in final render or material preview mode.
This is not explained/commented all the time in the code because it's such a fundamental concept.
However, it's not like we have no context at all in final render mode, you can still get it with `bpy.context`.
But it is not passed into the methods by the RenderEngine API in Blender.
Important: It is forbidden by the Blender API to access the context during final render, so you
should not resort to hacks like using `bpy.context` when there is no context passed into a function.

Note also that nodes are not exported here, they have their own
export methods in their classes (in the **nodes** directory, see below).
Expand Down
2 changes: 1 addition & 1 deletion export/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _convert_filesaver(scene, definitions, luxcore_engine):
filesaver_path = config.filesaver_path
output_path = utils.get_abspath(filesaver_path, must_exist=True, must_be_existing_dir=True)

blend_name = bpy.path.basename(bpy.context.blend_data.filepath)
blend_name = bpy.path.basename(bpy.data.filepath)
blend_name = os.path.splitext(blend_name)[0] # remove ".blend"

if not blend_name:
Expand Down

0 comments on commit d090b86

Please sign in to comment.