Created
March 31, 2022 08:40
-
-
Save ovidner/90e7c404b5822a5f1ad08278ab9581d2 to your computer and use it in GitHub Desktop.
Install NXOpen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pathlib | |
import site | |
def main(): | |
# Hack-ish way to get site-packages | |
site_packages_path = pathlib.Path( | |
[x for x in site.getsitepackages() if "site-packages" in x][0] | |
) | |
pth_file_path = site_packages_path / "nxopen.pth" | |
ugii_base_dir = os.getenv("UGII_BASE_DIR", None) | |
if not ugii_base_dir: | |
raise Exception("Cannot find NX installation (no UGII_BASE_DIR variable).") | |
print(f"Found NX installation at {ugii_base_dir}") | |
nxopen_path = pathlib.Path(ugii_base_dir) / "NXBIN" / "python" | |
pth_file_path.write_text(str(nxopen_path.resolve())) | |
print(f"Installed NXOpen through {pth_file_path}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment