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

getting error when running maya viewer #45

Open
annaberuchan opened this issue Feb 14, 2024 · 1 comment
Open

getting error when running maya viewer #45

annaberuchan opened this issue Feb 14, 2024 · 1 comment

Comments

@annaberuchan
Copy link

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.

  • usage in command line:

    • call without arguments:
      • will not start with error message: "DNAViewer needs to be run with Maya2022"
        NOTE: Script cannot be called with Python or mayapy, it' must be called in Maya Script Editor.
  • usage in Maya:

    1. copy whole content of this file to Maya Script Editor
    2. change value of ROOT_DIR to absolute path of dna_calibration, e.g. c:/dna_calibration in Windows or /home/user/dna_calibration. Important:
      Use / (forward slash), because Maya uses forward slashes in path.

    Expected: Maya will show UI.

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
Copy link
Contributor

marijavik commented Feb 29, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants