EpicGames / MetaHuman-DNA-Calibration

https://epicgames.github.io/MetaHuman-DNA-Calibration/
Other
404 stars 104 forks source link

getting error when running maya viewer #45

Open annaberuchan opened 4 months ago

annaberuchan commented 4 months ago

Hi, I think I did everything right, yet I cannot get the maya window:

Error: ImportError: file line 49: cannot import name 'show_dna_viewer_window' from 'dna_viewer' (C:\dna_callibration\dna_viewer__init__.py)

  1. I made sure I downloaded python3

  2. I downloaded: MetaHuman-DNA-Calibration-1.0.1

  3. I copied the files in the ''lib'' folder to C:\MEGAscan\support\plugins\maya\6.8\MSLiveLink\DHI\lib\Windows\python3

  4. In Maya, I executed one by one: import dna

import sys sys.modules["dna"]

  1. I executed the script from dna_viewer_run_in_maya I changed line 25 for the location of the folder

""" This example demonstrates Maya UI Window for simple and non-programmatic creation the scene with the creating functional rig.

NOTE: If running on Linux, please make sure to append the LD_LIBRARY_PATH with absolute path to the lib/linux directory before running the example: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: """

from os import environ from os import path as ospath from sys import path as syspath from sys import platform

if you use Maya, use absolute path

ROOT_DIR = f"{ospath.dirname(ospath.abspath(file))}/..".replace("\", "/")

ROOT_DIR = f'C:\dna_callibration' ROOT_LIB_DIR = f"{ROOT_DIR}/lib" if platform == "win32": LIB_DIR = f"{ROOT_LIB_DIR}/windows" elif platform == "linux": LIB_DIR = f"{ROOT_LIB_DIR}/linux" else: raise OSError( "OS not supported, please compile dependencies and add value to LIB_DIR" )

Add bin directory to maya plugin path

if "MAYA_PLUG_IN_PATH" in environ: separator = ":" if platform == "linux" else ";" environ["MAYA_PLUG_IN_PATH"] = separator.join([environ["MAYA_PLUG_IN_PATH"], LIB_DIR]) else: environ["MAYA_PLUG_IN_PATH"] = LIB_DIR

Adds directories to path

syspath.insert(0, ROOT_DIR) syspath.insert(0, LIB_DIR)

this example is intended to be used in Maya

from dna_viewer import show_dna_viewer_window

show_dna_viewer_window()

Any help is greatly appreciated, thank you!!

marijavik commented 4 months ago

Hi,

could you copy just code snippet from Maya script editor? It is difficult to follow with all this comments coming from the example. There is no need to copy lib folder anywhere. This snippet works for me:

from sys import path as syspath
from sys import platform

ROOT_DIR = "D:/work/pycharmspace/MetaHuman-DNA-Calibration"

MAYA_VERSION = "2022"  # or 2023
ROOT_LIB_DIR = f"{ROOT_DIR}/lib/Maya{MAYA_VERSION}"
if platform == "win32":
    LIB_DIR = f"{ROOT_LIB_DIR}/windows"
elif platform == "linux":
    LIB_DIR = f"{ROOT_LIB_DIR}/linux"
else:
    raise OSError(
        "OS not supported, please compile dependencies and add value to LIB_DIR"
    )

syspath.insert(0, ROOT_DIR)
syspath.insert(0, LIB_DIR)

import dna_viewer
dna_viewer.show()