Skip to content
Draft
Show file tree
Hide file tree
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
25 changes: 23 additions & 2 deletions Maya/MAYA_APP_DIR/modules/DazToMaya/scripts/Definitions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
import os

from typing import List
def try_paths(paths: List[str], file: str):
if os.path.isabs(file):
return file if os.path.exists(file) else False

tried = []
for path in paths:
newPath = os.path.join(path, file)
if os.path.exists(newPath):
return newPath
else:
tried.append(newPath)

raise FileNotFoundError("Tried paths: \n" + "\n".join(tried))
# return False

HOME_DIR = os.path.expanduser("~")
ROOT_DIR = os.path.join(HOME_DIR, "DAZ 3D", "Bridges", "Daz To Maya")
EXPORT_DIR = os.path.join(ROOT_DIR, "Exports")

ROOT_DIRS = [
os.path.join(HOME_DIR, "DAZ 3D", "Bridges", "Daz To Maya"),
os.path.join(HOME_DIR, "Documents", "DAZ 3D", "Bridges", "Daz To Maya"),
]

EXPORT_DIRS = [ os.path.join(dir, "Exports") for dir in ROOT_DIRS ]
18 changes: 9 additions & 9 deletions Maya/MAYA_APP_DIR/modules/DazToMaya/scripts/d2m.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@


# no delete morph, editer for user...

d2m_logo = os.path.abspath("../icons/d2m_import_logo.png")
d2m_banner = os.path.abspath("../icons/d2m_banner.png")
d2m_help_icon = os.path.abspath("../icons/d2m_help_icon.png")
txtConf = os.path.abspath("../scripts/d2m.cfg")
DIRNAME = os.path.dirname(os.path.abspath(__file__))
d2m_logo = os.path.join(DIRNAME, "../icons/d2m_import_logo.png")
d2m_banner = os.path.join(DIRNAME, "../icons/d2m_banner.png")
d2m_help_icon = os.path.join(DIRNAME, "../icons/d2m_help_icon.png")
txtConf = os.path.join(DIRNAME, "../scripts/d2m.cfg")

scale_menu_value = "Automatic"

Expand Down Expand Up @@ -2368,19 +2368,19 @@ def import_fbx(daz_file_path):
if scale_menu_value == "x0.01 (smaller)":
# FORCE cm Correct Unit....... CHELO
mel.eval('FBXImportConvertUnitString m')

daz_file_path = daz_file_path.replace('\\', '/')

import_cmd = "FBXImport -f \"" + daz_file_path + "\""
mel.eval(import_cmd)


def auto_import_daz():

# Importing only first figure for now
daz_file_path = os.path.abspath(Definitions.EXPORT_DIR + "\FIG\FIG0\B_FIG.fbx")
daz_file_path = Definitions.try_paths(Definitions.EXPORT_DIRS, os.path.join("FIG", "FIG0", "B_FIG.fbx"))

# exit if file not found
if os.path.exists(daz_file_path) == False:
if not daz_file_path:
open_import_not_found_window()
return

Expand Down
4 changes: 2 additions & 2 deletions Maya/MAYA_APP_DIR/modules/DazToMaya/scripts/dazmaterials.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pymel.core as pm
import maya.cmds as cmds

from Definitions import EXPORT_DIR
from Definitions import EXPORT_DIRS, try_paths
from DtuLoader import DtuLoader
from TextureLib import texture_library, texture_maps

Expand All @@ -20,7 +20,7 @@ def load_materials(self):
"""
Load materials from Dtu file
"""
dtu_path = os.path.abspath(EXPORT_DIR + "\FIG\FIG0")
dtu_path = try_paths(EXPORT_DIRS, os.path.join("FIG", "FIG0"))
dtu_loader = DtuLoader(dtu_path)
mats = dtu_loader.get_materials_list()
for mat in mats:
Expand Down