Hello Guest it is April 16, 2021, 02:12:57 PM

### Author Topic: VB calculation behind button is possible?  (Read 3313 times)

0 Members and 1 Guest are viewing this topic.

#### SimKel

• 7
##### VB calculation behind button is possible?
« on: January 13, 2012, 10:47:00 AM »
Hi,
I'm new using Mach3. I'd like to know if it is possible to create button that will execute calculation and return A and B axis angle values. I'd like to be able to enter 4 measured points. I would enter the four coordinates of each point and I'd like to calculate the plan and then the angles between reference coordinates system and the plan. The goal is to orient(A,B) the part in order to mill in a single pass with the Axis. the geometry of my part is a rectangle and i new to mill the determined plan on the upside face.

Is it possible to enter points coordinates and then have Mach3 do calculation and return the value of the angle as an input for the A and B axis.

Thanks!

#### Hood

• 25,838
• Carnoustie, Scotland
##### Re: VB calculation behind button is possible?
« Reply #1 on: January 13, 2012, 04:19:44 PM »
Not really sure what you are attempting but it is likely that could be done as most of the wizards work from code in a button.
Hood

#### SimKel

• 7
##### Re: VB calculation behind button is possible?
« Reply #2 on: January 16, 2012, 08:23:39 AM »
What i'm trying to do is to give 4 points (x,y,z) as an input. Those four points being processed by an algorithm and then return the value of the A axis and B axis in order to obtain the plan calculate by the algorithm. Is it possible, to take the output of the algorithm and use it as the input for the command of the A and B axis? I'd like to add four field to enter the points (x,y,z) and have a button to run the algorithm on the interface.

#### cjmerlin

• 194
##### Re: VB calculation behind button is possible?
« Reply #3 on: January 17, 2012, 07:56:10 AM »

It should be possible, You could create your four user Dro's using MachScreen

http://www.kd-dietz.de/index_eng

Have a browse in the documentation for the Mach3 programmers reference PDF which will give you all the info you'll need.

Also a reference to the VB script

www.indusoft.com/pdf/VBScript%20Reference.pdf

#### SimKel

• 7
##### Re: VB calculation behind button is possible?
« Reply #4 on: January 17, 2012, 08:51:37 AM »
Thanks for helping me out! I'll need a couple hours to go trough all this literature

#### Tweakie.CNC

• 8,695
• Super Kitty
##### Re: VB calculation behind button is possible?
« Reply #5 on: January 17, 2012, 10:53:48 AM »
It is my understanding that Mach supports a subset of VB which is Cypress Enable. Not all of the current VB commands are available to be used in Macro's / Button Scripts etc. so it would be best to use the CB reference guide for all your VB expressions http://www.machsupport.com/MachCustomizeWiki/pdfs/VB-Script-Commands.pdf.

Tweakie.
KEEP SAFE !

#### SimKel

• 7
##### Re: VB calculation behind button is possible?
« Reply #6 on: January 18, 2012, 09:03:53 AM »
I have a little problem that might be simple for someone. I've generated with VBscript a text file containing some GCode as it follows:

G00 A0. B0.
A0.7562497658762
B21.764485993774
M99

When I load this text file, there is nothing in the Gcode MDI. Here is how I generate the text file:

Dim fs,f As Object

Set fs =CreateObject("Scripting.FileSystemObject")
Set f=fs.CreateTextFile("c:\mach3\GCode\result_orient_shim.txt",2,true)
f.writeline("G00 A0.B0.")
f.writeline("A"&teta)
f.writeline("B"&zeta)
f.writeline("M99")
f.close

Set f=Nothing
Set fs=Nothing

Is there something wrong with my textfile!?!?

#### SimKel

• 7
##### Re: VB calculation behind button is possible?
« Reply #7 on: January 18, 2012, 09:51:34 AM »
I found out what was happening! The problem was in this code line

Set f=fs.CreateTextFile("c:\mach3\GCode\result_orient_shim.txt",2,true)

I should have used the parameter false instead of true. The MDI read text file in ASCII which corresponds to the value false. True corresponds to Unicode which is not compatible with the interface.