Skip to content

Commit

Permalink
Fix linked node trees
Browse files Browse the repository at this point in the history
  • Loading branch information
pragma37 committed Jul 28, 2021
1 parent ba09e14 commit 10ac833
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions BlenderMalt/MaltMaterial.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def poll_tree(self, object):
parameters : bpy.props.PointerProperty(type=MaltPropertyGroup, name="Shader Parameters")

def get_source_path(self):
path = self.shader_source
if self.shader_nodes:
path = self.shader_nodes.get_generated_source_path()
return bpy.path.abspath(path, library=self.id_data.library)
return self.shader_nodes.get_generated_source_path()
else:
return bpy.path.abspath(self.shader_source, library=self.id_data.library)

def draw_ui(self, layout, extension, material_parameters):
layout.active = self.id_data.library is None #only local data can be edited
Expand Down
14 changes: 8 additions & 6 deletions BlenderMalt/MaltNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ def get_pipeline_graph(self):

def get_generated_source_dir(self):
import os, tempfile
base_path = '//'
if bpy.context.blend_data.is_saved == False:
base_path = tempfile.gettempdir()
base_path = tempfile.gettempdir()
if bpy.context.blend_data.is_saved or self.library:
base_path = bpy.path.abspath('//', library=self.library)
return os.path.join(base_path,'malt-shaders')

def get_generated_source_path(self):
import os
file_prefix = 'temp'
if bpy.context.blend_data.is_saved:
if self.library:
file_prefix = bpy.path.basename(self.library.filepath).split('.')[0]
elif bpy.context.blend_data.is_saved:
file_prefix = bpy.path.basename(bpy.context.blend_data.filepath).split('.')[0]
pipeline_graph = self.get_pipeline_graph()
if pipeline_graph:
Expand Down Expand Up @@ -154,8 +156,8 @@ def update(self):
pass

source = self.get_generated_source()
source_dir = bpy.path.abspath(self.get_generated_source_dir())
source_path = bpy.path.abspath(self.get_generated_source_path())
source_dir = self.get_generated_source_dir()
source_path = self.get_generated_source_path()
import pathlib
pathlib.Path(source_dir).mkdir(parents=True, exist_ok=True)
with open(source_path,'w') as f:
Expand Down

0 comments on commit 10ac833

Please sign in to comment.