Variable issue in post processor

welcome to the forum.

The variable ‘visibility’ (not necessarily scope) in the pp that you observe is correct in that some vars don’t get instantiated until related toolpath events. In the case of operationName, the event is OnNewOperation(). In the case of toolName, OnToolChange(). And you are correct in that often times you must simply debug the pp with breakpoints to observe the stack in order to know when certain variable are available or refreshed. var leadinType is an interesting example, it gets updated depending on the point read along the toolpath; OnPenDown() vs. OnPenUp() will likely have different values for it.

If you are in the debugger, then I suspect you’ve seen the pp doc. btw- the doc is also available direct from your browser since its .html format, see- file:///C:/Program%20Files%20(x86)/SheetCam%20TNG/Languages/en/HTML/Post%20Processor.htm

re. comments and notations- if OnComment() is defined, I believe all the text in the Tool and Operation ‘Notes’ tab is output as comments in the gcode file automatically.

for use of these functions and comments such as you are intending, see this exemplar pp - Post Processor Example w Custom Options popup window