To be sure:
- you want to change tool length by switching D... register number to D2, D3 etc?
- or you are going to modify tool length by overriding $P_TOOLL ?
This way or another, my idea would be to use User Defined Events for this. In some operations, you can add additional UDEs to Transfer/Rapid motions.
If you need it also in other places on tool path, you can use Tool Path Editor to add UDEs wherever you like.
UDE which you want to use might be Cutter Compensation or Insert (it would be my choice if this command can exists as separate line in NC code)
Production: NX 11.0.2
Development: C#, Tcl/Tk, CSE
If it only needs to be changed for specific operations (not WITHIN an operation), "Length adjust" (typically right next to "tool number") can be used to set this.
Set the tool's length adjust to 1 (or whatever you want as the default)
Then in each operation you can over-ride the length adjust to the desired number (2 or 3 or ...)
You might want to add code to your post to make sure the length adjust is not zet to zero or > 7 (or whatever the max is for your machine)
Then output as the D word
The variable in the post is "mom_tool_adjust_register"
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled