Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: dah79 on March 14, 2016, 11:36:45 AM

Title: Open Mach4 with default toolpath
Post by: dah79 on March 14, 2016, 11:36:45 AM
Total newbe here, with the first of I'm sure many questions. 

Is there a way to open Mach4 with a specific toolpath file already loaded?
Title: Re: Open Mach4 with default toolpath
Post by: cncman172 on March 14, 2016, 03:58:10 PM
Dah79,

The tool path is defined by the Gcode program that is loaded into MACH4.  Why would you want a default gcode program loaded.  If you want to see the tool path just open a gcode file like roadrunner, which is included as one of the gcode files in c:\mach4hobby\gcodefiles\roadrunner.tap

Russ
Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 14, 2016, 06:17:45 PM
Theres always a way :-)

You will need to use 2 commands here within the screen load script.

From the screen editor you will need to edit the bottom of the screen load script with  mc.mcCntlLoadGcodeFile(inst, stringFileToLoad) first then create the toolpath with  mc.mcToolPathGenerate(inst)

Example with roadrunner.

Code: [Select]
    mc.mcCntlLoadGcodeFile(inst, "C:\\Mach4Hobby\\GcodeFiles\\roadrunner.tap")
    mc.mcToolPathGenerate(inst)

Hope this helps

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 15, 2016, 06:52:10 AM
Russ, this is a special situation where I want to make sure that this file is ran first.  That is why I wanted a way to have it loaded on Mach startup.

Daz, thank you for your reply.  I will try this when I get my software and controls.

Dave
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 07:24:13 AM
Finally got around to this, but had a couple of issues.  First of all, the slash (/) has to be in this direction or you get a syntax error.  This is what I ended up putting in the 'Screen Load Script':

-------------------------------------------------------
--  Screen Load Script
-------------------------------------------------------

pageId = 0
screenId = 0
testcount = 0
machState = 0
machStateOld = -1
machEnabled = 0
machWasEnabled = 0
inst = mc.mcGetInstance()
mc.mcCntlLoadGcodeFile(inst, "C:/Mach4Hobby/GcodeFiles/O0001.ngc")
mc.mcToolPathGenerate(inst)

This worked to load the default toolpath, but now I don't get the normal startup screen.  This is what I get (see attachment).  What did I do wrong?


Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 29, 2016, 08:19:22 AM
Quote
First of all, the slash (/) has to be in this direction or you get a syntax error.

The code I posted is 100% correct way of doing it and they want to be last 2 lines of the screenload script.

I will check again when near machine.

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 08:31:34 AM
Daz,

Please do check and report back.  I did put the code in the last 2 lines as shown in the above post.  See the attachment in the above post, it is a screen shot of how Mach4 opened after making those changes.

Thanks for your help.
Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 29, 2016, 04:37:19 PM
Yep checked on fresh install of mach4 and added last 2 lines and works as should.

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 05:27:46 PM
Daz,

I am running the demo version of Mach4, if that makes any difference.  From looking at my modifications above, do you see anything that I did wrong that would cause Mach to start up like what is in the attachment posted above?  If I put the (/) in the other direction (\), I get a syntax error every time and that is all I change to get rid of it.

I have made no other changes...

Dave
Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 29, 2016, 05:50:22 PM
Not sure but looks like your running XP,

If so I will hunt down an xp machine tomoro and try, just wondering if there is an error between xp and mach4 thats actually outputting some error text you cant see before it draws the main tabs.

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 05:54:13 PM
You are correct, I am running XP.

Thanks!
Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 29, 2016, 05:59:26 PM
Debugging code is fun, finding a friend who has xp is a challenge ;-)

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 07:03:57 PM
Ok,  I figured out it has something to do with the screen set I am using.  I have attached the screen set that I am trying to use AND the one that I added the 2 lines to.  I tried deleting the 2 lines that I added and the screen still would not load.  If I used a different screen set (wx6.set), everything loaded fine, as well as my default toolpath.

I know, I should have made a copy of the screen set before changing it, but....I didn't.  As stated, I am just getting started and am not connected to any machine, just playing in SIM mode.  I am trying to also get a PoKeyes module installed, but I deleted the plug ins until I get this figured out.

As far as I know, I did not change anything other than the 2 lines shown in an earlier post and the file 'compiles' without any errors.

Thanks for any help.
Title: Re: Open Mach4 with default toolpath
Post by: DazTheGas on March 29, 2016, 07:17:20 PM
The tab coords had been moved in the screen editor.

DazTheGas
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 29, 2016, 07:46:43 PM
Thanks, but how do I fix it?
Title: Re: Open Mach4 with default toolpath
Post by: dah79 on March 30, 2016, 09:33:16 AM
Figured it out.  Have no idea how everything got shifted.  Thanks for the help.