VCarve nesting gadget

This section is for general discussion about Gadgets

VCarve nesting gadget

Postby hunbali » Wed May 24, 2017 4:16 pm

I am developing a new gadget for VCarve that will speed up my process to create GCode.

The gadget steps would be following:
1 Select batch folder
2 Open the 1st dxf file
3 Group all vectors on the dxf file
4 Add number of copies to the individual part. (the goal is to read the number of copies based on the dxf file name)
5 Jump to the next dxf file in batch folder and repeat the steps above.
6 Select all parts and nest.
7 Ungroup all parts on each sheet.
8 Assign selected toolpath template to all the sheets associated with layers.
9 Save each sheet to a selected post processor.

So far I have modified the "DXF Batch processor" gadget to group each individual dxf files after importing the dxf file. This will do step 1 to 3 and 5. (4 is missing)
I have also found a gadget called "Apply Template To All Sheets" which will do step 8 to 9. Building the ungroup each sheet function would be easy to this gadget.

My problem is step 4 and 6.
I have read the "Vectric Lua interface for gadgets", and I did not found the LUA command to apply number of copies to a part, neither to nest. Is this something out of the LUA scope?
If the nesting and assigning the part quantities is not possible automatically, an other approach could be copying the grouped part as many times as I need (based on the file name) and than do the nesting by hand.

Any help on nesting with LUA would be appreciated.

Thank You!
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby Adrian » Wed May 24, 2017 8:44 pm

Yes it's outside the scope of the interface. The nesting is an external library from a 3rd party as far as I know from some questions I asked when I developed some parts of the "Apply Template to All Sheets" gadget.
User avatar
Adrian
Vectric Archimage
 
Posts: 7420
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: VCarve nesting gadget

Postby hunbali » Mon Jun 05, 2017 6:43 pm

Thank you for your answer.

In this case I have to go with a different solution. I would import the dxf file as many times as I need and than I would do the nest by hand.

I tried to modify the DXF batch processor to import the dxf file multiple times based on the part quantity.

I can not find a way to modify the filename and retrieve the quantity.
filename = "2_part", where the 2 means the quantity of the part.

My approach would be storing the filename, find the "_" position in the filename and get the quantity which is located left to the "_". The last step would be storing the quantity as a number.
in excel it would look like this:
quantity = NUMBERVALUE(LEFT(filename,FIND("_",filename,1)-1))

Than an easy loop would do the trick.

for i = 1, quantity do
ImportDxfDwg(filename)
end

Is there a way to retrieve the quantity based on the filename in LUA? Any help would be appreciated.
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby ger21 » Mon Jun 05, 2017 8:33 pm

Can you do it the way a lot of cabinet packages do?
You use a .csv file that contains the dxf names and quantities (and other info). Read through the .csv, and open the file as many times as the quantity field in the .csv tells you.
Gerry
ger21
Vectric Wizard
 
Posts: 857
Joined: Sun Sep 16, 2007 2:59 pm
Location: Shelby Township, MI, USA

Re: VCarve nesting gadget

Postby hunbali » Mon Jun 05, 2017 8:42 pm

Could you direct me to an example?
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby Adrian » Mon Jun 05, 2017 9:36 pm

The LUA string functions are available to manipulate the file name as needed.

http://lua-users.org/wiki/StringLibraryTutorial
User avatar
Adrian
Vectric Archimage
 
Posts: 7420
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: VCarve nesting gadget

Postby hunbali » Mon Jun 05, 2017 10:54 pm

Thank you!

StringLibrary was very useful for the solution.
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby hunbali » Wed Jun 07, 2017 12:12 am

I would like to export a sheet to dxf file. For some reason I have an error code running this lua code:

...
local filename = "c:\\Test\\Part1.dxf"
job:SelectAllVectors()
job:ExportSelectionToDxf(filename)
...

The lua selects all the vectors than stops. The problem is with the ExportSelectionToDxf function.

"No matching overload found, candidates:
bool ExportSelectionToDxf(VectricJob&,char const*,custom [double])"

Does anyone have an example or any guidance how to use the ExportSelectionToDxf function?

Thank you!
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby Adrian » Wed Jun 07, 2017 8:05 am

I'd say it's a bug in the Gadget library as the equivalent ExportSelectionToSvg and ExportSelectionToEps functions both work fine. Those formats are better to use than DXF as well as they preserve bezier curves.
User avatar
Adrian
Vectric Archimage
 
Posts: 7420
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: VCarve nesting gadget

Postby hunbali » Wed Jun 07, 2017 3:22 pm

The main reason to export to DXF was to generate pdf files for each individual sheet using a LUA code. Once all individual sheet is exported to dxf, AutoCad would generate the pdf files. Unfortunately Vcarve has no export to PDF nor print function for LUA. I would like to loop thru all sheets and create a pdf file with the sheet positioned on the center of the page and zoomed as big as it can be.

Do you have any other idea for the pdf files?

An other issue I have run into is adding the "tabs" automatically to a toolpath using LUA. I am using the "Apply Template To All Sheets" and I would like to modify it so the tabs would be assigned automatically. Setting a constant number of tabs or a constant distance between tabs. I could not find any function in the "Vectric Lua Interface for Gadgets" document that will lead me to my goal. Is this something that can be achieved?

Thanks for all your help! My gadget is slowly getting to the point I needed.
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC

Re: VCarve nesting gadget

Postby Adrian » Wed Jun 07, 2017 4:28 pm

I would thought you would be able to do it with the EPS format as that is the basis for PDF anyway.

The only way I know of to generate the tabs through LUA is by creating them directly on the vectors as needed with the InsertToolpathAtTabPoint function. There's no equivalent call to the dialog automatic placement.
User avatar
Adrian
Vectric Archimage
 
Posts: 7420
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: VCarve nesting gadget

Postby hunbali » Thu Aug 17, 2017 2:07 pm

Vcarve V9 has the function to export pdf files and I would like to build this function in my own gadget. Since the "Vectric_Lua_Interface.pdf" has no updated version with the V9 I tried the lua command ExportSelectionToPDF but no luck.

Anyone knows if there is any way to export pdf from user gadgets?
hunbali
Vectric Apprentice
 
Posts: 7
Joined: Fri May 12, 2017 8:54 pm
Model of CNC Machine: Techno CNC


Return to Gadgets - General

Who is online

Users browsing this forum: No registered users and 1 guest