Hi,
well it might be called jeweling but its too bloody late now!!!...its fixed in my head and I cant be bothered editing all the code.
Try this:
function m120()
local inst=mc.mcGetInstance()
--
-- Pearl Data.....to be edited as required
--
local pearlWidth=50
local pearlLength=100
local toolDiameter=6
local nominalStepover=0.66
local plungeSpeed=300
--
-- End of data block
--
local startXpos
local startYpos
local pearlZheight
local stepoverX,numPearlX
local stepoverY,numPearlY
local i=0
local j=0
-- Save the current position as the start of the pearling area....you have jogged to the start haven't you????
startXpos=mc.mcCntlGcodeInterpGetPos(inst,mc.X_AXIS)
startYpos=mc.mcCntlGcodeInterpGetPos(inst,mc.Y_AXIS)
pearlZheight=mc.mcCntlGcodeInterpGetPos(inst,mc.Z_AXIS)
-- Calculate the required step over to meet the nominal step over as closely as possible but be an integral
-- number of 'pearls'
-- Reduce perlWidth in X and Y by the diameter of the tool
pearlWidth=pearlWidth-toolDiameter
pearlLength=pearlLength-toolDiameter
-- Calculate the exact number of 'pearls' required to match the nomininalSteppover
numPearlX=pearlWidth / (nominalStepover * toolDiameter)
numPearlY=pearlLength / (nominalStepover * toolDiameter)
-- Find the integer number of 'pearls'
numPearlX=math.modf(numPearlX)
numPearlY=math.modf(numPearlY)
-- Calculate the actual stepover to be used so that an integral number of 'pearls' are perfomed
stepoverX=pearlWidth / numPearlX
stepoverY=pearlLength / numPearlY
--
--
local retract="g0 z "..tostring(pearlZheight+2) --Nominal retract is 2mm above the surface
local safeHeight="g0 z "..tostring(pearlZheight+20) --Nominal Safe Height is 20mm above the surface
mc.mcCntlGcodeExecute(inst,retract..'\n'..
'g1 f'..tostring(plungeSpeed))
for i=1,numPearlX,i+1 do
for j=1,numPearlY,j+1 do
pearlX=startXpos + (i * stepoverX)
pearlY=startYpos + (j * stepoverY)
mc.mcCntlGcodeExecute(inst,'g0 x '..tostring(pearlX)..' y '.. tostring(pearlY)..'\n'..
'g1 z '..tostring( pearlZheight)..'\n'..
'g4 p1000'..'\n'..
retract..'\n')
end
end
mc.mcCntlGcodeExecuteWait(inst,safeHeight)
end
if (mc.mcInEditor()==1)then
m120()
end
This code should be saved as: m120.mcs in the Profiles/<Your Profile>/Macros folder.
Jog to the start of the pearling/jeweling area lower the Z axis so the first pearl/jewel is formed and MDI <m120>.
This seems to work on my laptop, I have not tried on my machine.
You could build in extra data values for things like the retract height, safe height and Z down dwell time....but you get the idea.
Craig