Skip to content

Manage Program Names And Comments

KaiUR edited this page Jul 21, 2026 · 12 revisions

Manage Program Names And Comments

File: Process_Document_Scripts/Manage_Program_Names_And_Comments.py
Version: 1.1
Document Type: CATProcess


Description

An editor for the names and comments of a machining process. The part operations, manufacturing programs and operations of the active CATProcess are listed in one grid, each with its name, comment, tool and machining settings, so a whole job can be read and put right in one place. The settings columns are the ones Export Process Table Parameters writes to Excel — stepover, tolerance, depth of cut and offsets — alongside a warning where an operation is missing one its own type normally carries.

Names and comments are picked from template lists rather than typed: die parts and machines for a part operation, headings for a divider, machining descriptions for a program or an operation. Program names are assembled from the job — programmer, project, die, revision and die part — and renumbered part operation by part operation. Program comments are composed from the tool, the description and the two offsets, so a comment always says what the tool is, what it is doing and what it is cutting to.

Edits are staged in place — the Name, Comment and PP instruction columns show what each row is heading for, coloured green while it waits — and the document is untouched until Apply is pressed.


Requirements

Requirement Value
Python >= 3.10
pycatia >= 0.10.0
wxPython Required
xlsxwriter Not required
Open document CATProcess

Usage

  1. Open the CATProcess in CATIA
  2. Run the script — a progress bar shows each program as the tree is read
  3. Check the Job bar — initial, project, die and revision, read from the CATPart name
  4. Check Metal thicknesses — metal, master, die part code and spotting, per part operation
  5. Double-click a row, or select it and press Edit selected row
  6. Pick a name and comment, or compose one, then Stage
  7. Apply staged edits to CATIA writes them straight away; save the document in CATIA to keep them
Button Does
Edit selected row Opens the name and comment dialog for that activity
Metal thicknesses Metal, master, code and spotting for each part operation
Renumber programs Numbers the programs part operation by part operation
Refresh from CATIA Reads the whole tree again, behind the progress bar
Clear staged edit Drops the staged values on the selected row, so it shows the document again
Apply staged edits to CATIA Writes every staged value, without asking to confirm
Edit templates Adds, edits, reorders and removes the dropdown entries
Clear saved settings Deletes the saved files and restores the shipped templates
Help The whole of this page, inside the script

Metal thicknesses

Every thickness found in the design parts is listed with the master it was named with and the body name it came from — the same body carries both, as MASTER PANEL LH CP02 REV11 - UPPER IS MASTER - METAL IS 1.5mm. Rows can be added by hand where a part states nothing, and only rows added by hand can be edited or deleted.

Below, each part operation says which row applies to it, along with its die part code and spotting:

Part operation Code Metal mm Master Spotting mm Spotting Use
UPPER PAD (OKUMA) UP 1.5 UPPER 0.3 built in 1.5mm UPPER
LOWER POST (MECOF) LP 1.5 UPPER 1.5mm UPPER

Picking a row in Use fills the thickness and master together, so they cannot come from different rows. Where the whole process turns up a single thickness, every part operation defaults to it. Two die parts of different thickness each keep their own — there is no one figure for the job.


Spotting

Spotting is material left on for hand work at try out. It is set per part operation, either way:

  • built in — the allowance is added to every offset, so finish cuts to +0.3, and the comment carries SPOTTING +0.3MM BUILT IN on its own line
  • at the machine — the programs are unchanged and the comment tells the operator: LEAVE 0.3MM FOR SPOTTING

Program comments

A program comment is composed rather than typed:

16BN SEMI-FINISH SWEEP TO +0.3MM
16BN FINISH SWEEP TO 0.0MM (M/C: -1.5MM)
Piece Where it comes from
Tool The program's tool change, closed up for a ball nose — T4 16 BN becomes 16BN
Description The description list
TO ...MM The stage: rough +2.0 or +0.7, semi-finish +0.3, finish 0.0, Z check 0.0
(M/C: ...MM) What the operations actually machine to, from Offset on part

The stage figure is what the stage always means and does not move when metal comes off. The machined figure does, and is shown only when the two differ — so a part that is on the master side reads TO 0.0MM with nothing after it.

A part operation comment is built from ticked lines — the job description, UPPER IS MASTER, METAL IS 1.5MM, PROFILES ARE ...MM with its own value box — with the master and metal lines already filled in from the design part.


The offset rule

The master side is cut to nominal; the other side has the metal taken off it. BOTH means no metal comes off either side.

Master Upper parts Lower parts
UPPER nominal nominal - metal
LOWER nominal - metal nominal
BOTH nominal nominal

Worked through, metal 1.5 with UPPER IS MASTER:

Stage Upper part Lower part
Z-level rough +2.0 TO +2.0MM TO +2.0MM (M/C: +0.5MM)
Rough +0.7 TO +0.7MM TO +0.7MM (M/C: -0.8MM)
Semi-finish +0.3 TO +0.3MM TO +0.3MM (M/C: -1.2MM)
Finish 0.0 TO 0.0MM TO 0.0MM (M/C: -1.5MM)

Whether a part is an upper or a lower one comes from the part operation's name — name it UPPER PAD and it is an upper part. A name that says neither, such as ROLLER CAM POS_01, gets no offset, because being wrong here is wrong by the whole metal thickness.

The rule is only a fallback. Where the operations state an Offset on part, that is used instead and the rule is used to check it — a program whose operations disagree with its stage is reported rather than corrected.


Program names

Programs are named as one token:

A   104   D45   03   LP   01
|   |     |     |    |    +-- program number
|   |     |     |    +------- die part code
|   |     |     +------------ revision
|   |     +------------------ die number
|   +------------------------ project number
+---------------------------- programmer initial

The die part code belongs to the part operation, so two part operations in one process name their programs differently — ...UP01 under the pad, ...LP01 under the post.

Renumber programs groups the programs under their part operations, each with its own start and step on its header row, and numbering restarts for every part operation. Type in the Number column to set any one by hand. Dividers take no number and are skipped. Rebuild the whole name from the job settings switches between regenerating the whole token and changing only the trailing number.

A trailing number is read as a program number only where the name is built on the job's stem. A program CATIA named itself — Manufacturing Program.14 — ends in CATIA's own activity counter, so it is ignored and the next free number is offered instead.


PP instructions

A PPInstruction — the activity sitting at the head of a program — cuts nothing, and carries two separate things:

Field Example What it is
Name MECOF_HEAD What the activity is called in the tree
PP instruction head/'TCB6' What the post processor actually reads

Renaming the activity does not change what gets posted. The instruction lives in the activity's PP words syntax parameter, and is set on its own row in the edit window, staged and applied like a name or a comment, and shown in its own PP instruction column in the grid.

Each has its own template list, PP instruction names and PP instructions, and both ship empty — the entries belong to the shop and its machines rather than to the script. Add your own under Edit templates and press Save to keep them; they export and import like any other list. Because they ship empty, Reset this list on either one empties it rather than restoring anything, and says so before it does.


Templates

Every dropdown is fed by a list that Edit templates can change — die parts, machines, job descriptions, part operation comments, masters, dividers, operation descriptions, PP instruction names, PP instructions, tools and die numbers. Entries can be added, edited, reordered, sorted and removed, and whole sets exported to a file and imported again, replacing or merging. A file that does not mention a list leaves that list alone. Unticking Use the entries built into the script keeps only the entries added by hand; the shipped lists are always held, so any list can be put back.


Colour key

Colour Row
Blue Part operation
Pale blue Manufacturing program
Cream Operation
Amber Divider — a program carrying a *** heading ***
Green A staged Name, Comment or PP instruction, shown in place and waiting for Apply — with a darker mark on the Level column so the row is easy to find
Red text A setting this operation type should have but does not

The three tree levels run from blue down to cream, so depth reads as brightness; dividers are amber to stand out from the programs they sit among.


Notes

  • Nothing is written until Apply. Edits are staged over the current values and shown in green; Clear staged edit puts a row back to what the document still holds. Opening a row and pressing Stage without changing anything stages nothing. Apply writes without a further prompt, so the staged values in the grid are the confirmation.
  • Reopening an edited row brings back what was staged, not what is being replaced — the description, the stage and the offsets are all read from the staged comment.
  • Numbering counts staged names. A program staged as ...LP05 has claimed number 5, so the next free number offered is 6 rather than a number already spoken for.
  • Placeholders in a template — **.**MM, ***mm, 0.*mm, POS_## — are asked for when the edit is staged, and the template's own spelling of the unit is kept.
  • CATIA's No Description placeholder is read as no comment at all.
  • Two files live in %APPDATA%\pycatia_scripts\Manage_Program_Names_And_Comments\: settings.json holds the programmer initial and the machine, nothing else; templates.json holds the template lists once they have been edited. Clear saved settings deletes both.
  • Project, die, revision, metal and master belong to the document and are read from it every run, so a part name that fails to parse can never inherit the last job's die number.

Home


Getting Started


Contributing


Any Document Scripts


Drawing Document Scripts


Part Document Scripts


Shape Generation Scripts


Process Document Scripts


Product Document Scripts


Utility Scripts


Legal

Clone this wiki locally