Trying using cubit.cmd()

Hello everyone,

After using a workaround for some time, I would now like to use the cubit.cmd commands directly within Python to improve my workflow.

According to the Cubit User Documentation, the path to opt/Coreform Cubit/bin needs to be added. For Nullspace, I assume this corresponds to:
”…/Nullspace EM 2023 R3/Nullspace-Prep-2023.R3/bin”
I have tried adding this path in Python as described in the documentation, as well as adding it to the Windows PATH environment variable. However, it is still not working as expected.
Could you please confirm whether this is the correct path? The bin folder contains cubit.py and several .dll files withthe same or similar names.
If you have any ideas about where the issue might be on my side, I would greatly appreciate your input.

Thank you in advance!

Kind Regards
Michael

Hi Michael,

That path looks accurate—maybe something else is missing. Below is a step-by-step guide on how to configure VS Code to execute Nullspace scripts on Windows (Note that the paths are for NS 2025). If you are not a VS Code user, you may still get some useful tips from this guide. If you’re still having problems, let me know what program you are using to execute your Python scripts.

Configure Windows Environment Variables

Step 1: Open Environment Variables

  • In windows search bar type: edit the system environment variables → click to open

  • Click Advanced tab → Environment Variables button

Step 2: Add Three New User Variables

Click New under “User variables” and add each variable (Note these are the default path):

NSEMPATH

Variable name: NSEMPATH
Variable value: C:\\Program Files\\Nullspace EM 2025 R1\\bin


Note: Verify your actual installation path

CUBIT_HOME

Variable name: CUBIT_HOME
Variable value: C:\\Program Files\\Nullspace EM 2025 R1\\Nullspace-Prep-2025.R1


Note: Verify your actual installation path

PYTHONPATH

Variable name: PYTHONPATH
Variable value: %CUBIT_HOME%\\bin


Step 3: Update PATH Variable

  • Select Path variable → Edit

  • Click New and add: %NSEMPATH%

  • Click New and add: %CUBIT_HOME%\\bin

  • Click OK on all dialogs


Configure VS Code Settings

Local Setup (per project)

  1. In your project folder, create a .vscode folder

  2. Inside .vscode, create settings.json

  3. Copy and paste this content:

{
    "python-envs.pythonProjects": [],
    "python.defaultInterpreterPath": "C:\\\\Program Files\\\\Nullspace EM 2025 R1\\\\Nullspace-Python\\\\python.exe",
    "python.terminal.activateEnvironment": true,
    "python.terminal.activateEnvInCurrentTerminal": true,
    "python.venvPath": "${workspaceFolder}",
    "python.venvFolders": ["envs", ".pyenv", ".direnv", "venv"],
    "python.terminal.executeInFileDir": true,
    "python.terminal.focusAfterLaunch": true,
    "python.terminal.launchArgs": [],
    "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]
}


  1. Copy the .vscode folder to other project folders as needed

Global Setup (all projects)

  1. Press Ctrl + Shift + P in VS Code

  2. Type and select: Preferences: Open User Settings (JSON)

  3. Add these settings (merge with existing):

{
    "security.workspace.trust.untrustedFiles": "open",
    "claudeCode.preferredLocation": "panel",
    "python.defaultInterpreterPath": "C:\\\\Program Files\\\\Nullspace EM 2025 R1\\\\Nullspace-Python\\\\python.exe"
}



Verification

  • Close and reopen VS Code

  • Open a Nullspace Python script

  • Check Python interpreter in bottom-right corner

  • Test run a script

Dear Henrik,
thank you very much for your great explanation. I’m using VS Code.
I just tried running code that worked previously, but I’m now getting an error. I’m attaching the .out file — the last line indicates what happened. This is a new error for me, and I’m not sure what it means.

About the cubit.cmd commands, VS Code find it now, if it works, I have to check with a full code but it seems to.

For completeness, here is the full terminal output:

"
Cannot open 1D GQ file C:\Program Files\Nullspace EM 2023 R3/quadrature/lgwt_3.dat … exiting …NSEM returned an error. Please check the error log for more information.Returned 1

Command ‘[‘C:\Program Files\Nullspace EM 2023 R3\bin\nsem.EXE’, ‘C:\Users\d112567\OneDrive - Politecnico di Torino\02PhD\Simulation\NullspaceEM_Simulation\Project_Topic\Plate_single_size_rotating\Test\SimPlateMaria_SmallAngle_000Deg_Iter000V8.h5’]’

returned non-zero exit status 1.

Traceback (most recent call last):

File “c:\Users\d112567\OneDrive - Politecnico di Torino\02PhD\Simulation\NullspaceEM_Simulation\Project_Topic\Plate_single_size_rotating\Python\SimPlateRot.py”, line 149, in
ModelSim.run()

File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\nsem\config.py”, line 744, in run
raise subprocess.CalledProcessError(process.returncode, process.args)
Subprocess.CalledProcess
Error: Command ‘[‘C:\Program Files\Nullspace EM 2023 R3\bin\nsem.EXE’, ‘C:\Users\d112567\OneDrive - Politecnico di Torino\02PhD\Simulation\NullspaceEM_Simulation\Project_Topic\Plate_single_size_rotating\Test\SimPlateMaria_SmallAngle_000Deg_Iter000V8.h5’]’ returned non-zero exit status 1.
PS C:\Users\d112567>
"

[Paste terminal message here]
Kind regards,
Michael

(Attachment SimPlateMaria_SmallAngle_000Deg_Iter000V8.out is missing)