Learn Nx-open - 10 Code Examples & CST Typing Practice Test
NX Open is the API and programming interface of Siemens NX CAD/CAM/CAE software, allowing automation, customization, and integration through scripting and compiled languages such as Python, C#, and Java.
Learn NX-OPEN with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Create a New Part (NXOpen)
Imports NXOpen
Imports NXOpen.UF
Module NXModule
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim part As Part
part = theSession.Parts.NewDisplay("NewPart", Part.Units.Millimeters)
End Sub
End Module
Opens a new part document in NX via NXOpen API.
Create a Sketch on XY Plane
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim sketches As Sketches = workPart.Sketches
Dim xyPlane As Plane = workPart.Planes.FindObject("XY Plane")
Dim sketch As Sketch = sketches.CreateSketch(xyPlane)
Creates a new sketch on the XY plane in the active part.
Draw a Line in Sketch
Dim sketchCurve As SketchLine = sketch.CreateLine(0, 0, 0.1, 0.1)
Adds a line segment to the current sketch.
Draw a Circle in Sketch
Dim sketchCircle As SketchCircle = sketch.CreateCircleByRadius(0, 0, 0, 0.05)
Creates a circle with a center and radius in a sketch.
Extrude a Sketch
Dim extrudeBuilder As ExtrudeFeatureBuilder = workPart.Features.CreateExtrudeFeatureBuilder(sketch)
extrudeBuilder.SetDistance(0.1, NXOpen.SmartObject.UpdateOption.AfterModeling)
extrudeBuilder.CommitFeature()
extrudeBuilder.Destroy()
Extrudes the selected sketch to create a 3D solid body.
Create a Rectangle Sketch
Dim l1 As SketchLine = sketch.CreateLine(0, 0, 0.1, 0)
Dim l2 As SketchLine = sketch.CreateLine(0.1, 0, 0.1, 0.05)
Dim l3 As SketchLine = sketch.CreateLine(0.1, 0.05, 0, 0.05)
Dim l4 As SketchLine = sketch.CreateLine(0, 0.05, 0, 0)
Draws a rectangle in a sketch using four lines.
Apply Fillet to Edge
Dim edge As Edge = workPart.Bodies.FindObject("Edge1")
Dim filletBuilder As FilletFeatureBuilder = workPart.Features.CreateFilletFeatureBuilder(edge)
filletBuilder.SetRadius(0.01)
filletBuilder.CommitFeature()
filletBuilder.Destroy()
Applies a fillet to a selected edge of a solid body.
Add Material to Part
Dim material As Material = workPart.Materials.FindObject("Steel")
workPart.SetMaterial(material)
Assigns a material to the active part.
Create Circular Pattern
Dim feature As Feature = workPart.Features.FindObject("Extrude1")
Dim axis As Axis = workPart.Axes.FindObject("Z_Axis")
Dim patternBuilder As PatternFeatureBuilder = workPart.Features.CreatePatternFeatureBuilder(feature)
patternBuilder.SetCircularPattern(axis, 6, 360)
patternBuilder.CommitFeature()
patternBuilder.Destroy()
Patterns a feature in a circular pattern around an axis.
Save Part Document
workPart.SaveAs("C:\Users\Public\Documents\NXParts\Part1.prt")
Saves the active part to a specified file path.
Frequently Asked Questions about Nx-open
What is Nx-open?
NX Open is the API and programming interface of Siemens NX CAD/CAM/CAE software, allowing automation, customization, and integration through scripting and compiled languages such as Python, C#, and Java.
What are the primary use cases for Nx-open?
Automating repetitive CAD modeling tasks. Creating custom design or simulation workflows. Batch generation of drawings and reports. Integrating NX with PLM/PDM systems. Custom feature development and CAD add-ons
What are the strengths of Nx-open?
Deep integration with NX environment. Supports multiple programming languages. Enables full automation of complex CAD tasks. Accessible to both engineers and programmers. Reduces repetitive work and human error
What are the limitations of Nx-open?
Requires learning NX object model and API. NX license required. Complex workflows may need advanced scripting. Debugging scripts inside NX can be slow. Performance depends on NX and system hardware
How can I practice Nx-open typing speed?
CodeSpeedTest offers 10+ real Nx-open code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.