Prompt Details
Model
Chat - GPT-4o (gpt-4o)
Token size
80 ($0.00400 / call)
Example input
[Generate a Python script that automates sketch creation and extrusion in Siemens NX. The script should create a new sketch on the XY plane, draw a circle of a given diameter, extrude it to a specified height, and save the part file. Ensure the script is optimized for efficiency and error handling.]: Write a Python script to automate part modeling in Siemens NX. The script should open an existing part, create a sketch on the XY plane, draw a circle of 50mm diameter at the origin, extrude it to 100mm height, and save the part as 'Cylinder.prt
Example output
import nxopen
import nxopen.uf
def main():
# Open NX session
the_session = nxopen.Session.GetSession()
work_part = the_session.Parts.Work
ufs = nxopen.uf.UFSession.GetUFSession()
# Create a new sketch on XY plane
datum_plane = work_part.Datums.FindObject("XY plane")
sketch = work_part.Sketches.CreateSketch(datum_plane)
sketch.Activate(nxopen.Sketch.ViewReorient.True)
# Draw a circle at origin
origin = nxopen.Point3d(0.0, 0.0, 0.0)
circle = sketch.CreateCircle(origin, 25.0) # 25mm diameter
# Extrude the sketch
extrude_builder = work_part.Features.CreateExtrudeBuilder(None)
extrude_builder.Section.AddSketch(sketch)
extrude_builder.Limits.StartExtend.Value = 0.0
extrude_builder.Limits.EndExtend.Value = 50.0 # 50mm height
extrude = extrude_builder.CommitFeature()
extrude_builder.Destroy()
# Save the part
work_part.SaveAs("Automated_Part.prt")
print("Part created and saved successfully.")
if __name__ == "__main__":
main()
By purchasing this prompt, you agree to our terms of service
GPT-4O
NX AutoSketch Extrusion β Automate Your Siemens NX Workflow!
π Boost Productivity with NX Automation! π
Are you tired of repetitive modeling tasks in Siemens NX? NX Autos ketch Extrusion is a powerful Python-based automation script designed to streamline your design process, saving you time and effort!
...more
Added over 1 month ago
