Hello Guest it is September 21, 2019, 02:27:49 AM

Author Topic: Macros, Visual Basic and all that  (Read 5045 times)

0 Members and 1 Guest are viewing this topic.

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Macros, Visual Basic and all that
« on: September 21, 2007, 11:55:57 AM »
Can somebody help me -
My machine is working fine. I am competant enough to write GCode to run it.
I have started to write Macros in Visual Basic - eg rough a bar down to a finished radius - putting in the start and finish radius in User DRO's, but the trouble with Macros is when you put them into Mach3 as, say , M204 or whatever, you cannot see the result on the toolpath generator - so it is a bit of pot luck when you run it.

What I wish to do is write my Visual Basic script, then have it output a file to a GCode file for Mach 3. When I pick up the GCode file in Mach 3 it will show me the tool path and I can go through all the checks before I run it.

I have the Vis Basic scripter writing to a file,  using "Open....etc"    Write#1 "etc etc" but Vis Basic also writes the inverted comas into the GCode, which Mach3 will not accept. What is the format to get Visual Basic writing to a file that is acceptable to Mach3, please !!!
Not me driving the engine - I'm better looking.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macros, Visual Basic and all that
« Reply #1 on: September 22, 2007, 05:00:24 AM »
Hi Jim - been a looooooooong time but - use Print instead of Write.
(to anyone - what - no FSO?)

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macros, Visual Basic and all that
« Reply #2 on: September 22, 2007, 05:16:09 AM »
Thanks for that, Stirling - I did try that, but it seemed as though I didn't get any output at all to the file.

I will try again, and come back.
Not me driving the engine - I'm better looking.

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macros, Visual Basic and all that
« Reply #3 on: September 22, 2007, 05:28:17 AM »
Yes !! Just tried it with a "Quick brown fox" writing and printing - that does the trick.

Thanks Stirling.
Not me driving the engine - I'm better looking.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Macros, Visual Basic and all that
« Reply #4 on: September 22, 2007, 09:59:46 AM »
Jim,

    For what you are wanting to do, it is far, far, far, better to make yourself a "Wizard" and have it post the G code to your Mach control.  If you download a copy of Screen3 you can then open up the current Wizards in lathe or mill and look at how people are doing just what your talking about!!!
I have one posted up here called "CNC Saw", you could open up that screen set in Screen3 and see an example, note cnc saw is a cnc control as opposed to wizard. You could also look under VB stuff and I posted up a Multithreading wizard for lathe, you could look at that for an example as well.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macros, Visual Basic and all that
« Reply #5 on: September 22, 2007, 04:00:19 PM »
Thanks Scott - I'll have alook at that.

I think I went down the Visual Basic route because I have done a bit of computer programming in the past - and thats how I think.


One more question - to anybody - how do you name a subroutine is Vis Basic - and then call it.

It seems to be happy when I use CALL to call it, but I cannot work out how to name it.
Not me driving the engine - I'm better looking.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Macros, Visual Basic and all that
« Reply #6 on: September 22, 2007, 08:26:55 PM »
somewehre in the body of your code put your call then your sub call below it.

Sub Main()
some code things

Call Subroutine_Name(perameters if any)

Sub Subroutine_Name(perameters if any)
your sub code here........
End Sub

Main

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macros, Visual Basic and all that
« Reply #7 on: September 23, 2007, 04:37:54 AM »
the CALL statement isn't needed.

foo "hello"
bar
MsgBox mySquare(3)

Sub foo (s As String)
  MsgBox s
End Sub

Sub bar()
  MsgBox "in bar"
End Sub

Function mySquare(i As Integer) As Integer
  mySquare=i*i
End Function

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macros, Visual Basic and all that
« Reply #8 on: September 23, 2007, 05:20:07 AM »
Thanks Gentlemen - I'll work on that !!!

Jim Pinder
Not me driving the engine - I'm better looking.

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macros, Visual Basic and all that
« Reply #9 on: September 23, 2007, 05:39:01 AM »
No !! I am not having much sucess. I appear to have written it as has been suggested, in fact I think I have tried just about every combination, without success.

As soon as I start stepping through it, I get syntax error - usually with one of the "Sub" words highlighted.
Do subs need to be declared, as in some PIC chip syntax ???


I have attached my script, if anyone would mind having a look at it. Basically it turns a handrail stanchion from a piece of 10 mm bar (or any start diameter) - the inputs are from DRO on a page of Mach3 Turn I have ammended.

The maths might be a bit out, ( I don't think so, but until I get the syntax right, I can't check it.)

Jim Pinder

Any replies could come direct to jimpinder@tiscali.co.uk






Not me driving the engine - I'm better looking.