MaterialXMaterials 1.39.5
Utilities for retrieving materials from remote servers
Loading...
Searching...
No Matches
__main__.py
1import sys, os
2import subprocess
3
4def main() -> int:
5 '''
6 Main entry point for running commands in the package.
7 '''
8 argCount = len(sys.argv)
9 if argCount < 2:
10 print('No arguments provided. Use -h or --help for help.')
11 return 1
12 if sys.argv[1] == '-h' or sys.argv[1] == '--help':
13 print('Usage: python -m materialxMaterials <command> [options] where command is gpuopen, physbased, acg (AmbientCG), or polyhaven')
14 return 0
15
16 # Check if the command is valid
17 cmdArgs = sys.argv[1:]
18 if cmdArgs[0] == 'physbased':
19 cmdArgs[0] = 'physicallyBasedMaterialXCmd.py'
20 elif cmdArgs[0] == 'gpuopen':
21 cmdArgs[0] = 'GPUOpenLoaderCmd.py'
22 elif cmdArgs[0] == 'acg':
23 cmdArgs[0] = 'ambientCGLoaderCmd.py'
24 elif cmdArgs[0] == 'polyhaven':
25 cmdArgs[0] = 'polyHavenLoaderCmd.py'
26 else:
27 print('Unknown command specified:', cmdArgs[0])
28 return 1
29
30 packageLocation = os.path.dirname(__file__)
31 python_exec = sys.executable
32 script_path = os.path.join(packageLocation, cmdArgs[0])
33
34 cmd = [python_exec, script_path] + cmdArgs[1:]
35 print('Running command:', ' '.join(cmd))
36
37 # Run the command
38 return subprocess.call(cmd, shell=False)
39
40if __name__ == '__main__':
41 sys.exit(main())