External control of SheetCAM from Visual Basic / VBA

Hi Les,

I was wondering if you had considered exposing an object model for external control of SheetCAM? I am working on several products and I would like to have an integrated UI for CorelDraw VBA apps so my users could have GCODE ready to go to Mach3 straight from my app.

-James Leonard

Hi James,

I have to admit I haven’t really thought about it. Could you do what you
want with DDE? For various reasons I don’t want to use OLE or COM.

Could you give me some more information on what you would like to do via
the link.

Les

Hi Les,

DDE sometimes does not work so well. VB can call C linkage functions in a DLL just fine though. You could do the DDE from the DLL.

Basically I want to creat .job files and specify toolpath operations. I am doing a custom DXF export from CorelDraw with named layers. Each layer is either shapes to outside rout or pockets to cut into wood for inlay.

The idea is to export a file, tell SheetCam where it is and what to do, then generate GCODE for Mach3

-James

Hmm. Theoretically you don’t have to link to a dll. SheetCam could
expose a few functions externally that you could hook into. Instead of
lib “xxx.dll” it would be lib “sheetcam.exe”. Your software would of
course need to know the full path to sheetcam.exe.

Basically I want to creat .job files and specify toolpath operations. I am doing a custom DXF export from CorelDraw with named layers. Each layer is either shapes to outside rout or pockets to cut into wood for inlay.

.job files are in two sections. The first is in standard Windows .ini
format. The second half is the drawing data in binary format. You really
don’t want to have to deal with that bit, trust me :slight_smile:.

You should be able to create your own .job files just containing the
.ini data but no binary data. The format is pretty simple and I can
help you with the bits that aren’t obvious. I could then provide you
with three functions: LoadJob(), LoadDrawing() and RunPost().

Another option is to use the command line. I already have an
undocumented command line switch that tells SheetCam to load the
specified job, post process it then quit. It is used as part of the test
suite.

I have just had another thought - V1.0 .job files don’t contain the
drawing, they just contain the filename of the dxf file. As far as I can
remember I maintained backwards compatibility. I’ll do some experiments
tomorrow and see what I can come up with.

Hi Les,

I initially tried just stripping out the binary portion of a .job file to see if it would be as easy as it looked… :wink: SheetCAM was not impressed! :slight_smile:

It would be a very good thing overall to document the job file format for all that wanted to use SheetCAM in a little more intergrated fashion. Many cad programs have scripting capabilities.

The only issue I would see with the command line option would be in error handling. I.E. if all does not go well, how would I know about it from my VB / VBA app?

-James

I initially tried just stripping out the binary portion of a .job file to see if it would be as easy as it looked… SheetCAM was not impressed!

Did you leave the [BinaryDataStart] tag on the end of the file? I just tested a job file with everything after this tag stripped and it worked. I also looked into file format V1.0 but SheetCam no longer supports that one.

I don’t think it is worth documenting the binary part because it is inextricably linked with SheetCam’s internal workings. To generate a file in this format you need big chunks of SheetCam code and a good knowledge of how it works.

It looks like LoadJob(), LoadDrawing() etc. functions are the way to go. I’ll see what I can do in the next release.

Hi Les,

Nope, I pulled the [BinaryDataStart] tag out as well. I was guessing (hoping) that all the binary portion was optional, or created by the first run. Yes, LoadJob(), LoadDrawing(), etc. would be great. Maybe you could have a pollable completion status routine and the equivalent of GetLastErrror() so that we could do true closed loop processing.

I would also like to source tooltables and definitions from VBA.

I know that process level linkage is possible in theory, but I have never seen it done. I would be very interested in this. There is usually a marshalling layer involved, whether it is COM, DDE or a simple self-made protocol based on SendMessage or even WM_COPYDATA messaging.

This all sounds really great!

-James

I’ll do some experiments tomorrow and see if I can make some functions externally visible. If not, perhaps DDE can be used.

Les

Hi Les, my partner-to-be and I almost have V 1.0 of the DXFTool ready for release so I am back on the SheetCAM integration project. I still cannot get a .JOB file without the binary portion to load into SheetCAM. OR maybe it does load, but it definitely does not do anything!

The goal of this new project is to leverage the control we have with the DXFTool and the SheetCAM control ActiveX object to create a straight-to-router control package so this process can be similar to cutting vinyl with other CorelDraw based packages.

I am attaching a test .JOB file. Thsi one is NOT intened to ever be cut, but is being used for other aspects of V2 DXFTool development.

This .JOB file is a valid SheetCAM job with the binary data portion stripped out. This is my first pass so I have a working model to emulate.

-James Leonard

Hi James,

You need the [BinaryDataStart] tag at the end of your file. Without that
tag, SheetCam assumes the file is corrupted and ignores it.

Les


jemmyell wrote:

Hi Les, my partner-to-be and I almost have V 1.0 of the DXFTool ready for release so I am back on the SheetCAM integration project. I still cannot get a .JOB file without the binary portion to load into SheetCAM. OR maybe it does load, but it definitely does not do anything!

Hi Les,

There is an unmodified .JOB file in that ZIP file I posted. Could you strip out the binary data and repost it so I can see what I am doing wrong? I edit the file with NOTEPAD and I have tried no lines after the last tag, one blank line and two blanks lines. Nothing produces a valid load. I am doing this manually from SheetCAM for now, not from my plugin.

-James

Hi James,

There should be nothing at all after the tag, not even a newline. If you
still have problems I’ll upload a sample in the morning. This computer
is running Linux and won’t let me save a file with DOS line ends.

Les

Hi Les,

There is an unmodified .JOB file in that ZIP file I posted. Could you strip out the binary data and repost it so I can see what I am doing wrong? I edit the file with NOTEPAD and I have tried no lines after the last tag, one blank line and two blanks lines. Nothing produces a valid load. I am doing this manually from SheetCAM for now, not from my plugin.

-James

Hi Les,

Here is the ZIP file again. It has the original file, and one that I stripped the binary data out of again. It still will not load, and I looked at it with a hex editor and the file ends at the closing right bracket.

-James

Hi James,

It works for me. When I load sequencetest3.job I get two tools and two
processes. What happens when you load the job?

Les

jemmyell wrote:

Here is the ZIP file again. It has the original file, and one that I stripped the binary data out of again. It still will not load, and I looked at it with a hex editor and the file ends at the closing right bracket.

Hi Les,

That JOB file does nothing at all for me! What version did you use for test? Is it possible the plugin is interfering with this? I will try deleting the plugin tomorrow.

-James

Hi James,

The version of SheetCam shouldn’t matter. The job file code hasn’t
changed in well over a year. I loaded the file directly. Were you
loading it via the plugin?

Les

Hi Les,

That JOB file does nothing at all for me! What version did you use for test? Is it possible the plugin is interfering with this? I will try deleting the plugin tomorrow.

Hi Les,

No, it is a mystery. I loaded it directly also and nothing appeared. I will work on this more when I get to my day job.

-James

Hi Les,

I had assumed that since a full path to the drawing (my DXF) is kept in the JOB file that the drawing would be opened when I loaded the JOB file. The two lines that show that the ‘layer does not exist’ for my two defined tools / layers were almost hidden off the bottom of the screen. After I found those I had an idea, and tried opening the drawing manually.

When I open the drawing, the JOB files does display all data correctly.

Will I need to open the drawing separately in my code, or is this a bug that you want to fix?

-James

Hi James,

SheetCam expects to find the drawing data in the [BinaryDataStart]
section. As you have left the section blank you need to manually load
the drawing.

Les

Hi Les,

I had assumed that since a full path to the drawing (my DXF) is kept in the JOB file that the drawing would be opened when I loaded the JOB file. The two lines that show that the ‘layer does not exist’ for my two defined tools / layers were almost hidden off the bottom of the screen. After I found those I had an idea, and tried opening the drawing manually.

When I open the drawing, the JOB files does display all data correctly.

Will I need to open the drawing separately in my code, or is this a bug that you want to fix?