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

Fix MTL conversion bug with Mineways MTLs #397

Merged
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
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:
StandingPadAnimations marked this conversation as resolved.
Show resolved Hide resolved
lines = mtl_file.readlines()
except Exception as e:
StandingPadAnimations marked this conversation as resolved.
Show resolved Hide resolved
print(e)
return False

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