In PTC Creo, Mapkeys are powerful keyboard shortcuts that record a series of UI actions, but their most advanced feature is the ability to run OS Scripts. This allows you to execute commands directly in your operating system (like Windows CMD or Batch files) without leaving the Creo environment. OS Script Mapkey Example
A common use for an OS script is to launch an external tool or perform a file management task. For instance, you can create a mapkey that opens a calculator or copies a configuration file to your working directory.
Basic Syntax in config.pro:To run a command, the mapkey uses the @SYSTEM prefix. Example: Open Windows Calculator mapkey c @SYSTEM start calc.exe; Use code with caution. Copied to clipboard
How it works: When you type c in Creo, it executes the Windows start command to open the calculator. Example: Open Current Working Directory mapkey owd @SYSTEM start explorer . Use code with caution. Copied to clipboard
How it works: This launches Windows Explorer directly to your current Creo working directory. How to Create an OS Script Mapkey
Open the Mapkeys dialog (File > Options > Environment > Mapkey Settings). Click New and define your key sequence (e.g., os). Go to the OS Script tab.
Type your command (e.g., start notepad.exe) into the text area. Click OK and save to your config.pro to make it permanent. Advanced "Interesting" Use Cases
Select a file in assy and run mapkey to "Show file in Windows Explorer"
In Creo Parametric, a mapkey using an OS script allows you to execute operating system commands (like Windows CMD or batch files) directly from within your CAD session. This is a powerful way to automate tasks that Creo cannot do natively, such as managing external files or launching third-party applications. Useful Feature: Automatically Opening the Working Directory
A highly practical use for an OS script mapkey is a "Quick Open Explorer" command. Instead of manually navigating through Windows to find your current project files, this script triggers Windows Explorer to open exactly where you are working in Creo.
Example Mapkey Code:You can add this line to your config.pro (or mapkeys.pro in newer versions) to map the shortcut wd to open your working directory: mapkey wd @SYSTEM start explorer . Use code with caution. Copied to clipboard
@SYSTEM: This prefix tells Creo that the following text is an operating system command rather than a Creo internal command.
start explorer .: This is a standard Windows command where . represents the current folder (your Creo working directory). Other Practical Examples
Launch a Calculator: Use mapkey calc @SYSTEM start calc.exe to quickly bring up a calculator without leaving your workspace.
External File Management: Run a batch file that renames or moves exported PDFs and DXFs to a specific server location immediately after they are generated.
Purge Files: Create a mapkey that runs the purge command in your working directory to delete old iterations and save disk space. Key Benefits of OS Scripts
Non-Interruptive: You can start these scripts without minimizing Creo or switching focus away from your design.
Workflow Integration: They bridge the gap between CAD modeling and your broader file management or simulation pipeline.
Automation of Repetitive Tasks: For instance, you could script a process to copy specific configuration files from a central company directory into your local session. Mapkey Copy & Paste - PTC Community
You're looking for a good piece related to CREO Mapkey OS Script example.
What is CREO Mapkey?
CREO Mapkey is a feature in PTC CREO that allows users to create custom keyboard shortcuts, automate repetitive tasks, and streamline their workflow. Mapkey is a powerful tool that enables users to record and playback a sequence of actions, which can be saved and reused.
What is OS Script?
OS Script is a feature in CREO that allows users to automate tasks using scripts written in a programming language, such as Visual Basic Scripting Edition (VBSE) or JavaScript. OS Script provides a way to interact with the CREO application programmatically, enabling automation of complex tasks.
CREO Mapkey OS Script Example:
Here's an example of using CREO Mapkey OS Script to automate a task:
Example: Create a new part in CREO using a Mapkey OS Script
Step 1: Create a new Mapkey
Step 2: Record the OS Script
Step 3: Edit the OS Script
Dim creoApp As Object
Set creoApp = CreateObject(" Creo Parametric.Application")
' Create a new part
creoApp.Documents.Add "Part"
' Set the part name
creoApp.ActiveDoc.Name = "ExamplePart"
Step 4: Save and Run the Mapkey
When you run the Mapkey, it will create a new part in CREO with the name "ExamplePart".
Tips and Variations:
By using CREO Mapkey OS Script, you can automate repetitive tasks, streamline your workflow, and increase productivity.
Creo mapkey OS script is a powerful automation tool that allows you to execute external operating system commands (like
files) directly from within the Creo Parametric environment. By using the
prefix in a mapkey definition, you can automate tasks that go beyond CAD modeling, such as file management, launching external apps, or running custom scripts. PTC Community Core Example: Executing a Batch File To run an OS script, the mapkey must use the command followed by the path to your executable or script. PTC Community Mapkey Syntax (in config.pro mapkey os_run @SYSTEM C:\scripts\my_script.bat; Detailed Feature Review Description Automation Scope
Allows Creo to interact with the Windows environment, enabling tasks like copying config files or opening specific project folders in File Explorer. Ease of Execution
Once defined, the script can be triggered via a custom keyboard shortcut, eliminating the need to minimize Creo or use the background terminal. Scripting Flexibility Supports various script types, including VBScript (.vbs) Batch files (.bat) , and other executables. Integration
Can be placed at the end of a regular CAD mapkey to "clean up" or "finalize" a task, such as archiving a newly exported PDF. Implementation Tips & Best Practices Path Formatting : Use double backslashes ( ) in the path if editing the config.pro file manually to ensure the system reads them correctly. Legibility : If your OS command has multiple lines, use a backslash (
) at the end of each line except the last to keep the code organized. External Apps : You can use the command to launch websites or programs. For example: @SYSTEM start http://ptc.com; Advanced Use Cases AutoIt scripts
to read the Creo window title or trail files, allowing the mapkey to perform context-aware actions like opening the exact folder where a part is stored.
: If the "OS Script" tab is greyed out in the Mapkey dialog, you may need to manually add the line to your config.pro using a text editor. PTC Community batch script example
for a task like automatically moving exported DXF files to a project folder? Mapkey Writing/Editing Tips - PTC Community
To execute Operating System (OS) scripts within a Creo mapkey, use the @SYSTEM prefix or the OS Script tab in the Mapkeys dialog. Example: Running a Batch File
If you want to run a Windows batch script (e.g., C:\scripts\cleanup.bat) via a mapkey shortcut like cc, the configuration line in your config.pro would look like this:
mapkey cc @MAPKEY_LABEL Run Cleanup Script; @SYSTEM C:\scripts\cleanup.bat; Use code with caution. Copied to clipboard Scripting via the User Interface
Open the Mapkeys dialog via File > Options > Mapkey Settings (or search "mapkey" in the search bar).
Click New and define your keyboard shortcut (e.g., myscript). Go to the OS Script tab. Enter your command, such as: Open a folder: explorer . (opens current working directory) Run a Python script: python C:\path\to\script.py Open Windows Calculator: calc.exe creo mapkey os script example
Click Save to ensure the mapkey persists in your Mapkeys.pro or config.pro file. Key Formatting Rules Creo Parametric - Mapkeys [Configuration]
In Creo Parametric, you can use the @SYSTEM keyword within a mapkey to execute external Operating System (OS) commands, batch files, or scripts. This allows you to perform tasks like launching external applications, copying files, or running complex batch processes without leaving the Creo session. Full Mapkey Syntax Example
Below is an example of a mapkey that runs a Windows batch file to back up a file from the current directory. You can add this directly to your config.pro (or mapkeys.pro in Creo 11) using a text editor.
mapkey bkp @MAPKEY_NAMEBackup Script;@MAPKEY_LABELRun Backup Batch File;\ @SYSTEMstart /min C:\\scripts\\backup_model.bat; Use code with caution. Copied to clipboard Components of the OS Script Mapkey To Define a Mapkey - PTC Support Portal
Creo Mapkey OS Script Example: Automating Repetitive Tasks
Creo, a powerful 3D modeling and design software, offers a feature called Mapkey that allows users to create custom keyboard shortcuts and automate repetitive tasks. In this write-up, we'll explore how to create a Mapkey OS script example to streamline your workflow.
What is Mapkey?
Mapkey is a powerful feature in Creo that enables users to create custom keyboard shortcuts, automate tasks, and integrate external applications. It allows users to record and playback a sequence of actions, making it an ideal tool for automating repetitive tasks.
What is an OS Script?
An OS script, short for Operating System script, is a set of instructions that interact with the operating system to perform specific tasks. In the context of Creo Mapkey, an OS script is used to execute a series of commands that interact with the operating system, such as creating directories, copying files, or launching applications.
Creating a Mapkey OS Script Example
Let's create a simple Mapkey OS script example that automates the following tasks:
Step 1: Open Mapkey
To create a new Mapkey, open Creo and navigate to Tools > Mapkey. This will launch the Mapkey dialog box.
Step 2: Create a New Mapkey
In the Mapkey dialog box, click on New to create a new Mapkey. Give your Mapkey a name, such as "Create_Project_Dir".
Step 3: Record the OS Script
In the Mapkey dialog box, select OS Script as the action type. Click on Record to start recording the OS script.
Step 4: Record the Script
Perform the following actions:
notepad project_notes.txt in the Run dialog box ( Windows key + R).date /t and time /t in the Notepad file.Step 5: Stop Recording
Once you've completed the actions, click on Stop to stop recording the OS script.
Step 6: Save the Mapkey
Save the Mapkey by clicking on Save. You can now assign a keyboard shortcut to this Mapkey by clicking on Assign. In PTC Creo, Mapkeys are powerful keyboard shortcuts
Example Code
The resulting OS script code may look like this:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
' Create new directory on desktop
Dim desktopPath
desktopPath = Environ$("USERPROFILE") & "\Desktop\Creo_Project"
fso.CreateFolder desktopPath
' Launch Notepad and create new file
Dim notepadPath
notepadPath = "notepad.exe project_notes.txt"
CreateObject("WScript.Shell").Run notepadPath, 1, True
' Copy current date and time into Notepad file
Dim dateTime
dateTime = Now()
Dim fsoFile
Set fsoFile = fso.OpenTextFile(desktopPath & "\project_notes.txt", 8, True)
fsoFile.WriteLine dateTime
fsoFile.Close
Conclusion
In this example, we've created a simple Mapkey OS script that automates repetitive tasks, such as creating a new directory and launching Notepad. By using Mapkey, you can streamline your workflow and increase productivity. You can modify this script to suit your specific needs and automate more complex tasks. Happy scripting!
| Feature | Why it matters |
|--------|----------------|
| Mapkey that calls system("start /min C:\scripts\archive.bat") | Runs script without blocking Creo fully |
| Script that waits for file locks to clear | Prevents “file in use” errors |
| Error handling (e.g., exit codes) | Lets mapkey know if script succeeded |
| Comments explaining each step | Critical because mapkey syntax is cryptic |
The Problem: You have a drawing (.drw). You want to export a PDF, move it to a specific \Release folder, and append today’s date—all with one click.
Step 1: The Batch Script (export_pdf.bat)
Save this to C:\Creo_Scripts\export_pdf.bat:
@echo off set source_file=%1 set source_path=%~dp1 set source_name=%~n1 set target_folder=%source_path%Release:: Check if Release folder exists, if not, create it if not exist "%target_folder%" mkdir "%target_folder%"
:: Get today's date (Format: YYYY-MM-DD) for /f "tokens=1-3 delims=/ " %%a in ('date /t') do set curdate=%%c-%%a-%%b
:: Copy the PDF (assuming Creo saved it as PDF in source folder) copy "%source_path%%source_name%.pdf" "%target_folder%%source_name%_%curdate%.pdf"
echo PDF Exported to %target_folder% >> C:\Creo_Logs\export_log.txt
Step 2: The Mapkey Definition
Record a Mapkey named PDFR (PDF Release):
File > Save As > Export (Choose PDF).OS_Script C:\Creo_Scripts\export_pdf.bat !
(The trailing ! passes the current model's full path to the batch file)Result: Press PDFR. Creo exports the PDF, then calls the batch file to move + rename it.
bom_file = sys.argv[1] if not os.path.exists(bom_file): sys.exit(1)
If you deploy these scripts to a team of 50 engineers, follow these rules:
Centralize Scripts: Store all .bat, .ps1, and .vbs files on a network read-only drive (e.g., Z:\Creo_Admin\Scripts\). Map every user’s Mapkey to this location. This allows you to update scripts without touching 50 individual PCs.
Log Everything: Your OS scripts should write to %TEMP%\creo_script_log.txt. When a user says "the Mapkey doesn't work", you need proof.
Sanitize Inputs: Never trust the ! variable. In your batch script, add:
set input=%~1
if not exist "%input%" (
echo ERROR: File not found: %input% >> log.txt
exit /b 1
)
Use Exit Codes: Your script should exit 0 (success) or exit 1 (failure). While Creo cannot read these natively in a standard Mapkey, you can chain them for advanced UI.
| Function | Mapkey Code |
| :--- | :--- |
| Open Notepad | mapkey $F1 @SYSTEM notepad; |
| Open Calculator | mapkey $F2 @SYSTEM calc; |
| Open Current Folder | mapkey $F3 @SYSTEM start .; |
| Run Custom Script | mapkey $F4 @SYSTEM "C:\Scripts\my_script.bat"; |
| Ping Server (Network Check) | mapkey $F5 @SYSTEM ping google.com; |
A Mapkey records your keystrokes, menu picks, and mouse clicks within the Creo interface. When you press a shortcut (e.g., F2 or Ctrl+D), Creo replays those commands instantly.
Why add an OS Script? Native Mapkeys cannot:
By calling an OS script, a Mapkey bridges the gap between Creo’s internal API and your Windows/Linux file system. Open CREO and go to Tools > Mapkey