A simple utility script to automatically generate G-Code files from an NX Manufacturing part. I frequently had to manually export separate G-Code files for multiple CNC machines for every operation of a machined part as well as to take 2~3 screenshots of the part configuration for every setup. In order to avoid this clickfest, remain focused, and improve workflow flexibility when working on multiple CAM parts I wrote this simple script in Visual Basic with a GUI created with Block UI Styler.
- Select operations for export in Operations section.
- Select the machines for which the operations will be exported.
- Specify the output folder.
By pressing OK/Apply a folder structure corresponding to the one in Program Order of the part is generated in the output path. Inside every configuration folder are also exported 3 screenshots (Iso, XY, XZ) showing the coordinate frame and the operations are grouped by machine. An example is shown in the following screenshot.
If for the example shown all operations are selected to be exported using the Mazak and Doosan postprocessors the resulting file structure is shown below:
C:\Users\george\Desktop\MODEL1_SETUP_1\
├── MODEL1_SETUP_1_ISO.PNG
├── MODEL1_SETUP_1_XY.PNG
├── MODEL1_SETUP_1_XZ.PNG
├── MAZAK\
│ ├── PHASE_1\
│ │ ├── 01_FACE_MILLING.eia
│ │ ├── 02_REST_MILLING.eia
│ │ ├── 03_ZLEVEL_PROFILE.eia
│ │ ├── 04_HOLE_D8.eia
│ │ └── 05_CHAMFER.eia
│ └── PHASE_2\
│ ├── 01_SPOT_DRILLING.eia
│ ├── 02_DRILLING_D4.5.eia
│ └── 03_CHAMFER.eia
└── DOOSAN\
├── PHASE_1\
│ ├── 01_FACE_MILLING.mpf
│ ├── 02_REST_MILLING.mpf
│ ├── 03_ZLEVEL_PROFILE.mpf
│ ├── 04_HOLE_D8.mpf
│ └── 05_CHAMFER.mpf
└── PHASE_2\
├── 01_SPOT_DRILLING.mpf
├── 02_DRILLING_D4.5.mpf
└── 03_CHAMFER.mpf
- Auto generation of all separate G-Code files for multiple machines (postporcessors).
- Auto generation of screenshots for each setup (MCS) in Geometry View.
- Auto generation of file structure according to Program Order.
- Smart detection of grouped operations: Folders containing only operations and having only operations as siblings are exported as grouped operations (can be verified in the Operations section before postprocesing). Useful for exporting grouped pattern instances of operations.
- Automatic renaming of the '1234' parent folder in Program Order according to file name.
- The aforementioned behaviour (postprocessors, screenshots) is fully configurable by inserting entries at specified places in the scirpt.
- Clone and extract this repository in a desired location (you can delete the
screenshots
folder). - Keep the
AutoPostprocess.dlx
file in theDLX\
directory, relative to theAutoPostprocess.vb
file.
Or modify, if needed, inAutoPostprocess.vb
thetheDlxFileName
(andJournalFolder
) class variable inside theOutputParameters
class constructor. - Modify, if needed, the default output path by editing
AutoPostprocess.dlx
in Block UI Styler. - Modify, if needed, the list of available machines by editing
AutoPostprocess.dlx
in Block UI Styler. Then, inAutoPostprocess.vb
insert the info for theese machines by adding anextension
andPostProcessor
entry in eachmachine
dict inside theUtils
class constructor. - Execute the script in an open NX Manufacturing part (this is necessary) by doing either of the following:
- Run it as a journal:
- Developer tab (if hidden right click the tab bar and tick Developer)
- Play
- Browse...
- Navigate and select
AutoPostprocess.vb
- Run
- Create a UI button:
- Right click on an empty area in a tab (eg. Home)
- Customize...
- Naviagate to: Commands tab/Categories section/My Items/My UserCommands
- Drag a User Command from inside the Items section on the right to an empty space in a tab. (don't press Close yet)
- Right click the new button
- Edit Action
- Browse...
- Navigate and select
AutoPostprocess.vb
- OK
- Close
- Run it as a journal: