User Guide
Last update: 17.07.2025What You Can Do with Automation in Speos for NX
You can create new Speos for NX features or modify existing features, run and export simulations using scripts.
This section gives you an overview of what Speos for NX Library can achieve with one example of Python script.
This section contains the following topics:
- How to create an NX Journal Python
- How to create a Speos for NX Python script
- How to run an NX Journal
How to create an NX Journal Python
- Create a text file in the target directory.
- Edit it with a text editor.
- Change its extension for .py.
-Or-
- Press Ctrl + M on your keyboard.
- Click Menu, Tools, Journal, Record.
- Type the name of the journal.
- Click OK.
- Click Menu, Tools, Journal, Stop Recording.
How to create a Speos for NX Python script
- Open your .py journal.
- Rewrite the function as below:
# Imports system packages
import sys
import os
Imports the NX library
import NXOpen
Retrieves the Speos library directory path using the "SPEOS_NX_DIR" environment variable.
snxdir = os.getenv('SPEOS_NX_DIR', '') + '\application'
Sets the Speos library directory path in the system environment.
sys.path.append(snxdir)
Imports the Speos library
import SpeosNX
def main():
# Gets the NX session.
MyNXSession = NXOpen.Session.GetSession()
# Gets the Speos session.
Session = SpeosNX.Session.GetSession()
# Gets the Speos part collection.
PartCollection = Session.Parts
# Loads all parts that contain Speos features.
PartCollection.Load()
# Gets the currents NX work part.
workPart = MyNXSession.Parts.Work
# Gets the current working part's Speos feature collection.
FeatureCollection = PartCollection.Work.Features
origin = workPart.Features.FindObject("DATUM_CSYS(0)").FindObject("POINT 1")
xAxis = workPart.Datums.FindObject("DATUM_CSYS(0) X axis")
yAxis = workPart.Datums.FindObject("DATUM_CSYS(0) Z axis")
# Create the feature Builder
MySpeosFeature = None
IrradianceSensor = FeatureCollection.CreateSensorIrradianceBuilder(MySpeosFeature)
# Feature name,
IrradianceSensor.Name = "Irradiance Sensor"
# Axis System
IrradianceSensor.AxisSystem.OriginPoint = origin.Tag
IrradianceSensor.AxisSystem.DirectionX = xAxis.Tag
IrradianceSensor.AxisSystem.DirectionY = yAxis.Tag
# Create the feature
IrradianceSensor.Commit()
if name == 'main':
main()
How to run an NX Journal
- In Menu, click Tools, Journal, Play....
- Select the journal to play from Recently Accessed Journals.
-Or-
- Browse for the journal to start.
- Click Run.
Note: You can also edit the journal from Speos for NX. You can add journal arguments.