Creo Mapkey Os Script: Example !exclusive!
A complete guide to Creo Mapkeys using OS Scripts (System Commands). This guide covers the "Why," the syntax, practical examples, security considerations, and troubleshooting.
Part 2: The Bridge – OS Scripting Integration
An OS script is an external executable (.bat, .ps1, .vbs, .exe, or .py) that runs on your operating system. Creo can launch these scripts using the PROTECT or SYSTEM functions.
Why combine them?
- Conditional logic: Your script checks if a drawing exists before opening.
- File manipulation: Rename, move, or zip exported PDFs automatically.
- External communication: Send an email or update an ERP system after a Mapkey runs.
Part 4: Complete Example – Automated STEP Export + Folder Organizing
Let’s build a real-world example. You have an assembly, MAIN_ASSEMBLY.ASM. You want a single keystroke that:
- Exports a STEP file.
- Checks today’s date.
- Moves the STEP file to a dated subfolder.
- Logs the action to a CSV file.
Further learning
- Use the Mapkeys dialog to inspect recorded OS text.
- Consult Creo Help for OS command reference specific to your Creo release.
- Build mapkeys incrementally and test frequently.
If you want, I can:
- Provide a mapkey tailored to your Creo version (e.g., Creo 7, 8, 9) — tell me the version.
- Convert the example into an importable mapkey.cnf snippet for direct use.
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
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, 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
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:
- Creates a new directory called "Creo_Project" on the desktop.
- Launches Notepad and creates a new file called "project_notes.txt".
- Copies the current date and time into the Notepad file.
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:
- Create a new directory called "Creo_Project" on the desktop by right-clicking on the desktop and selecting New > Folder.
- Launch Notepad and create a new file called "project_notes.txt" by typing
notepad project_notes.txtin the Run dialog box ( Windows key + R). - Copy the current date and time into the Notepad file by typing
date /tandtime /tin 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.
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!
In PTC Creo, mapkeys are powerful enough to trigger external operations through OS Scripts, allowing you to automate tasks like moving files, launching external analysis tools, or opening specific network folders without leaving the CAD environment. The Core Syntax
To run an operating system command or a script file (like .bat, .vbs, or .exe), you use the @SYSTEM prefix within your mapkey definition.
Basic Syntax:mapkey shortcut @SYSTEM command_or_path_to_script; Example 1: Launching a Batch File
This example shows how to trigger a local batch file that might perform cleanup or file organization. Mapkey Definition:
mapkey run_clean @SYSTEM C:\\scripts\\cleanup_working_dir.bat; Use code with caution. Copied to clipboard creo mapkey os script example
Action: When you type run_clean, Creo executes the batch file located at the specified path.
Pro Tip: Use double backslashes (\\) in the file path to ensure Creo correctly parses the directory separators. Example 2: Opening a Project Folder on a Server
Many engineers use mapkeys to quickly jump to the project's "Final Docs" or "Output" folder on a company server. Mapkey Definition:
mapkey .docs @SYSTEM start "" "\\\\your_server\\Projects\\Current_Job\\Docs"; Use code with caution. Copied to clipboard
Action: Uses the Windows start command to open a specific network directory in File Explorer.
Why use it: It saves you from manual navigation through deep folder structures every time you need to check a drawing or spec. Example 3: Nested Automation (The "Frankenstein" Example)
For advanced users, you can combine standard Creo actions with OS scripts in a "nested" mapkey to create a seamless workflow. Logic Flow: Step 1: Export model info from Creo.
Step 2: Run an OS script to process that data (e.g., an AutoHotkey script or Python executable).
Step 3: Re-import the results or perform a final Creo action. Example structure in config.pro:
mapkey automation %>export_info; \ mapkey(continued) @SYSTEM start /wait C:\\scripts\\process_data.exe; \ mapkey(continued) %run_import; Use code with caution. Copied to clipboard How to Implement OS Scripts
Open Mapkeys Settings: Go to File > Options > Mapkeys Settings.
Create New: Click New and define your shortcut name (e.g., os).
Use the OS Script Tab: Instead of recording keyboard clicks, click the OS Script tab in the Record Mapkey dialog.
Enter Command: Type your command directly into the text area.
Save: Click Save Changed to store it in your config.pro (or mapkeys.pro in Creo 11). Important Tips for OS Scripts
Execution Order: Ensure your OS command ends with a semicolon (;) so Creo knows where the script ends and the next mapkey action begins.
Background Running: Using the start command in Windows allows the script to run in a separate window, often preventing Creo from "freezing" while the script executes.
Case Sensitivity: Remember that while Windows paths aren't case-sensitive, mapkey shortcuts themselves are. If you'd like, I can help you:
Write a specific batch file to go with one of these mapkeys.
Find the exact file path for your config.pro or mapkeys.pro based on your Creo version. Troubleshoot why a path with spaces might be failing. Solved: Script - PTC Community
Master PTC Creo Mapkeys with OS Scripts: A Complete Guide Automating repetitive tasks in PTC Creo often requires going beyond simple button-click recordings. To truly streamline your workflow—like automatically renaming files, moving data to specific folders, or triggering external Python scripts—you need to leverage the power of OS Scripts within Mapkeys.
This guide provides clear examples and best practices for integrating Operating System commands directly into your Creo environment. What is a Creo OS Script Mapkey?
A standard mapkey records internal Creo commands. An OS Script mapkey uses the @SYSTEM syntax to "break out" of Creo and execute commands in the Windows Command Prompt (CMD) or shell environment. The Basic Syntax
In your config.pro file, an OS-based mapkey looks like this: mapkey example @SYSTEMstart notepad.exe; Use code with caution. mapkey: Initiates the definition. example: The shortcut keys you press.
@SYSTEM: Tells Creo to send the following text to the Operating System. ;: Ends the mapkey sequence. Example 1: Open the Current Working Directory
One of the most useful scripts is a "one-touch" button to open the folder where your current files are saved. The Mapkey: mapkey .fod @SYSTEMexplorer . ; Use code with caution.
How it works: explorer . tells Windows to open File Explorer at the current relative path (the dot represents "here").
Why use it: Saves you from navigating through deep server directory trees manually. Example 2: Run a Python Script for Batch Renaming
If you have a Python script that processes exported CSVs or renames STEP files, you can trigger it without leaving the Creo interface. The Mapkey: mapkey .py @SYSTEMpython C:\scripts\process_data.py; Use code with caution.
Pro Tip: Ensure python is in your Windows Environment Path so Creo can find the executable. Example 3: Create a "Purge" Shortcut
Creo creates version numbers for every save (e.g., part.prt.1, part.prt.2). While Creo has a purge command, many users prefer the classic OS-level batch purge. The Mapkey: mapkey .pur @SYSTEMpurge; Use code with caution.
(Note: This requires the PTC purge.exe utility to be in your system path, which is standard in most installations.) Example 4: Advanced Scripting with Arguments
You can chain commands or call complex batch files (.bat or .cmd). This is useful for pushing files to a backup server. The Mapkey: mapkey .bak @SYSTEMC:\scripts\backup_tool.bat; Use code with caution. The backup_tool.bat Content:
@echo off mkdir "C:\Backup\%DATE%" copy *.prt* "C:\Backup\%DATE%\" echo Backup Complete! pause Use code with caution. Critical Tips for Success
Use the Mapkey Editor: While you can type these into config.pro, it is safer to use the Mapkey Dialog in Creo. When recording, choose "OS Script" from the "OS Command" tab.
Avoid Blocking: If you run a script that stays open (like a persistent CMD window), Creo may "freeze" until that window is closed. Use the start command (e.g., @SYSTEMstart cmd) to run the process in the background.
Pathing Issues: If your file paths contain spaces, you must use double quotes. However, because config.pro also uses quotes, you often need to escape them or use a batch file as a middleman.
The "Pause" Command: If your script runs and disappears too fast to see errors, add pause to the end of your .bat file so the window stays open for troubleshooting. Conclusion
Integrating OS scripts into your Creo mapkeys transforms the software from a CAD tool into a fully integrated engineering workstation. Start with a simple folder shortcut and gradually move toward complex automation with Python or Batch scripts.
In the world of , Mapkeys are the ultimate productivity hack, allowing you to record a series of mouse clicks and keyboard commands into a single shortcut. However, the real magic happens when you use the @SYSTEM command to trigger OS Scripts (batch files or shell scripts) directly from within your CAD environment.
Below is a draft blog post designed to help your readers bridge the gap between Creo commands and operating system automation. Supercharging Creo: How to Use Mapkeys with OS Scripts
If you’ve been using PTC Creo for a while, you probably have a library of Mapkeys for common tasks like changing view orientations or toggling datums. But what happens when you need to do something outside of Creo—like moving a file, launching a specific spreadsheet, or triggering a custom Python script?
That’s where OS Scripting in Mapkeys comes in. By using the @SYSTEM command, you can turn Creo into a control center for your entire engineering workflow. What is a Creo OS Script Mapkey?
Standard Mapkeys record internal Creo commands. An OS Script Mapkey, however, sends a command directly to your Windows Command Prompt (CMD) or Linux Shell. This allows you to automate file management, sync with PDM systems, or open third-party analysis tools without leaving your workspace. Step-by-Step: Creating an OS Script Mapkey
You can manually edit your config.pro file to add these powerful shortcuts. Here is the syntax for a basic example that opens a specific project folder in Windows Explorer. The Script Example Add this line to your config.pro:
mapkey .expl @MAPKEY_LABELOpen Project Folder;\ mapkey(continued) @SYSTEMstart explorer.exe "C:\Projects\Current_Job"; Use code with caution. Copied to clipboard Breakdown of the Code:
mapkey .expl: This defines the shortcut (typing .expl in Creo triggers the action).
@MAPKEY_LABEL: Provides a name for the command in the Mapkey dialog.
@SYSTEM: This is the critical "bridge" command. It tells Creo: "Stop looking at CAD commands and send the following text to the Operating System."
start explorer.exe...: This is the standard Windows command to open a folder. Practical Use Cases A complete guide to Creo Mapkeys using OS
Why bother with this? Here are three ways professional power users use OS Scripts:
Automated Backups: Create a Mapkey that saves your work and then runs a .bat file to copy the latest version to a secure "Archive" folder.
External Calculators: Map a key to launch an Excel-based tolerance stack-up tool or a custom Python script that processes exported CSV data.
Cleanup Tools: Run a script that deletes all old version files (*.1, *.2, etc.) in your working directory to keep your workspace tidy. Pro-Tip: The "Silent" Run
If you don't want a Command Prompt window popping up every time you run your Mapkey, you can call a VBScript or a "hidden" batch file to keep the UI clean.
Mapkeys aren't just for CAD commands anymore. By leveraging the @SYSTEM call, you can automate the "boring stuff" that happens between your design sessions.
Want to dive deeper? Check out the PTC Support Portal for the latest documentation on Mapkey syntax and configuration.
In Creo Parametric, a mapkey OS script allows you to execute external operating system commands or scripts directly from the Creo environment without minimizing the software window. This feature is commonly used to automate file management, launch external applications, or perform complex data processing that Creo's native macro language cannot handle alone. PTC Community Defining an OS Script Mapkey
To create a mapkey that runs an OS script, follow these steps in the Creo Mapkeys Settings Navigate to File > Options > Mapkeys Settings to open the Record Mapkey dialog. Key Sequence ) and a name/description. Switch to the OS Script tab within the dialog box.
Enter the OS command or the path to your external script in the text area provided. PTC Community Script Examples and Syntax Mapkeys use the
prefix in their configuration code to identify an OS-level command. PTC Community Calling a VBScript or Batch File:
You can point directly to an executable file on your network or local drive.
mapkey(continued) @SYSTEMZ:\\folder\\subfolder\\script.VBS;\ Copied to clipboard PTC Community Discussion File Management (Batch Example):
You can use standard Windows CMD commands to clean up directories or move files.
mapkey(continued) @SYSTEMdel old_config.pro\n\ mapkey(continued) @SYSTEMdir /b *.prt > current_parts.txt\n\ Copied to clipboard PTC Community Writing Tips Launching External Applications:
A common use case is opening a specific customer folder based on the current working directory.
@echo off set cdn=%cd% if exist "\\server\docs\%cdn%" ( start "" "\\server\docs\%cdn%" ) Use code with caution. Copied to clipboard PTC Customization Forum Key Use Cases Config Synchronization:
Automatically copying a standard company configuration file from a central server to your local working directory before loading it into your session. Data Exporting:
Running a script that zips or moves exported PDFs/STEP files to a specific release folder. Workflow Integration:
Triggering third-party PLM or analysis tools that require command-line arguments derived from the active Creo model. PTC Community Configuration Storage Starting with , mapkeys are primarily stored in a dedicated mapkeys.pro file located in the user's
roaming folder, though they can still be manually managed in the config.pro for legacy support. PowerShell
script example that integrates with this mapkey system for advanced file processing? Creo Parametric 11.0 - Mapkeys Configuration File
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
- Open CREO and go to Tools > Mapkey.
- Click New to create a new Mapkey.
- Give the Mapkey a name, e.g., "CreateNewPart".
Step 2: Record the OS Script
- In the Mapkey dialog box, click Record.
- Perform the actions to create a new part in CREO (e.g., File > New > Part).
- Click Stop to stop recording.
Step 3: Edit the OS Script
- In the Mapkey dialog box, click Edit.
- In the Script Editor, select OS Script as the script type.
- In the script editor, add the following code:
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
- Save the Mapkey.
- To run the Mapkey, press the assigned keyboard shortcut (e.g., Ctrl+Shift+C).
When you run the Mapkey, it will create a new part in CREO with the name "ExamplePart".
Tips and Variations:
- You can customize the script to perform more complex tasks, such as creating a new assembly or drawing.
- You can also use other programming languages, such as JavaScript or Python, to write the OS Script.
- To debug the script, you can use the Script Editor's built-in debugger.
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
In Creo Parametric, a is a keyboard macro used to automate repetitive tasks. While most mapkeys record internal Creo commands, you can use the call to execute external OS scripts (like Batch or Python) directly from the Creo interface. Mapkey OS Script Syntax
To run an external script, the mapkey must be defined in your config.pro file using the following structure: mapkey [key_sequence] @SYSTEM[path_to_script/command]; Open a specific folder in Windows Explorer: mapkey .ef @SYSTEMstart explorer C:\Working_Directory; will open the defined directory in a new window) Run a Python script for file cleanup: mapkey .py @SYSTEMpython C:\scripts\cleanup.py;
(This triggers an external Python interpreter to run a custom script) Clear the Creo message log: mapkey .cl @SYSTEMdel /q /f *.log; Part 2: The Bridge – OS Scripting Integration
(Uses a standard command-line prompt to delete log files in the current working directory) How to Implement Open Options File > Options > Environment > Mapkey Settings Create New , enter your shortcut name (e.g., ), and provide a description. Manual Edit
: Since the "Record" tool primarily captures GUI clicks, it is often easier to open your config.pro in a text editor and manually paste the : Ensure the mapkey is saved to your active config.pro so it loads every time you start Creo. Key Considerations Permissions
: Ensure the script has the necessary OS-level permissions to execute.
command runs, a command prompt window may briefly appear. Use start /min if you want to keep the window minimized.
: If your script path contains spaces, wrap it in double quotes (e.g., "C:\My Scripts\test.bat" Python or Batch script to pair with this mapkey for a particular task? About Mapkeys - Creo Parametric - PTC Support Portal
In Creo Parametric, you can run an file) from a mapkey by using the
command prefix within the mapkey definition. This allows Creo to execute external Windows shell commands directly from your macro. PTC Community Mapkey OS Script Syntax
A typical mapkey that triggers an external script follows this format in your config.pro
mapkey script_test @MAPKEY_NAMEExecute My Script;@MAPKEY_LABELLabel;\ mapkey(continued) @system"C:\scripts\my_batch_file.bat"; Use code with caution. Copied to clipboard Key Implementation Steps
: This is the trigger that tells Creo to pass the following string to the Operating System's command processor. Quotes and Paths
: Surround your script path with double quotes if it contains spaces. You can also use system variables (e.g., or custom ones like ) if they are defined in your environment. Batch File Behavior
: When the mapkey runs, a temporary OS window may open. To prevent the window from closing immediately so you can see results, include a at the end of your Wait for Finish
: By default, Creo waits for the system command to finish before proceeding to the next mapkey line. PTC Community Example: Open Working Directory in Explorer
This common mapkey example opens the current Creo working directory in Windows Explorer:
mapkey owd @MAPKEY_NAMEOpen Working Dir;@MAPKEY_LABELOpen Dir;\ mapkey(continued) @system"start ."; Use code with caution. Copied to clipboard Pro Tips for OS Mapkeys Batch File Location
: Place your scripts in a central, permanent directory (like C:\PTC_Scripts\
) rather than a temporary working folder to ensure the mapkey works in every session. Hidden Execution
: If you want to run a command without the black command prompt window flashing, you may need to call a "launcher" script or use VBScript to run the batch file in hidden mode. Combining Commands
: You can chain Creo commands and OS scripts. For example, a mapkey can export a PDF and then immediately run a script to move or rename that PDF. PTC Community that processes your exported files?
How to call a external applications using OS script (mapkey)?
Introduction
Creo, formerly known as Pro/ENGINEER, is a powerful 3D modeling software used by engineers and designers to create complex designs. Mapkeys are a feature in Creo that allows users to automate repetitive tasks by creating custom keyboard shortcuts. In this article, we will explore how to create a Mapkey OS script example in Creo.
What is a Mapkey?
A Mapkey is a keyboard shortcut that can be used to automate a series of tasks in Creo. It allows users to record a sequence of actions and assign them to a single key or a combination of keys. Mapkeys can be used to perform tasks such as creating a new part, assembling components, or generating drawings.
What is an OS Script?
An OS script, also known as an Operating System script, is a type of script that interacts with the operating system to perform tasks. In the context of Creo, an OS script is used to execute a series of commands outside of Creo, such as creating a new folder, copying files, or running a batch program.
Creo Mapkey OS Script Example
Here is an example of a Mapkey OS script that creates a new folder and launches a text editor:
Step 1: Create a new Mapkey
- Open Creo and go to Tools > Mapkeys.
- Click on New to create a new Mapkey.
- In the Mapkey dialog box, select OS Script as the Type.
- Give the Mapkey a name, such as "CreateNewFolder".
Step 2: Write the OS Script
- In the OS Script dialog box, select the Operating System as Windows (or the OS you are using).
- Write the following script:
@echo off
mkdir C:\NewFolder
notepad C:\NewFolder\example.txt
This script creates a new folder called "NewFolder" on the C: drive and launches Notepad with a new file called "example.txt".
Step 3: Configure the Mapkey
- In the Mapkey dialog box, assign a keyboard shortcut to the Mapkey, such as Ctrl+Shift+N.
- Click OK to save the Mapkey.
Step 4: Test the Mapkey
- Press the assigned keyboard shortcut (Ctrl+Shift+N).
- The OS script will execute, creating a new folder and launching Notepad.
Conclusion
In this article, we have seen how to create a Creo Mapkey OS script example that interacts with the operating system to perform tasks. By using Mapkeys and OS scripts, users can automate repetitive tasks and increase their productivity in Creo. This is just one example of the many possibilities of using Mapkeys and OS scripts in Creo.
Additional Resources
- PTC Creo Mapkey documentation: [link to PTC website]
- Creo Mapkey tutorial: [link to tutorial]
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"
OS Script mapkey in PTC Creo Parametric allows you to execute external operating system commands (like batch files, Python scripts, or PowerShell) directly from within the Creo environment. Example Syntax You can define an OS Script mapkey manually in your config.pro (or the newer mapkeys.profile in Creo 11) using the PTC Community Code Example:
mapkey run_py @MAPKEY_NAMEExecute Python Script;@MAPKEY_LABELPyScript;\ mapkey(continued) @SYSTEMpython "C:\scripts\my_creo_automation.py"; Use code with caution. Copied to clipboard How to Create via the UI Instead of manual coding, you can use the OS Script tab in the Mapkeys dialog: Mapkeys Settings and enter your desired shortcut (e.g., Navigate to the tab in the Record Mapkey dialog. Type the command you want the OS to run (e.g., C:\temp\cleanup.bat , then immediately click
Save your changes to your configuration file to keep the mapkey for future sessions. Why use OS Scripts? Automation:
Launch batch files that clean up temporary files in your working directory. External Integration:
Open a project tracker or specific network folder related to the active model. Background Tasks:
Run complex data exports or manipulations using Python or VB API without leaving the Creo window. PTC Community Solved: Script - PTC Community