Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07ea8c7ef3 | |||
| f4baf8a43b | |||
| c8d4a28d22 |
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
{
|
||||
"Lua.diagnostics.globals": [
|
||||
"EgtProtectGlobal",
|
||||
"EgtOutLog",
|
||||
"GDB_ID",
|
||||
"EgtGetFirstNameInGroup",
|
||||
"EgtImportDxf",
|
||||
"EgtGetLastInGroup",
|
||||
"EgtGetNextPart",
|
||||
"EgtGetLastPart",
|
||||
"EgtSetInfo",
|
||||
"EgtSetName",
|
||||
"EgtGetFirstLayer",
|
||||
"EgtGetName",
|
||||
"EgtGetFirstInGroup",
|
||||
"EgtGetType",
|
||||
"GDB_TY",
|
||||
"EgtCurveThickness",
|
||||
"EgtModifyCurveThickness",
|
||||
"EgtCurveIsClosed",
|
||||
"EgtTrimCurveStartAtLen",
|
||||
"EgtSP",
|
||||
"EgtEP",
|
||||
"EgtTrimCurveEndAtLen",
|
||||
"EgtCloseCurveCompo",
|
||||
"EgtCurveAreaXY",
|
||||
"abs",
|
||||
"EgtGetNext",
|
||||
"EgtInvertCurve",
|
||||
"EgtGetBBox",
|
||||
"GDB_BB",
|
||||
"EgtGroup",
|
||||
"EgtTextAdv",
|
||||
"Point3d",
|
||||
"GDB_TI",
|
||||
"EgtSetColor",
|
||||
"BBox3d",
|
||||
"EgtRotate",
|
||||
"ORIG",
|
||||
"Z_AX",
|
||||
"EgtCopy",
|
||||
"EgtSurfFlatRegion",
|
||||
"Color3d",
|
||||
"EgtSetStatus",
|
||||
"GDB_ST",
|
||||
"EgtMdbSetCurrMachining",
|
||||
"EgtMdbGetCurrMachiningParam",
|
||||
"EgtTdbSetCurrTool",
|
||||
"EgtTdbGetCurrToolParam",
|
||||
"MCH_MP",
|
||||
"EgtOffsetCurveAdv",
|
||||
"EgtRelocateGlob",
|
||||
"MCH_TP",
|
||||
"EgtCurveWithRegionClassify",
|
||||
"GDB_CRC",
|
||||
"EgtErase",
|
||||
"EgtGetBBoxGlob",
|
||||
"EgtInvertSurf",
|
||||
"EgtGetInfo",
|
||||
"EgtAutoNestAddPart",
|
||||
"EgtAutoNestAddHoleToPart",
|
||||
"EgtAutoNestAddToolOutlineToPart",
|
||||
"EgtSetCurrMachine",
|
||||
"V_NULL",
|
||||
"EgtAutoNestGetOneResult",
|
||||
"EgtSetCurrMachGroup",
|
||||
"EgtGetFirstRawPart",
|
||||
"EgtGetParent",
|
||||
"EgtGetMachGroupNewName",
|
||||
"EgtAddMachGroup",
|
||||
"EgtGetCurrMachGroup",
|
||||
"EgtGetMachGroupId",
|
||||
"EgtMirror",
|
||||
"Y_AX",
|
||||
"GDB_RT",
|
||||
"EgtMove",
|
||||
"Vector3d",
|
||||
"EgtAddPartToRawPart",
|
||||
"EgtZoom",
|
||||
"SCE_ZM",
|
||||
"EgtAutoNestStart",
|
||||
"EgtResetCurrMachGroup",
|
||||
"EgtRectangle2P",
|
||||
"EgtGetFirstPartInRawPart",
|
||||
"EgtGetNextPartInRawPart",
|
||||
"EgtAutoNestAddSheet",
|
||||
"EgtAutoNestAddDefectToSheet",
|
||||
"EgtAutoNestSetInterpartGap",
|
||||
"EgtAutoNestCompute",
|
||||
"EgtAutoNestGetComputationStatus",
|
||||
"EgtAutoNestGetResults",
|
||||
"EgtProcessEvents",
|
||||
"EgtAutoNestCancelComputation",
|
||||
"EgtGetCurrMachineName",
|
||||
"EgtGetMachiningGeometry",
|
||||
"EgtExistsObj",
|
||||
"EgtGetMachiningParam",
|
||||
"EgtSetCurrMachining",
|
||||
"EgtGetMachiningEndPoint",
|
||||
"EgtSpInit",
|
||||
"EgtSpAddPoint",
|
||||
"SHP_OB",
|
||||
"EgtSpSetOpenBound",
|
||||
"EgtSpCalculate",
|
||||
"SHP_TY",
|
||||
"EgtSpTerminate",
|
||||
"GDB_IN",
|
||||
"EgtGetRawPartCenter",
|
||||
"sqrt",
|
||||
"EgtSpSetZzOwStep",
|
||||
"EgtGetCurrPhase",
|
||||
"EgtGetPhaseDisposition",
|
||||
"EgtCreateDirectory",
|
||||
"EgtGetFirstMachGroup",
|
||||
"EgtGetNextMachGroup",
|
||||
"EgtImportSetup",
|
||||
"EgtGetRawPartBBox",
|
||||
"EgtLine",
|
||||
"tointeger",
|
||||
"floor",
|
||||
"EgtAddMachining",
|
||||
"EgtSetMachiningGeometry",
|
||||
"EgtApplyMachining",
|
||||
"EgtSurfFrAdd",
|
||||
"EgtSurfFrSubtract",
|
||||
"EgtExplodeSurf",
|
||||
"EgtTrimCurveWithRegion",
|
||||
"MCH_MILL_WS",
|
||||
"EgtSetMachiningParam",
|
||||
"MCH_MILL_LI",
|
||||
"EgtApplyAllMachinings",
|
||||
"EgtEstimate",
|
||||
"EgtCopyFile",
|
||||
"EgtEraseFile",
|
||||
"EgtSetMachineLook",
|
||||
"MCH_LOOK",
|
||||
"EgtExportSvg",
|
||||
"EgtGetFirstGroupInGroup",
|
||||
"EgtGetNextGroup",
|
||||
"EgtCopyGlob",
|
||||
"EgtGetNextName",
|
||||
"EnclosesXY",
|
||||
"EgtGenerate",
|
||||
"EgtCurveLength",
|
||||
"EgtGetCalcColor",
|
||||
"EgtRemoveOperation",
|
||||
"EgtArcRadius",
|
||||
"GEO",
|
||||
"min",
|
||||
"EgtExplodeCurveCompo",
|
||||
"EgtCurveCompo",
|
||||
"EgtAddCurveCompoCurve",
|
||||
"AreSameColor",
|
||||
"EgtPointCurveDistSide",
|
||||
"X_AX",
|
||||
"max",
|
||||
"EgtSurfFrRectangle"
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -151,7 +151,7 @@ Config.TabParams = {{MatId = 1, MatExtCode = 6120, Length = 10.0, Height =
|
||||
Config.Kerf = {{MatId = 1, MatExtCode = 6120, Kerf = 8},
|
||||
{MatId = 2, MatExtCode = 6110, Kerf = 20},
|
||||
{MatId = 3, MatExtCode = 6049, Kerf = 20},
|
||||
{MatId = 4, MatExtCode = 6118, Kerf = 20},
|
||||
{MatId = 4, MatExtCode = 6118, Kerf = 10},
|
||||
{MatId = 5, MatExtCode = 6479, Kerf = 20},
|
||||
{MatId = 6, MatExtCode = 6408, Kerf = 20},
|
||||
{MatId = 7, MatExtCode = 6406, Kerf = 20},
|
||||
@@ -161,7 +161,7 @@ Config.Kerf = {{MatId = 1, MatExtCode = 6120, Kerf = 8},
|
||||
{MatId = 11, MatExtCode = 6423, Kerf = 20},
|
||||
{MatId = 12, MatExtCode = 112268, Kerf = 20},
|
||||
{MatId = 13, MatExtCode = 119169, Kerf = 20},
|
||||
{MatId = 14, MatExtCode = 121214, Kerf = 20},
|
||||
{MatId = 14, MatExtCode = 121214, Kerf = 10},
|
||||
{MatId = 15, MatExtCode = 111625, Kerf = 20},
|
||||
{MatId = 16, MatExtCode = 6127, Kerf = 20},
|
||||
{MatId = 17, MatExtCode = 6044, Kerf = 20},
|
||||
@@ -174,7 +174,7 @@ Config.Kerf = {{MatId = 1, MatExtCode = 6120, Kerf = 8},
|
||||
{MatId = 26, MatExtCode = 127662, Kerf = 20},
|
||||
{MatId = 27, MatExtCode = 127663, Kerf = 20},
|
||||
{MatId = 28, MatExtCode = 127664, Kerf = 20},
|
||||
{MatId = 29, MatExtCode = 127665, Kerf = 20},
|
||||
{MatId = 29, MatExtCode = 127665, Kerf = 10},
|
||||
}
|
||||
|
||||
Config.KitXModel = {{Model = '65w981', KitQty = 6},
|
||||
|
||||
@@ -19,7 +19,7 @@ package.cpath = package.cpath .. ";/EgtDevTest/LUAREST/32/?.lua"
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( false)
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-- Imposto direttorio libreria specializzata per Nesting
|
||||
local sBaseDir = EgtGetSourceDir()
|
||||
@@ -279,7 +279,7 @@ function Nesting(readBatch)
|
||||
local MatSheetList = {}
|
||||
--for Material = 1, #materials do
|
||||
for Material = MatIndex, MatCount do
|
||||
--for Material = 2, 2 do
|
||||
-- for Material = 15, 15 do
|
||||
--for Material = 4, 4 do
|
||||
-- se è il materiale nullo salto al prossimo
|
||||
if materials[Material].MatId ~= 0 and #materials[Material].PriorityList > 0 then
|
||||
@@ -388,6 +388,7 @@ function Nesting(readBatch)
|
||||
-- calcolo lavorazioni, stime, ecc
|
||||
NestingLib.PostNestOp(materials[Material], ErrorList, false, readBatch.BatchId, 1)
|
||||
NestingLib.PostNestOp(materials[Material], ErrorList, false, readBatch.BatchId, 2)
|
||||
NestingLib.PostNestOp(materials[Material], ErrorList, false, readBatch.BatchId, 3)
|
||||
if ManageError(ErrorList, readBatch) then return end
|
||||
|
||||
-- salvo il progetto di nesting
|
||||
@@ -399,7 +400,9 @@ function Nesting(readBatch)
|
||||
EgtOutText("End sheets nest")
|
||||
|
||||
-- se debug
|
||||
if DebugCode then
|
||||
--if DebugCode then
|
||||
-- verifico se ci sono tutti i pezzi dopo il nesting perche' i pezzi grandi quasi come il foglio potrebbero non essere nestati
|
||||
if Config.bDoubleMach then
|
||||
-- verifico di aver messo tutti i part su un grezzo
|
||||
local PartList = {}
|
||||
-- raccolgo tutti i part dai materiali in una lista
|
||||
@@ -947,8 +950,48 @@ function Estimate(readBatch)
|
||||
end
|
||||
end
|
||||
|
||||
EgtOutText("End sheets estimate")
|
||||
-- verifico se ci sono tutti i pezzi dopo il nesting perche' i pezzi grandi quasi come il foglio potrebbero non essere nestati
|
||||
if Config.bDoubleMach then
|
||||
-- verifico di aver messo tutti i part su un grezzo
|
||||
local PartList = {}
|
||||
-- raccolgo tutti i part dai materiali in una lista
|
||||
for MaterialIndex = 1, #materials do
|
||||
if materials[MaterialIndex].SheetList then
|
||||
for SheetIndex = 1, #materials[MaterialIndex].SheetList do
|
||||
for PartIndex = 1, #materials[MaterialIndex].SheetList[SheetIndex].PartList do
|
||||
table.insert(PartList, tonumber(materials[MaterialIndex].SheetList[SheetIndex].PartList[PartIndex].PartId))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- passo i part del readbatch
|
||||
for OrderIndex = CurrOrderIndex, CurrOrderCount do
|
||||
for KitIndex = 1, #readBatch.OrderList[OrderIndex].KitList do
|
||||
for BPartIndex = 1, #readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList do
|
||||
local bFound = false
|
||||
for VPartIndex = #PartList, 1, -1 do
|
||||
if readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId == PartList[VPartIndex] then
|
||||
if not bFound then
|
||||
bFound = true
|
||||
table.remove(PartList, VPartIndex)
|
||||
else
|
||||
table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId, Description = "Part duplicated after nesting!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
if not bFound then
|
||||
table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId, Description = "Part lost after nesting!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- verifico se sono rimasti elementi nella tabella kit
|
||||
if #PartList > 0 then
|
||||
table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. PartList[1], Description = #PartList .. " part more than in batch request after nesting!"})
|
||||
end
|
||||
end
|
||||
|
||||
EgtOutText("End sheets estimate")
|
||||
|
||||
-- creo batch di risposta
|
||||
local answ = {}
|
||||
@@ -1068,6 +1111,47 @@ function ExtendedEstimate(readBatch)
|
||||
table.insert(answ.EstOrderList, readBatch.OrderList[Order])
|
||||
end
|
||||
|
||||
-- -- verifico se ci sono tutti i pezzi dopo il nesting perche' i pezzi grandi quasi come il foglio potrebbero non essere nestati
|
||||
-- if true then
|
||||
-- -- verifico di aver messo tutti i part su un grezzo
|
||||
-- local PartList = {}
|
||||
-- -- raccolgo tutti i part dai materiali in una lista
|
||||
-- for MaterialIndex = 1, #materials do
|
||||
-- if materials[MaterialIndex].SheetList then
|
||||
-- for SheetIndex = 1, #materials[MaterialIndex].SheetList do
|
||||
-- for PartIndex = 1, #materials[MaterialIndex].SheetList[SheetIndex].PartList do
|
||||
-- table.insert(PartList, tonumber(materials[MaterialIndex].SheetList[SheetIndex].PartList[PartIndex].PartId))
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- -- passo i part del readbatch
|
||||
-- for OrderIndex = 1, #readBatch.OrderList do
|
||||
-- for KitIndex = 1, #readBatch.OrderList[OrderIndex].KitList do
|
||||
-- for BPartIndex = 1, #readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList do
|
||||
-- local bFound = false
|
||||
-- for VPartIndex = #PartList, 1, -1 do
|
||||
-- if readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId == PartList[VPartIndex] then
|
||||
-- if not bFound then
|
||||
-- bFound = true
|
||||
-- table.remove(PartList, VPartIndex)
|
||||
-- else
|
||||
-- table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId, Description = "Part duplicated after nesting!"})
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- if not bFound then
|
||||
-- table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. readBatch.OrderList[OrderIndex].KitList[KitIndex].PartList[BPartIndex].PartId, Description = "Part lost after nesting!"})
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- -- verifico se sono rimasti elementi nella tabella kit
|
||||
-- if #PartList > 0 then
|
||||
-- table.insert(ErrorList, {ErrType = "E.12", Uid = "PartId = " .. PartList[1], Description = #PartList .. " part more than in batch request after nesting!"})
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- correggo e riporto tempo totale di lavorazione
|
||||
answ.EstimatedWorktime = TotTime
|
||||
|
||||
|
||||
+125
-22
@@ -131,7 +131,7 @@ function NestingLib.FilterPaintedParts(OrderList, materials, ErrorList)
|
||||
end
|
||||
|
||||
-- ordino per modelli kit
|
||||
function compareOrderExtCode(a,b)
|
||||
local function compareOrderExtCode(a,b)
|
||||
return a.OrderCod < b.OrderCod
|
||||
end
|
||||
table.sort(OrderList, compareOrderExtCode)
|
||||
@@ -536,9 +536,13 @@ local SKELETONTRACK = "SKELETONTRACK"
|
||||
local SKELETONPART = "SKELETON"
|
||||
local CUTOPT = "CUTOPT"
|
||||
-- funzione legge il dxf ed aggiunge il pezzo al nesting
|
||||
local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
local function AddPartListToNesting(PartList, ErrorList, Material, IsEstimate)
|
||||
local BigPartsQty = 0
|
||||
local LastId = GDB_ID.ROOT
|
||||
for Part = 1, #PartList do
|
||||
--if PartList[Part].PartExtCode == '14162182' or PartList[Part].PartExtCode == '14162184' then
|
||||
-- x = 5
|
||||
--end
|
||||
-- tipo di rotazione del pezzo consentita : 0 -> rotazione libera, 1 -> rotazione solo di 180°, 2 -> nessuna rotazione
|
||||
local RotationType = 0
|
||||
-- verifico se gia' presente per importazione precedente
|
||||
@@ -577,6 +581,7 @@ local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
local LayerId = EgtGetFirstLayer(PartId1)
|
||||
local nMaxId = GDB_ID.NULL
|
||||
local bFound = false
|
||||
local bBigPart = false
|
||||
while LayerId do
|
||||
local layerName = EgtGetName(LayerId)
|
||||
local bOutline = false
|
||||
@@ -602,7 +607,7 @@ local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
end
|
||||
-- se entro la tolleranza
|
||||
if -OutlineDepth >= (Material.T_mm - Config.ThicknessTolerance) and -OutlineDepth <= (Material.T_mm + Config.ThicknessTolerance) then
|
||||
EgtModifyCurveThickness(OutlineId, -Material.T_mm)
|
||||
EgtModifyCurveThickness(OutlineId, - Material.T_mm)
|
||||
end
|
||||
-- se il percorso non è chiuso
|
||||
if not EgtCurveIsClosed(OutlineId) then
|
||||
@@ -710,6 +715,50 @@ local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
RotationType = 1
|
||||
end
|
||||
EgtSetName(nMaxId, OUTLINE)
|
||||
-- verifico se e' grande quasi come il foglio
|
||||
local dTempX = OutlineBox:getDimX()
|
||||
local dTempY = OutlineBox:getDimY()
|
||||
local bRotated = false
|
||||
if dTempY > dTempX then
|
||||
bRotated = true
|
||||
dTempX = OutlineBox:getDimY()
|
||||
dTempY = OutlineBox:getDimX()
|
||||
end
|
||||
-- ricavo Kerf del materiale
|
||||
local dKerf = 9
|
||||
for Index = 1, #Config.Kerf do
|
||||
if Config.Kerf[Index].MatId == Material.MatId then
|
||||
dKerf = Config.Kerf[Index].Kerf
|
||||
end
|
||||
end
|
||||
if dTempX > Material.L_mm - max( 51, dKerf) - dKerf and dTempY > Material.W_mm - max( 26, dKerf) - dKerf then
|
||||
-- verifico se occupa l'angolo
|
||||
local nInside1 = 0
|
||||
local nInside2 = 0
|
||||
if not bRotated then
|
||||
local LabelRegId = EgtSurfFrRectangle( EgtGetParent( nMaxId), OutlineBox:getMin() + ( OutlineBox:getDimY() - 26) * Y_AX() - 10 * X_AX(), OutlineBox:getMin() + ( OutlineBox:getDimY() + 10) * Y_AX() + 51 * X_AX(), GDB_RT.GLOB)
|
||||
nInside1 = EgtCurveWithRegionClassify( nMaxId, LabelRegId)
|
||||
EgtErase( LabelRegId)
|
||||
LabelRegId = EgtSurfFrRectangle( EgtGetParent( nMaxId), OutlineBox:getMax() - ( OutlineBox:getDimY() - 10) * Y_AX() - 51 * X_AX(), OutlineBox:getMax() + 10 * X_AX() - ( OutlineBox:getDimY() - 26) * Y_AX(), GDB_RT.GLOB)
|
||||
nInside2 = EgtCurveWithRegionClassify( nMaxId, LabelRegId)
|
||||
EgtErase( LabelRegId)
|
||||
--_, _, nInside1 = EgtPointCurveDistSide( OutlineBox:getMin() + ( OutlineBox:getDimY() - 26) * Y_AX() + 51 * X_AX(), nMaxId, Z_AX())
|
||||
--_, _, nInside2 = EgtPointCurveDistSide( OutlineBox:getMax() - ( OutlineBox:getDimY() - 26) * Y_AX() - 51 * X_AX(), nMaxId, Z_AX())
|
||||
else
|
||||
local LabelRegId = EgtSurfFrRectangle( EgtGetParent( nMaxId), OutlineBox:getMin() - 10 * X_AX() - 10 * Y_AX(), OutlineBox:getMin() + 51 * Y_AX() + 26 * X_AX(), GDB_RT.GLOB)
|
||||
nInside1 = EgtCurveWithRegionClassify( nMaxId, LabelRegId)
|
||||
EgtErase( LabelRegId)
|
||||
LabelRegId = EgtSurfFrRectangle( EgtGetParent( nMaxId), OutlineBox:getMax() - 51 * Y_AX() - 26 * X_AX(), OutlineBox:getMax() + 10 * X_AX() + 10 * Y_AX(), GDB_RT.GLOB)
|
||||
nInside2 = EgtCurveWithRegionClassify( nMaxId, LabelRegId)
|
||||
EgtErase( LabelRegId)
|
||||
--_, _, nInside1 = EgtPointCurveDistSide( OutlineBox:getMin() + 51 * Y_AX() + 26 * X_AX(), nMaxId, Z_AX())
|
||||
--_, _, nInside2 = EgtPointCurveDistSide( OutlineBox:getMax() - 51 * Y_AX() - 26 * X_AX(), nMaxId, Z_AX())
|
||||
end
|
||||
if nInside1 ~= GDB_CRC.OUT and nInside2 ~= GDB_CRC.OUT then
|
||||
bBigPart = true
|
||||
BigPartsQty = BigPartsQty + 1
|
||||
end
|
||||
end
|
||||
-- copio outline in un layer dedicato
|
||||
local OutlineLayer = EgtGroup(PartId1)
|
||||
EgtSetName(OutlineLayer, OUTLINE)
|
||||
@@ -862,7 +911,9 @@ local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
end
|
||||
-- preparo pezzo per il nesting
|
||||
local Priority = 0
|
||||
if PartList[Part].Priority then
|
||||
if bBigPart and not IsEstimate then
|
||||
Priority = 1
|
||||
elseif PartList[Part].Priority then
|
||||
Priority = PartList[Part].Priority
|
||||
end
|
||||
local bCanRotate, dRotStep = true, 0
|
||||
@@ -886,6 +937,8 @@ local function AddPartListToNesting(PartList, ErrorList, Material)
|
||||
end
|
||||
EgtAutoNestAddToolOutlineToPart( PartId1, nSkeletonRegionId)
|
||||
end
|
||||
--EgtSaveFile("c:\\Temp\\TestSauderBig.nge")
|
||||
return BigPartsQty
|
||||
end
|
||||
--
|
||||
|
||||
@@ -897,6 +950,9 @@ local function SetMachineByIndex(MachId)
|
||||
elseif MachId == 2 then
|
||||
sCurrMachName = "Multiax-NE_Nest02"
|
||||
EgtSetCurrMachine(sCurrMachName)
|
||||
elseif MachId == 3 then
|
||||
sCurrMachName = "Multiax-NE_Nest03"
|
||||
EgtSetCurrMachine(sCurrMachName)
|
||||
end
|
||||
end
|
||||
--
|
||||
@@ -915,6 +971,7 @@ local function CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList
|
||||
local Sheet = {PartList = {}}
|
||||
local bFirstSheet = true
|
||||
local nMach2SheetId = FirstMachIndex
|
||||
local nMach3SheetId = FirstMachIndex
|
||||
for i = 0, 999 do
|
||||
local nType, nId, nFlag, dX, dY, dAngRot = EgtAutoNestGetOneResult( i)
|
||||
if not nType then break end
|
||||
@@ -932,6 +989,9 @@ local function CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList
|
||||
if MachId == 2 then
|
||||
nRawId = EgtGetInfo(nRawId, 'LastRaw2')
|
||||
EgtSetCurrMachGroup(EgtGetParent(EgtGetParent(nRawId)))
|
||||
elseif MachId == 3 then
|
||||
nRawId = EgtGetInfo(nRawId, 'LastRaw3')
|
||||
EgtSetCurrMachGroup(EgtGetParent(EgtGetParent(nRawId)))
|
||||
end
|
||||
-- imposto foglio
|
||||
Sheet = Material.SheetList[#Material.SheetList]
|
||||
@@ -947,6 +1007,10 @@ local function CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList
|
||||
--MachGroupName = "Sheet" .. nRaw1Id
|
||||
MachGroupName = EgtGetMachGroupNewName("M2_Sheet")
|
||||
MachGroupName = "M2Sheet" .. nMach2SheetId
|
||||
elseif MachId == 3 then
|
||||
nMach3SheetId = nMach3SheetId + 1
|
||||
MachGroupName = EgtGetMachGroupNewName("M3_Sheet")
|
||||
MachGroupName = "M3Sheet" .. nMach3SheetId
|
||||
else
|
||||
MachGroupName = "Sheet" .. #Material.SheetList + 1 --SheetCounter
|
||||
end
|
||||
@@ -956,10 +1020,14 @@ local function CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList
|
||||
-- end
|
||||
local bOk = EgtAddMachGroup(MachGroupName, sCurrMachName)
|
||||
-- se macchina 2 aggiungo info e riferimento a foglio della macchina 1
|
||||
if MachId ==2 then
|
||||
if MachId == 2 then
|
||||
EgtSetInfo(EgtGetCurrMachGroup(), 'MachId', MachId)
|
||||
local nOrigSheetId = EgtGetMachGroupId("Sheet" .. nMach2SheetId)
|
||||
EgtSetInfo(EgtGetCurrMachGroup(), 'OrigSheetId', nOrigSheetId)
|
||||
elseif MachId == 3 then
|
||||
EgtSetInfo(EgtGetCurrMachGroup(), 'MachId', MachId)
|
||||
local nOrigSheetId = EgtGetMachGroupId("Sheet" .. nMach3SheetId)
|
||||
EgtSetInfo(EgtGetCurrMachGroup(), 'OrigSheetId', nOrigSheetId)
|
||||
end
|
||||
-- imposto tavola
|
||||
local vtOffs = UtilityLib.SetupMachineTable(IsOffline)
|
||||
@@ -983,7 +1051,7 @@ local function CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList
|
||||
--EgtOutLog( string.format( ' Part %d pos=%f,%f rot=%f flip=%d', nId, dX, dY, dAngRot, nFlag))
|
||||
-- se ho un grezzo valido metto i pezzi
|
||||
local PartId = nId
|
||||
if MachId ~= 2 then
|
||||
if MachId ~= 2 and MachId ~= 3 then
|
||||
if nFlag ~= 0 then
|
||||
EgtMirror( PartId, ORIG(), Y_AX(), GDB_RT.GLOB)
|
||||
end
|
||||
@@ -1035,7 +1103,8 @@ function NestingLib.NestPartInRawPart(LastRaw, PartList, Material, ErrorList, Is
|
||||
EgtResetCurrMachGroup()
|
||||
|
||||
-- aggiungo tutti i pezzi al nesting
|
||||
AddPartListToNesting(PartList, ErrorList, Material)
|
||||
local BigPartsQty = 0
|
||||
BigPartsQty = AddPartListToNesting(PartList, ErrorList, Material, IsEstimate) or 0
|
||||
|
||||
-- ripristino MachGroup
|
||||
EgtSetCurrMachGroup(nOldMachGroup)
|
||||
@@ -1056,7 +1125,7 @@ function NestingLib.NestPartInRawPart(LastRaw, PartList, Material, ErrorList, Is
|
||||
dKerf = Config.Kerf[Index].Kerf
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- verifico se ultimo grezzo non nullo
|
||||
local LastMachGroupId = nil
|
||||
if LastRaw and LastRaw ~= GDB_ID.NULL then
|
||||
@@ -1086,6 +1155,30 @@ function NestingLib.NestPartInRawPart(LastRaw, PartList, Material, ErrorList, Is
|
||||
-- la aggiungo come difetto
|
||||
EgtAutoNestAddDefectToSheet(SheetPartId, nSheetLabel) -- EgtAutoNestAddDefectToSheet( SheetId, DefectId)
|
||||
else
|
||||
-- se ci sono pezzi grandi
|
||||
if BigPartsQty > 0 then
|
||||
-- creo un ugual numero di fogli senza etichetta
|
||||
local BigSheetPartId = EgtGroup(GDB_ID.ROOT)
|
||||
EgtSetName(BigSheetPartId, "Sheet")
|
||||
local BigSheetLayerId = EgtGroup(BigSheetPartId)
|
||||
EgtSetName(BigSheetLayerId, OUTLINE)
|
||||
local BigSheetOutlineId = EgtRectangle2P(BigSheetLayerId, Point3d(0,0,0), Point3d(Material.L_mm, Material.W_mm, 0), GDB_RT.GLOB)
|
||||
EgtModifyCurveThickness(BigSheetOutlineId, -Material.T_mm)
|
||||
EgtSetName(BigSheetOutlineId, OUTLINE)
|
||||
EgtAutoNestAddSheet( BigSheetPartId, BigSheetOutlineId, dKerf, 0, BigPartsQty) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
end
|
||||
-- se ci sono pezzi grandi
|
||||
-- if BigPartsQty > 0 then
|
||||
-- -- creo un ugual numero di fogli senza etichetta
|
||||
-- local BigSheetPartId = EgtGroup(GDB_ID.ROOT)
|
||||
-- EgtSetName(BigSheetPartId, "Sheet")
|
||||
-- local BigSheetLayerId = EgtGroup(BigSheetPartId)
|
||||
-- EgtSetName(BigSheetLayerId, OUTLINE)
|
||||
-- local BigSheetOutlineId = EgtRectangle2P(BigSheetLayerId, Point3d(0,0,0), Point3d(Material.L_mm, Material.W_mm, 0), GDB_RT.GLOB)
|
||||
-- EgtModifyCurveThickness(BigSheetOutlineId, -Material.T_mm)
|
||||
-- EgtSetName(BigSheetOutlineId, OUTLINE)
|
||||
-- EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, dKerf, 0, BigPartsQty) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
-- end
|
||||
-- creo etichetta dello sheet
|
||||
local dLabelW = 50
|
||||
local dLabelH = 25
|
||||
@@ -1096,7 +1189,7 @@ function NestingLib.NestPartInRawPart(LastRaw, PartList, Material, ErrorList, Is
|
||||
local nSheetLabel = EgtRectangle2P(SheetLayerId, Point3d(0, dYPos - dLabelH,0), Point3d(dLabelW, dYPos, 0), GDB_RT.GLOB)
|
||||
EgtSetName(nSheetLabel, SHEETLABEL)
|
||||
-- creo foglio per nesting
|
||||
EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, dKerf, 0, 50) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, dKerf, 0, 1000) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
-- aggiungo etichetta come difetto
|
||||
EgtAutoNestAddDefectToSheet(SheetPartId, nSheetLabel) -- EgtAutoNestAddDefectToSheet( SheetId, DefectId)
|
||||
end
|
||||
@@ -1155,15 +1248,18 @@ function NestingLib.NestPartInRawPart(LastRaw, PartList, Material, ErrorList, Is
|
||||
if not IsOffline and not IsEstimate and not IsValidation then
|
||||
LastRaw2 = CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList, 2, LastRaw, FirstMachIndex)
|
||||
EgtSetInfo(LastRaw, 'LastRaw2', LastRaw2)
|
||||
LastRaw3 = CreateMachSheets(LastMachGroupId, SheetPartId, Material, PartList, 3, LastRaw, FirstMachIndex)
|
||||
EgtSetInfo(LastRaw, 'LastRaw3', LastRaw3)
|
||||
end
|
||||
-- se impostata seconda macchina, reimposto la prima
|
||||
local sMachName = EgtGetCurrMachineName()
|
||||
if sMachName == 'Multiax-NE_Nest02' then
|
||||
if sMachName == 'Multiax-NE_Nest02' or sMachName == 'Multiax-NE_Nest03' then
|
||||
SetMachineByIndex(1)
|
||||
end
|
||||
else
|
||||
table.insert(ErrorList, {ErrType = "E.10", Uid = "Generic", Description = "Error in nesting function!"})
|
||||
end
|
||||
--EgtSaveFile("c://Temp//TestSauderBigParts.nge")
|
||||
-- ritorno l'ultimo grezzo utilizzato
|
||||
return LastRaw
|
||||
end
|
||||
@@ -1318,7 +1414,7 @@ function NestingLib.VerifyPath(Folder, BatchId, Material, MachId)
|
||||
end
|
||||
end
|
||||
-- scelgo nome cartella macchina
|
||||
if MachId == 0 or MachId == 1 or MachId == 2 then
|
||||
if MachId == 0 or MachId == 1 or MachId == 2 or MachId == 3 then
|
||||
local MachDirName = ''
|
||||
if MachId == 0 then
|
||||
MachDirName = '##REPLACEME##'
|
||||
@@ -1326,6 +1422,8 @@ function NestingLib.VerifyPath(Folder, BatchId, Material, MachId)
|
||||
MachDirName = 'NE01'
|
||||
elseif MachId == 2 then
|
||||
MachDirName = 'NE02'
|
||||
elseif MachId == 3 then
|
||||
MachDirName = 'NE03'
|
||||
end
|
||||
CurrPath = CurrPath .. "/".. MachDirName
|
||||
if not UtilityLib.FolderExists(CurrPath) then
|
||||
@@ -1348,13 +1446,13 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
local PartsPriority = {}
|
||||
local CurrMachGroupId = EgtGetMachGroupId(Material.SheetList[Sheet].MachGroupName)
|
||||
-- se seconda macchina, imposto gruppo di lavorazione copia
|
||||
if MachId == 2 then
|
||||
if MachId == 2 or MachId == 3 then
|
||||
-- recupero id grezzo originale
|
||||
local nRawPartId = EgtGetFirstRawPart()
|
||||
-- cerco gruppo copia con id grezzo originale
|
||||
local nMachGroupId = EgtGetFirstMachGroup()
|
||||
while nMachGroupId do
|
||||
if EgtGetInfo(nMachGroupId, 'OrigSheetId', 'i') == CurrMachGroupId and EgtGetInfo(nMachGroupId, 'MachId', 'i') == 2 then
|
||||
if EgtGetInfo(nMachGroupId, 'OrigSheetId', 'i') == CurrMachGroupId and EgtGetInfo(nMachGroupId, 'MachId', 'i') == MachId then
|
||||
EgtSetCurrMachGroup(nMachGroupId)
|
||||
end
|
||||
nMachGroupId = EgtGetNextMachGroup(nMachGroupId)
|
||||
@@ -1388,7 +1486,7 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
else
|
||||
PartsArea = CreateMachByOrderedType(Material, CurrRawPart, PartsBBox, nSkeletonLayerId, PartsPriority, ErrorList)
|
||||
end
|
||||
if MachId ~= 2 then
|
||||
if MachId ~= 2 and MachId ~= 3 then
|
||||
-- imposto area totale dei pezzi
|
||||
Material.SheetList[Sheet].SurfaceWork = PartsArea
|
||||
-- calcolo area esterna
|
||||
@@ -1599,7 +1697,7 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
EgtApplyAllMachinings()
|
||||
-- aggiorno lavorazione un'altra volta per migliorare posizioni eventuali tab
|
||||
EgtApplyAllMachinings()
|
||||
if MachId ~= 2 then
|
||||
if MachId ~= 2 and MachId ~= 3 then
|
||||
-- ricavo stime
|
||||
local CurrEstimatePath = NestingLib.VerifyPath("Estimate", BatchId, Material)
|
||||
if not UtilityLib.FolderExists(CurrEstimatePath) then
|
||||
@@ -1632,7 +1730,7 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
else
|
||||
CurrCNCPath = CurrCNCPath .. "/" .. Material.SheetList[Sheet].MachGroupName .. ".cnc"
|
||||
end
|
||||
if MachId == 2 then
|
||||
if MachId == 2 or MachId == 3 then
|
||||
Material.SheetList[Sheet].MachiningProgram = DBCurrCNCPath .. "/" .. Material.SheetList[Sheet].MachGroupName .. ".cnc"
|
||||
else
|
||||
Material.SheetList[Sheet].MachiningProgram = CurrCNCPath
|
||||
@@ -1651,7 +1749,7 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
EgtCreateDirectory(CurrPrintPath)
|
||||
end
|
||||
CurrPrintPath = CurrPrintPath .. "/" .. Material.SheetList[Sheet].MachGroupName .. ".cnc"
|
||||
if MachId == 2 then
|
||||
if MachId == 2 or MachId == 3 then
|
||||
Material.SheetList[Sheet].PrintProgram = DBCurrPrintPath .. "/" .. Material.SheetList[Sheet].MachGroupName .. ".cnc"
|
||||
else
|
||||
Material.SheetList[Sheet].PrintProgram = CurrPrintPath
|
||||
@@ -1659,7 +1757,7 @@ function NestingLib.PostNestOp(Material, ErrorList, IsEstimate, BatchId, MachId)
|
||||
bOk = EgtCopyFile(CurrPrintCNCPath, CurrPrintPath)
|
||||
bOk = EgtEraseFile(CurrPrintCNCPath)
|
||||
end
|
||||
if MachId ~= 2 then
|
||||
if MachId ~= 2 and MachId ~= 3 then
|
||||
-- salvo svg del grezzo
|
||||
local CurrSVGPath = NestingLib.VerifyPath("SVG", BatchId, Material)
|
||||
if not UtilityLib.FolderExists(CurrSVGPath) then
|
||||
@@ -1747,10 +1845,12 @@ end
|
||||
end
|
||||
-- scrittura delle linee modificate
|
||||
local fh2 = io.open( LabelSVGPath, 'w')
|
||||
for i = 1, #Lines do
|
||||
fh2:write( Lines[i] .. '\n')
|
||||
if fh2 then
|
||||
for i = 1, #Lines do
|
||||
fh2:write( Lines[i] .. '\n')
|
||||
end
|
||||
fh2:close()
|
||||
end
|
||||
fh2:close()
|
||||
-- fine
|
||||
end
|
||||
|
||||
@@ -1841,7 +1941,7 @@ function CreateMachByType(Material, CurrRawPart, PartsBBox, nSkeletonLayerId, Pa
|
||||
EgtSetName(CutPartsArea, PARTCUTSUM)
|
||||
else
|
||||
if not nPartSurfId then
|
||||
x = 2
|
||||
local x = 2
|
||||
end
|
||||
EgtSurfFrAdd(CutPartsArea, nPartSurfId)
|
||||
end
|
||||
@@ -2433,6 +2533,7 @@ function CalcPartMachinings(Material, CurrPart, bInternalPart, LastMch, nMachTyp
|
||||
EgtSetMachiningParam(MCH_MP.OFFSR, dRadial)
|
||||
EgtSetMachiningParam(MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- applico la lavorazione
|
||||
local bValidOutlineMach = false
|
||||
if EgtApplyMachining() then
|
||||
bValidOutlineMach = true
|
||||
InitInTSP(NewMachId, InternalOutlineList, 0)
|
||||
@@ -2479,6 +2580,7 @@ function CalcPartMachinings(Material, CurrPart, bInternalPart, LastMch, nMachTyp
|
||||
EgtSetMachiningParam(MCH_MP.OFFSR, dRadial)
|
||||
EgtSetMachiningParam(MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
|
||||
-- applico la lavorazione
|
||||
local bValidOutlineMach = false
|
||||
if EgtApplyMachining() then
|
||||
bValidOutlineMach = true
|
||||
InitInTSP(NewMachId, InternalOutlineList, 0)
|
||||
@@ -2526,6 +2628,7 @@ function CalcPartMachinings(Material, CurrPart, bInternalPart, LastMch, nMachTyp
|
||||
EgtSetMachiningParam(MCH_MP.OFFSR, dRadial)
|
||||
EgtSetMachiningParam(MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- applico la lavorazione
|
||||
local bValidOutlineMach = false
|
||||
if EgtApplyMachining() then
|
||||
bValidOutlineMach = true
|
||||
InitInTSP(NewMachId, InternalOutlineList, 0)
|
||||
|
||||
Reference in New Issue
Block a user