A more realistic recorded OS fragment (captured from UI and typical of Creo) looks like:
!MK_RECT_EXTRUDE
!OS=1
!Select Top plane
SELECT(3,FEATURE,TOP)
!Create Sketch
MENU_ACTIVATE(ModelEdit)
MENU_COMMAND(NewSketch)
!Sketch: create rectangle by corner points
SKETCH_CREATE_RECTANGLE( X1=-10, Y1=-5, X2=10, Y2=5 )
!Finish sketch
MENU_COMMAND(Accept)
!Extrude
MENU_ACTIVATE(Geometry)
MENU_COMMAND(Extrude)
SET_EXTRUDE_DEPTH(5)
MENU_COMMAND(Accept)
!Save
MENU_COMMAND(Save)
Use this style as a template and replace values with parameters or relations. creo mapkey os script example
timestamp = datetime.datetime.now().isoformat() output_file = bom_file.replace('.txt', '_processed.csv') with open(output_file, 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(['Timestamp', 'Part Number', 'Quantity']) for line in lines[1:]: # skip header parts = line.strip().split('\t') if len(parts) >= 2: writer.writerow([timestamp, parts[0], parts[1]]) A more realistic recorded OS fragment (captured from
For complex data processing (CSV formatting, database uploads), Python is superior. Use this style as a template and replace
This article shows how to create and use Creo Mapkeys and Object Script (OS) to automate repetitive tasks in Creo Parametric. It includes a working example, explanation of key elements, and tips for debugging and portability.
A more realistic recorded OS fragment (captured from UI and typical of Creo) looks like:
!MK_RECT_EXTRUDE
!OS=1
!Select Top plane
SELECT(3,FEATURE,TOP)
!Create Sketch
MENU_ACTIVATE(ModelEdit)
MENU_COMMAND(NewSketch)
!Sketch: create rectangle by corner points
SKETCH_CREATE_RECTANGLE( X1=-10, Y1=-5, X2=10, Y2=5 )
!Finish sketch
MENU_COMMAND(Accept)
!Extrude
MENU_ACTIVATE(Geometry)
MENU_COMMAND(Extrude)
SET_EXTRUDE_DEPTH(5)
MENU_COMMAND(Accept)
!Save
MENU_COMMAND(Save)
Use this style as a template and replace values with parameters or relations.
timestamp = datetime.datetime.now().isoformat() output_file = bom_file.replace('.txt', '_processed.csv') with open(output_file, 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(['Timestamp', 'Part Number', 'Quantity']) for line in lines[1:]: # skip header parts = line.strip().split('\t') if len(parts) >= 2: writer.writerow([timestamp, parts[0], parts[1]])
For complex data processing (CSV formatting, database uploads), Python is superior.
This article shows how to create and use Creo Mapkeys and Object Script (OS) to automate repetitive tasks in Creo Parametric. It includes a working example, explanation of key elements, and tips for debugging and portability.