Results 1 to 2 of 2

Thread: Editing post question - Lua to Javascript

  1. #1
    Registered
    Join Date
    Jul 2008
    Location
    USA
    Posts
    98
    Downloads
    0
    Uploads
    0

    Editing post question - Lua to Javascript

    I am working on something that I hope I can apply to HSMworks... Currently we have a robot that is plasma cutting from code we have set up in SheetCAM....it is written in Lua... I would have so much more control over the toolpaths if I used HSMworks instead of SheetCAM....I can just use a 2D contour cut, and translate the spindle on/off to be read as firing the robot I/O for the plasma cutter.... I was hoping to be able to translate the Lua code to Javascript for this particular formula - but haven't a clue how to do it....

    Below is the Lua code for certain arc points (rather than using I,J) that I need to translate into Javascript for HSMworks to use...if anyone has experience in translating between the two, any help would be appreciated...


    function OnArc()
    if(math.abs(endZ - currentZ) >.001 ) then
    post.ArcAsMoves(.05)
    return
    end

    halfpi = math.pi/2

    difx = currentX - arcCentreX
    dify = currentY - arcCentreY

    radius = math.hypot(difx,dify)
    startangle = math.atan2(difx,dify)
    endangle = startangle + arcAngle
    if(arcAngle > 0) then
    quad = (math.toint((startangle / halfpi) + 10) - 10) * halfpi
    repeat
    quad = quad + halfpi
    if(quad > endangle) then
    doarc(endangle)
    else
    doarc(quad)
    end
    until(quad >= endangle)
    else
    quad = -(math.toint((-startangle / halfpi) + 10) - 10) * halfpi
    repeat
    quad = quad - halfpi
    if(quad < endangle) then
    doarc(endangle)
    else
    doarc(quad)
    end
    until(quad <= endangle)
    end
    end

    function doarc(angle)
    if(arcAngle <0) then
    post.Text (" G03")
    else
    post.Text (" G02")
    end
    post.NonModalNumber (" X", ((math.sin(angle) * radius) + arcCentreX) * scale, "0.0000")
    post.NonModalNumber (" Y", ((math.cos(angle) * radius) + arcCentreY) * scale, "0.0000")
    post.NonModalNumber (" CX",(arcCentreX) * scale, "0.0000")
    post.NonModalNumber (" CY",(arcCentreY) * scale, "0.0000")
    post.NonModalNumber (" F", feedRate * scale, "0.0###")
    post.Eol()
    end


  2. #2
    Registered
    Join Date
    Jul 2008
    Location
    USA
    Posts
    98
    Downloads
    0
    Uploads
    0
    Got it taken care of....very simple modification to the post...

    maximumCircularSweep = toRad(180) - changed (180) to (45) and it breaks out points along the arc up to 8 places....nice!!


Similar Threads

  1. need help editing post
    By laltec in forum Post Processors for MC
    Replies: 2
    Last Post: 04-16-2010, 12:28 AM
  2. Need help editing post
    By bugzpulverizer in forum Post Processors for MC
    Replies: 5
    Last Post: 08-25-2008, 12:35 PM
  3. Javascript Page to determine stepper wires
    By hesham morsy in forum Stepper Motors and Drives
    Replies: 0
    Last Post: 01-21-2007, 05:57 PM
  4. Post Editing
    By jybute in forum GibbsCAM
    Replies: 2
    Last Post: 09-16-2006, 05:44 PM
  5. Editing question
    By CNCadmin in forum OneCNC
    Replies: 8
    Last Post: 10-23-2004, 12:09 AM

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.