Post Processors: Adding SHEET NAME to output

This forum is for general discussion regarding VCarve Pro
Post Reply
ColonelBlimp
Posts: 4
Joined: Wed Jul 20, 2022 10:21 am
Model of CNC Machine: Router from China

Post Processors: Adding SHEET NAME to output

Post by ColonelBlimp »

Hi All,

I want to add the sheet name to a tap file produced by my custom post-processor. However, I can't seem to find a variable which accomplishes this.

Here is a snippet of what I have:

Code: Select all

"(Copyright Chilukwa Joinery)"
"([TP_FILENAME] - [TOOLPATH_NAME])"
"([TOOLNAME])"
I am wanting to do something like this:

Code: Select all

"(Copyright Chilukwa Joinery)"
"([TP_FILENAME] - [SHEET_NAME]/[TOOLPATH_NAME])"
"([TOOLNAME])"
Currently, I must type in the sheet name as part of the 'toolpath name' - which makes for mistakes.

Any help gratefully appreciated.

User avatar
Adrian
Vectric Archimage
Posts: 14680
Joined: Thu Nov 23, 2006 2:19 pm
Model of CNC Machine: ShopBot PRS Alpha 96x48
Location: Surrey, UK

Re: Post Processors: Adding SHEET NAME to output

Post by Adrian »

There is no variable that I'm aware of. You'll probably need to raise an enhancement request with Vectric and they can tell you if there is an undocumented one.

You could probably do it with LUA code in the post processor as that is aware of sheets (see the SetupSheet gadget code) but that's another level above just putting a variable in.

ColonelBlimp
Posts: 4
Joined: Wed Jul 20, 2022 10:21 am
Model of CNC Machine: Router from China

Re: Post Processors: Adding SHEET NAME to output

Post by ColonelBlimp »

Many thanks for the feedback.

I might raise an enhancement request as I have some other "nice-to-haves" to do with sheets.

Again, many thanks for the quick reply.

wilkigr
Vectric Craftsman
Posts: 261
Joined: Tue Oct 13, 2020 3:14 pm
Model of CNC Machine: Sienci Long Mill

Re: Post Processors: Adding SHEET NAME to output

Post by wilkigr »

You may want to take a look at the grbl mm or grbl inch post processors. These are the ones that I use and the default name for my tool paths does include the sheet name.

For example: Sheet 2_Pocket 2.gcode. In this case, I did not rename the sheet when I created it. I left it as "sheet 2". The pocket was similarly "pocket 2". You can see that the default tool path included the sheet name.

wb9tpg
Vectric Wizard
Posts: 457
Joined: Tue Sep 04, 2018 2:49 pm
Model of CNC Machine: Shapeoko 3 XL

Re: Post Processors: Adding SHEET NAME to output

Post by wb9tpg »

ColonelBlimp wrote:
Fri Jan 27, 2023 10:53 am

Code: Select all

"([TP_FILENAME] - [SHEET_NAME]/[TOOLPATH_NAME])"
I've successfully coded the Sheet Name in LUA and would he happy to share it the code. Do you want the line formatted exactly as you've shown? I'll tweak it as you desire then post the code.
Gary Mitchell
Kentucky, USA

User avatar
Adrian
Vectric Archimage
Posts: 14680
Joined: Thu Nov 23, 2006 2:19 pm
Model of CNC Machine: ShopBot PRS Alpha 96x48
Location: Surrey, UK

Re: Post Processors: Adding SHEET NAME to output

Post by Adrian »

wilkigr wrote:
Fri Jan 27, 2023 1:51 pm
You may want to take a look at the grbl mm or grbl inch post processors. These are the ones that I use and the default name for my tool paths does include the sheet name.

For example: Sheet 2_Pocket 2.gcode. In this case, I did not rename the sheet when I created it. I left it as "sheet 2". The pocket was similarly "pocket 2". You can see that the default tool path included the sheet name.
That doesn't come from the post processor though. That's part of the toolpath calculation (depending on your settings) before the post processor writes the code. The default toolpath naming can be intercepted with LUA code (I do it on my system) but the OP wants the sheet name in the actual code.

wb9tpg
Vectric Wizard
Posts: 457
Joined: Tue Sep 04, 2018 2:49 pm
Model of CNC Machine: Shapeoko 3 XL

Re: Post Processors: Adding SHEET NAME to output

Post by wb9tpg »

Here is what I got. It'll only work if you save your toolpath before you change to the next sheet. That is because it gets the name of your current sheet.

Create a copy of your post processor first

Then copy the script section and insert it into the POST_NAME area like this example

Code: Select all

POST_NAME = "Grbl Sheet (mm) (*.gcode)"
+TAPE_SPLITTING = 55000 5000 "%s_%d.gcode" 1 "YES"
FILE_EXTENSION = "gcode"
UNITS = "MM"
LASER_SUPPORT = "YES"
RAPID_PLUNGE_TO_STARTZ = YES
+DIRECT_OUTPUT = "VTransfer"
SUBSTITUTE = "({)}"

+ Script to build a line like below
+ "([TP_FILENAME] - [SHEET_NAME]/[TOOLPATH_NAME])"
SCRIPT

  require "strict"
  pp = require "ppVariables"
	
	function main(script_path)
    if pp.Init() == false then
      DisplayMessageBox('Failed to initialise ppVariables module!')
			return false
    end       
		return true
  end
  
	function get_sheet()
	  local job = VectricJob()
		local sheet_manager = job.SheetManager
		local sheet_id = sheet_manager.ActiveSheetId
		local sheet_name = sheet_manager:GetSheetName(sheet_id)
		return sheet_name
	end
	
	function lua_header()  
	  -- Format a line like below
		-- "([TP_FILENAME] - [SHEET_NAME]/[TOOLPATH_NAME])"
	  local sheet_name = {}
	  sheet_name = get_sheet()
		
		local tp_filename = {}
		tp_filename = pp.TP_FILENAME
		
		local tp_name = {}
		tp_name = pp.TOOLPATH_NAME
		
		
		pp.PostP:OutputLine('(' .. tp_filename .. ' - ' .. sheet_name .. '/' .. tp_name .. ')\r\n', false)
	end

ENDSCRIPT
Then wherever you want the line displayed in the gcode insert this line. In this example it's the first line on the Header section

Code: Select all

begin HEADER
"<!>lua_header()"
The resulting line of Gcode is
(Test V5TP - Sheet 1/Test V5)
Gary Mitchell
Kentucky, USA

wilkigr
Vectric Craftsman
Posts: 261
Joined: Tue Oct 13, 2020 3:14 pm
Model of CNC Machine: Sienci Long Mill

Re: Post Processors: Adding SHEET NAME to output

Post by wilkigr »

Adrian wrote:
Fri Jan 27, 2023 3:28 pm
wilkigr wrote:
Fri Jan 27, 2023 1:51 pm
You may want to take a look at the grbl mm or grbl inch post processors. These are the ones that I use and the default name for my tool paths does include the sheet name.

For example: Sheet 2_Pocket 2.gcode. In this case, I did not rename the sheet when I created it. I left it as "sheet 2". The pocket was similarly "pocket 2". You can see that the default tool path included the sheet name.
That doesn't come from the post processor though. That's part of the toolpath calculation (depending on your settings) before the post processor writes the code. The default toolpath naming can be intercepted with LUA code (I do it on my system) but the OP wants the sheet name in the actual code.
I learn something new here every day. :D Thanks, Adrian. I haven't set anything that does that, so I assume it's a default in VCarve.

Just to be clear, I wasn't suggesting that the OP use the grbl post. I merely thought, incorrectly, that he may have been able to see something in the grbl post that he could use in his.

Post Reply