Skip to content

Instantly share code, notes, and snippets.

@ovidner
Created March 31, 2022 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovidner/90e7c404b5822a5f1ad08278ab9581d2 to your computer and use it in GitHub Desktop.
Save ovidner/90e7c404b5822a5f1ad08278ab9581d2 to your computer and use it in GitHub Desktop.
Install NXOpen
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