function PPCLib.placePlateToOrigin(plate,machine,isForBottomFace,offsetToolpath,job) local originXY = machine.XYOrigin local originZ = machine.ZOrigin local machineWidth = machine.size.x local machineLength = machine.size.y local bedPlateSize = machine.bedPlateSize local machineAR = machineWidth/machineLength local w = plate.width local h = plate.height local plateAR = w/h local t = currentPlateThickness if isForBottomFace then Zk = -1 else Zk = 1 end local state = nil if ((machineAR <= 1) and (plateAR <=1)) or ((machineAR > 1) and (plateAR > 1)) then state = 1 if (machineAR <= 1 ) then if machineWidth > h then state = 2 end else if machineLength > w then state = 2 end end else state = 2 if (machineAR < 1 ) and (plateAR > 1) then if machineWidth > w then state = 1 end else if machineLength > h then state = 1 end end end if state == 1 then Yi, Yj = 0, 1 if originXY == XYOriginType.XminusYminus then h = 0 if (not isForBottomFace) then w=0 end elseif originXY == XYOriginType.XminusYplus then if (not isForBottomFace) then w = 0 end elseif originXY == XYOriginType.XplusYplus then if isForBottomFace then w = 0 end elseif originXY == XYOriginType.XplusYminus then h = 0 if isForBottomFace then w = 0 end elseif originXY == XYOriginType.XYmiddle then w, h = w/2, h/2 end elseif state == 2 then Yi, Yj = 1, 0 if originXY == XYOriginType.XminusYminus then w = 0 if isForBottomFace then h = 0 end elseif originXY == XYOriginType.XminusYplus then if isForBottomFace then h = 0 end elseif originXY == XYOriginType.XplusYplus then if (not isForBottomFace) then h = 0 end elseif originXY == XYOriginType.XplusYminus then w = 0 if (not isForBottomFace) then h = 0 end elseif originXY == XYOriginType.XYmiddle then w, h = w/2, h/2 end end if originZ == ZOriginType.topOfStockSurface then if isForBottomFace then t = (-1)*t else t = 0 end elseif originZ == ZOriginType.bottomOfStockSurface then if isForBottomFace then t = 0 else t = (-1)*t end elseif originZ == ZOriginType.bottomOfBedPlateSurface then if isForBottomFace then t = (-1)*bedPlateSize.z else t = (-1)*(t+bedPlateSize.z) end else end returnValue = Transform() returnValue.translation = Vec3(w,h,t) returnValue.rotation = computeMatrixHoldDir(Vec3(Yi,Yj,0),Vec3(0,0,Zk)) return returnValue end