Skip to content

Commit

Permalink
Merge pull request #397 from StandingPadAnimations/mtl-conversion-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StandingPadAnimations committed Mar 17, 2023
2 parents e9c2a1b + ba194ab commit eb44f32
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions MCprep_addon/world_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,25 @@ def convert_mtl(filepath):
Returns:
True if success or skipped, False if failed, or None if skipped
"""
mtl = filepath.rsplit(".", 1)[0] + '.mtl'
# Check if the MTL exists. If not, then check if it
# uses underscores. If still not, then return False
mtl = Path(filepath.rsplit(".", 1)[0] + '.mtl')
if not mtl.exists():
mtl_underscores = Path(mtl.parent.absolute()) / mtl.name.replace(" ", "_")
if mtl_underscores.exists():
mtl = mtl_underscores
else:
return False

lines = None
copied_file = None
with open(mtl, 'r') as mtl_file:
lines = mtl_file.readlines()

try:
with open(mtl, 'r') as mtl_file:
lines = mtl_file.readlines()
except Exception as e:
print(e)
return False

if bpy.context.scene.view_settings.view_transform in BUILTIN_SPACES:
return None
Expand Down

0 comments on commit eb44f32

Please sign in to comment.