How to extract workbench project name and project directory from Mechanical scripting editor?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 242
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭

How to extract workbench project name and project directory from Mechanical scripting editor?

Best Answer

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 242
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    Here is a script that can be used in Mechanical Scripting Editor.

    import wbjn
    import os
    
    project_files_dir = wbjn.ExecuteCommand(ExtAPI, "returnValue(GetProjectDirectory())")
    project_wbjn_path = wbjn.ExecuteCommand(ExtAPI, "returnValue(GetProjectFile())")
    project_name = os.path.relpath(project_wbjn_path, project_files_dir)