External control of SheetCAM from Visual Basic / VBA

Request and discuss new features
jemmyell

External control of SheetCAM from Visual Basic / VBA

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

External control of SheetCAM from Visual Basic / VBA

Post by Les Newell »

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
jemmyell

C language functions in a DLL would be better than DDE

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

External control of SheetCAM from Visual Basic / VBA

Post by Les Newell »

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 :-).

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.
jemmyell

Command line would probably be good

Post by jemmyell »

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! :)

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

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.
jemmyell

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

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

Les
jemmyell

working on job file creation again

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

External control of SheetCAM from Visual Basic / VBA

Post by Les Newell »

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!
jemmyell

I still can't make it work

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

External control of SheetCAM from Visual Basic / VBA

Post by Les Newell »

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
jemmyell

there is nothing after the closing bracket (hex 5d)

Post by jemmyell »

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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

External control of SheetCAM from Visual Basic / VBA

Post by Les Newell »

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.
jemmyell

it does nothing at all

Post by jemmyell »

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
Post Reply