Originally Posted by widgitmaster
If that is the case, I am the most experienced person there is!![]()
Mike
I'll post some sample code later today to help get you going.Originally Posted by GaryM
Scott
Originally Posted by widgitmaster
If that is the case, I am the most experienced person there is!![]()
Mike
No greater love can a man have than this, that he give his life for a friend.
Gary,
Here's a quick sample project in VB. On the form there are text boxes for entering a start point, end point and radius. There are also two option buttons for specifying arc direction. Just enter values and click either 'Add Line' to insert a G01 block or 'Add Arc' to insert a G02/G03 block. You might want to step through it a few times to see what's going on.
Hope this helps,
Scott
MetLHead,
You are all right. That is exacly what I needed. I was getting close but I missed it a little bit. When I get the program cleaned up a little bit I will post it for people to try out. Thanks again!
Gary
Boy do I need HELP! I figured out how to use MetlHead's code, but how to actually use this to draw an arc? Here is the G-code
G01 F30 X10 Y10
G01 Z-2
G02 X70 Y60 I73.3 J-26.96
I tried using this to draw an arc, e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, sweepAngle)
Still can't get it to draw an arc the way cncsimulator does. Anyone have a hint or clue?
Sorry I ask these dumb questions, I have only messed around with programming a little bit, nothing this complex.
Gary
GaryM,
I posted a G-Code to DXF program converter with open source a while back:
G-Code to DXF
Looks close to the same method that MetLHead used. Great minds think alike![]()
Wayne Hill
Hey Guys:Originally Posted by WayneHill
I want to compliment Wayne on his program. I have used it and recommend it. If you need a conversion program, this is the one.
Jerry
Wayne,
Thanks I'll check it out.
Gary
Help!
Boy do I need help! I am useing VB.NET to write this function. I have this function below which draws an arc by starting with the startangle and then the sweep. But, I want to write it so I can start the arc say at screenX and screeny and end the arc at endx and endy! Let's say I want to start the arc at screenx = 10, screeny = 10, endx
= 100, endy = 50, radius of 50.
"Here is the G-Code"
G01 F30 X10 Y10
G01 Z-2
G02 X100 Y50 I48.52 J12.09
I have tried so many different variations that now I am so confused I am lost. Any help would be very much appreciated!
Sub drawArc(ByVal radius As Single, ByVal startAngle As Single, ByVal sweep As Single)
Const n As Integer = 30
Dim angle As Single = startAngle * 3.14159265 / 180
Dim angleInc As Single = sweep * 3.14159265 / (180 * n)
Dim cx As Single = garc.C.X
Dim cy As Single = garc.C.Y
Dim sx As Single = cx + radius * Cos(angle)
Dim sy As Single = cy + radius * Sin(angle)
Dim ex As Single
Dim ey As Single
Dim k As Integer = 1
While k < n
ex = cx + radius * Cos(angle)
ey = cy + radius * Sin(angle)
g.DrawLine(myPen, sx, sy, ex, ey)
sx = ex
sy = ey
System.Math.Min(System.Threading.Interlocked.Increment(k), k - 1)
angle += angleInc
End While
End Sub
Gary
I don't know what the garc is, but your center (cx, cy, right?)would simply be 58.52, 22.09 (this is rounded off, btw. More decimals = better) And your original sx = 10 and original sy = 10. After that it should be the same code, right?
I haven't used any .net and my VB is very weak, but that's what I get out of this.![]()
Gerry
Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Gerry,
The garc is from the geometry module that MetlHead posted awhile back. The cx, cy, is the center yes. Here is the function I have in the above post DrawArc(radius,startAngle, sweep). What I really want is drawArc(startx,starty,endx,endy).
The program that I'm writing works good as far as the g-code. My program produced the g-code in the above post, just need some graphics. So far the program will do drill hole patterns, Pockets, lines, arcs, except no graphic for the arc. Hope all this makes sense.
Gary
It's basically the same thing. You have the start and end points, and the center point. Your drawing the arc as a series of straight lines, right. Figure out the included angle, and divide it up by how many segments you want to draw the arc in. Then, just enter the 10,10 as the start and use the angle increment to figure out each succesive point until you reach the end. Maybe a for...next loop for the amount of segments needed would be better than the while loop.
Gerry
Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)