Page 2 of 4 FirstFirst 1234 LastLast
Results 13 to 24 of 38

Thread: Source code needed!

  1. #13
    Gold Member MetLHead's Avatar
    Join Date
    Mar 2003
    Location
    USA
    Posts
    749
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by GaryM
    widgitmaster,

    Thanks for the link. I am trying to figure out how to use MetlHead's Geometry module to use in a program I am trying to write. I ain't figured it out yet but I'm trying. Must be nice not to be so darn dumb.

    Gary
    I'll post some sample code later today to help get you going.

    Scott


  2. #14
    Registered
    Join Date
    Jun 2003
    Posts
    2080
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by widgitmaster
    The best experience is what you learn from major screw ups!

    Eric

    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.


  3. #15
    Gold Member MetLHead's Avatar
    Join Date
    Mar 2003
    Location
    USA
    Posts
    749
    Downloads
    0
    Uploads
    0
    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
    Attached Files Attached Files


  4. #16
    Registered
    Join Date
    Jul 2004
    Location
    United States
    Posts
    89
    Downloads
    1
    Uploads
    0
    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


  • #17
    Registered
    Join Date
    Jul 2004
    Location
    United States
    Posts
    89
    Downloads
    1
    Uploads
    0
    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


  • #18
    Registered WayneHill's Avatar
    Join Date
    Mar 2004
    Location
    Michigan
    Posts
    745
    Downloads
    0
    Uploads
    0
    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


  • #19
    Gold Member
    Join Date
    Oct 2004
    Location
    USA
    Posts
    742
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by WayneHill
    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
    Hey Guys:
    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


  • #20
    Registered
    Join Date
    Jul 2004
    Location
    United States
    Posts
    89
    Downloads
    1
    Uploads
    0
    Wayne,

    Thanks I'll check it out.

    Gary


  • #21
    Registered
    Join Date
    Jul 2004
    Location
    United States
    Posts
    89
    Downloads
    1
    Uploads
    0
    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


  • #22
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22211
    Downloads
    0
    Uploads
    0
    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)


  • #23
    Registered
    Join Date
    Jul 2004
    Location
    United States
    Posts
    89
    Downloads
    1
    Uploads
    0
    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


  • #24
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22211
    Downloads
    0
    Uploads
    0
    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)


  • Page 2 of 4 FirstFirst 1234 LastLast

    Posting Permissions



    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.