function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("DXF post processor\n") ctrl:AppendText("\n") end -- Created 19/10/2005 post.ForceExtension("dxf") function OnInit() bigArcs = 1 --stitch arc segments together minArcSize = 0.05 --arcs smaller than this are converted to moves post.Text(" 0\nSECTION\n") post.Text(" 2\nENTITIES\n") angscale = 180/math.pi --convert rads to degrees numFmt = "0.############" curLayer = "Unknown" end function OnNewLine() end function OnFinish() post.Text(" 0\nENDSEC\n") post.Text(" 0\nEOF\n") end function OnRapid() end function OnMove() if(math.hypot(currentX - endX, currentY - endY) < 0.0000001) then return end post.Text(" 0\nLINE") post.Text("\n 8\n", curLayer) post.Text("\n 10\n") post.Number(currentX * scale, numFmt) post.Text("\n 20\n") post.Number(currentY * scale, numFmt) post.Text("\n 30\n") post.Number(currentZ * scale, numFmt) post.Text("\n 11\n") post.Number(endX * scale, numFmt) post.Text("\n 21\n") post.Number(endY * scale, numFmt) post.Text("\n 31\n") post.Number(endZ * scale, numFmt) post.Eol() end function OnArc() diffx = arcCentreX - currentX diffy = arcCentreY - currentY rad = math.hypot(diffx,diffy) startang = -math.atan2(diffx,diffy) * angscale startang = startang + 270 diffx = arcCentreX - endX diffy = arcCentreY - endY endang = -math.atan2(diffx,diffy) * angscale endang = endang + 270 if(arcAngle >0) then atemp = startang startang = endang endang = atemp end if(math.hypot(currentX - endX, currentY - endY) < 0.0001 and math.abs(arcAngle) > 3.14) then -- a circle post.Text(" 0\nCIRCLE") post.Text("\n 8\n", curLayer) post.Text("\n 10\n") post.Number(arcCentreX * scale, numFmt) post.Text("\n 20\n") post.Number(arcCentreY * scale, numFmt) post.Text("\n 30\n") post.Number(currentZ * scale, numFmt) post.Text("\n 40\n") post.Number(rad * scale, numFmt) post.Eol() return end post.Text(" 0\nARC") post.Text("\n 8\n", curLayer) post.Text("\n 10\n") post.Number(arcCentreX * scale, numFmt) post.Text("\n 20\n") post.Number(arcCentreY * scale, numFmt) post.Text("\n 30\n") post.Number(currentZ * scale, numFmt) post.Text("\n 40\n") post.Number(rad * scale, numFmt) post.Text("\n 50\n") post.Number(startang, numFmt) post.Text("\n 51\n") post.Number(endang, numFmt) post.Eol() end function OnSpindleCW() end function OnSpindleCCW() end function OnSpindleOff() end function OnNewOperation() local pts = sc.Parts.Get() local pt = pts:op_index(partIndex):GetParentPart() local op = pt.operations:op_index(operationIndex):DynamicCast("OperationWithPaths") if op then curLayer = op.layerName:op_get() end end function OnToolChange() end function OnSpindleChanged() end function OnNewPart() end function OnFloodOn() end function OnMistOn() end function OnCoolantOff() end function OnDrill() post.Text(" 0\nLINE") post.Text("\n 8\n", curLayer) post.Text("\n 10\n") post.Number(endX * scale, numFmt) post.Text("\n 20\n") post.Number(endY * scale, numFmt) post.Text("\n 30\n") post.Number(drillStart * scale, numFmt) post.Text("\n 11\n") post.Number(endX * scale, numFmt) post.Text("\n 21\n") post.Number(endY * scale, numFmt) post.Text("\n 31\n") post.Number(drillZ * scale, numFmt) post.Eol() end