Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2012, 11:35:02 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  macro problem
Pages: 1   Go Down
Print
Author Topic: macro problem  (Read 861 times)
0 Members and 1 Guest are viewing this topic.
eyalyossef
Active Member

Offline Offline

Posts: 2


View Profile
« on: May 03, 2009, 10:52:42 AM »

Hello .
This program was written in vb , I want to run the program on macro from the Gcode.
the mach3 editor ,does not get it .
I really thanked those who could help repair program.






Function FindIntersection(px11 As Single, py11 As Single, px12 As Single, py12 As Single, px21 As Single, py21 As Single, px22 As Single, py22 As Single) As String
Dim dx1 As Single
Dim dy1 As Single
Dim dx2 As Single
Dim dy2 As Single
Dim t1 As Single
Dim t2 As Single
Dim nUl As Single

On Error GoTo err


   
   
    dx1 = px12 - px11                 ' calulates dx,dy for each point
    dy1 = py12 - py11
    dx2 = px22 - px21
    dy2 = py22 - py21

    nUl = (dy1 * dx2 - dx1 * dy2)
    t1 = ((px11 - px21) * dy2 + (py21 - py11) * dx2) / nUl
    t2 = ((px21 - px11) * dy1 + (py11 - py21) * dx1) / -nUl

    nInter_x = px11 + dx1 * t1    'X point
    nInter_y = py11 + dy1 * t1    'Y point
   
 
    FindIntersection = Round(inter_x, 2) & "," & Round(inter_y, 2)
err:
    If err.Number = 11 Then Label1.Caption = "parallel lines"
       
End Function
« Last Edit: May 03, 2009, 10:55:57 AM by eyalyossef » Logged
vmax549
Guest
« Reply #1 on: May 07, 2009, 08:35:32 AM »

HIYA Eyal,  You were close(;-)to getting it running. I just made a couple of changes and it runs.




Function FindIntersection(px11 As Single, py11 As Single, px12 As Single, py12 As Single, px21 As Single, py21 As Single, px22 As Single, py22 As Single) As String    ( SHOULD BE all one line)


Dim dx1 As Single
Dim dy1 As Single
Dim dx2 As Single
Dim dy2 As Single
Dim t1 As Single
Dim t2 As Single
Dim nUl As Single

On Error GoTo N2

   
    dx1 = px12 - px11                 ' calulates dx,dy for each point
    dy1 = py12 - py11
    dx2 = px22 - px21
    dy2 = py22 - py21

    nUl = (dy1 * dx2 - dx1 * dy2)
    t1 = ((px11 - px21) * dy2 + (py21 - py11) * dx2) / nUl
    t2 = ((px21 - px11) * dy1 + (py11 - py21) * dx1) / -nUl

    nInter_x = px11 + dx1 * t1    'X point
    nInter_y = py11 + dy1 * t1    'Y point
   
 
    FindIntersection = Round(inter_x, 2) & "," & Round(inter_y, 2)

N2:
    If err.Number = 11 Then Message"parallel lines"
       
End






(;-) TP

Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!