开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Fw: Macro for tool change


John Prentice
 

Brian

Tried to send this direct so you could get the attachment but your e-mail bounced (twice)

I think that the attached macro (not with this post as Group will not allow them) coded for test as M90 (Save As it in your Mach2\Macros folder) does the job you suggest. It would be useful to know if this is so or if I misunderstand the question. If it does work can you let me know what you tried that didn't so I can improve the documentation?

To pass an argument to a macro call you provide a P Q or L word in the call and pick up the values in the VB Script by a call like
xxxvalue = param1() where xxxvalue is a variable in your program and param1() is a function which returns the P word, (also param2() returns Q word value and param3() is supposed to returns L word value but I cannot get it to work)

Your example suggests that this is not what you want though. You can use variables in VB Script like in Basic so your example with "tool" as a variable is OK as far as it goes setting it.

There are two issues. (a) The variable "tool" will not be preserved between macros calls (so it will be unset in M6END) and (b) you need to pass a valid text string to Code.

You can save the tool in a G-code interpreter parameter say [10] by SetVar(10, tool) in the M6Start and get it back by tool = GetVar(10) in M6END

You should be able to format the string by something like:

code ("G43 H" & tool)

the variable "tool" is converted to a string and the operator & concatenates it with the fixed text "G43 H"

Hope this helps. I have not tested it all put together so Art may have to put us straight.

Leave out the ( and ) if you prefer - I think it reads easier with them but it's probably because of the languages I grew up with!

Best wishes

John Prentice