51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
|
"""
|
||
|
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:<path-to-lib-linux-dir>
|
||
|
"""
|
||
|
|
||
|
|
||
|
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_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()
|