WallData :

- corretta pulitura spigoli su svuotatura di FreeContour
- modifiche varie per nesting.
This commit is contained in:
DarioS
2021-10-05 12:33:58 +02:00
parent f3e0cc8c68
commit b82c3fb644
2 changed files with 137 additions and 21 deletions
+135 -20
View File
@@ -12,7 +12,7 @@ EgtEnableDebug( false)
--NEST.MACHINE = 'Essetre-90480019_MW'
--NEST.FLAG = 3
local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. NEST.LEN .. ', ' .. NEST.WIDTH
local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. LEN["1"] .. ', ' .. WIDTH["1"]
EgtOutLog( sLog)
-- Cancello file di log specifico
@@ -108,27 +108,51 @@ _G.package.loaded.WallLib = nil
local WL = require( 'WallLib')
_G.package.loaded.WProcessLapJoint = nil
local LapJoint = require( 'WProcessLapJoint')
-- Carico i dati globali
local WD = require( 'WallData')
-- Inizializzo contatori errori e avvisi
local nErrCnt = 0
local nWarnCnt = 0
-- resetto gruppo di lavorazione corrente
EgtResetCurrMachGroup()
-- inizio nesting automatico
EgtAutoNestStart()
-- creo tabella dei grezzi
local RawParts = {}
for nIndex, nLen in pairs( LEN) do
table.insert(RawParts, {Len = nLen})
end
for nIndex, nWidth in pairs( WIDTH) do
RawParts[tonumber(nIndex)].Width = nWidth
end
for nIndex, nQty in pairs( QTY) do
RawParts[tonumber(nIndex)].Qty = nQty
end
for nIndex, nMaterial in pairs( MATERIAL) do
RawParts[tonumber(nIndex)].Material = nMaterial
end
local SheetPartIdList = {}
local OUTLINE = "Outline"
-- creo pannello del materiale
local SheetPartId = EgtGroup(GDB_ID.ROOT)
EgtSetName(SheetPartId, "Sheet")
local SheetLayerId = EgtGroup(SheetPartId)
EgtSetName(SheetLayerId, OUTLINE)
local SheetOutlineId = EgtRectangle2P(SheetLayerId, Point3d(0,0,0), Point3d(NEST.LEN, NEST.WIDTH, 0), GDB_RT.GLOB)
-- EgtModifyCurveThickness(SheetOutlineId, -Material.T_mm)
EgtSetName(SheetOutlineId, OUTLINE)
-- creo foglio per nesting
EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, NEST.KERF, 0, NEST.QTY) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
for nIndex = 1, #RawParts do
-- creo pannello del materiale
local SheetPartId = EgtGroup(GDB_ID.ROOT)
table.insert(SheetPartIdList, SheetPartId)
EgtSetName(SheetPartId, "Sheet")
local SheetLayerId = EgtGroup(SheetPartId)
EgtSetName(SheetLayerId, OUTLINE)
local SheetOutlineId = EgtRectangle2P(SheetLayerId, Point3d(0,0,0), Point3d(RawParts[nIndex].Len, RawParts[nIndex].Width, 0), GDB_RT.GLOB)
-- EgtModifyCurveThickness(SheetOutlineId, -Material.T_mm)
EgtSetName(SheetOutlineId, OUTLINE)
-- creo foglio per nesting
EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, NEST.KERF, 0, RawParts[nIndex].Qty) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
end
-- ciclo su pezzi per aggiungerli al nesting
for nPartId, nCount in pairs( PART) do
-- verifico se ruotare pareti
@@ -138,7 +162,7 @@ for nPartId, nCount in pairs( PART) do
for nInd = 1, #vPartProc do
if LapJoint.Identify( vPartProc[nInd]) then
local nFacOpt, dMinElev, nFacOpt2, dMinElev2 = WL.GetFaceWithMostAdj( vPartProc[nInd].Id, vPartProc[nInd].PartId)
if nFacOpt then
if nFacOpt >= 0 then
local vtN = EgtSurfTmFacetNormVersor( vPartProc[nInd].Id, nFacOpt, GDB_ID.ROOT)
if vtN:getZ() < -0.09 then
bFtDown = true
@@ -156,7 +180,96 @@ for nPartId, nCount in pairs( PART) do
-- recupero contorno
local nOutlineLayer = EgtGetFirstNameInGroup(nPartId, "Outline")
local nOutline
-- elimino vecchio contorno se gia' presente
local nOldOutline = EgtGetFirstNameInGroup(nOutlineLayer, 'ON_TMP')
EgtErase(nOldOutline or GDB_ID.NULL)
-- Recupero o ricalcolo il solido
local SolidId = EgtBeamGetSolid( nPartId)
if not SolidId or not EgtGetInfo( SolidId, 'VALID') then
EgtBeamCalcSolid( nPartId, true)
SolidId = EgtBeamGetSolid( nPartId)
end
local nOutline, nCnt = EgtGetSurfTmSilhouette( SolidId, Z_AX(), 10, nOutlineLayer, GDB_RT.GLOB)
EgtBeamShowSolid( nPartId, false)
EgtSaveFile("c:\\Temp\\ProvaNesting.nge")
local nCurrOutline = nOutline
if nCnt > 0 then
local frSum
EgtScale( nOutline, GLOB_FRM(), 1, 1, 0, GDB_RT.GLOB)
EgtModifyCurveExtrusion( nOutline, Z_AX(), GDB_RT.GLOB)
--local frSum = EgtSurfFlatRegion(nOutlineLayer, nOutline)
--EgtSaveFile("c:\\Temp\\ProvaNesting.nge")
-- -- per ogni contorno creo flat region e le sommo
-- for nIndex = 0, nCnt - 1 do
-- EgtScale( nOutline + nIndex, GLOB_FRM(), 1, 1, 0, GDB_RT.GLOB)
-- EgtModifyCurveExtrusion( nOutline + nIndex, Z_AX(), GDB_RT.GLOB)
-- local frCurr = EgtSurfFlatRegion(nOutlineLayer, nOutline + nIndex)
-- if frCurr then
-- if frSum then
-- EgtSurfFrAdd(frSum, frCurr)
-- else
-- frSum = frCurr
-- end
-- end
-- EgtErase(frCurr)
-- end
-- --EgtSaveFile("c:/Temp/ProvaNesting.nge")
-- -- calcolo contorno della flat region somma
-- nCurrOutline = EgtExtractSurfFrChunkLoops(frSum, 0, nOutlineLayer)
-- EgtErase(frSum)
-- -- cancello contorni
-- for nIndex = 0, nCnt do
-- EgtErase(nOutline + nIndex)
-- end
end
if nCurrOutline and nCurrOutline ~= GDB_ID.NULL then
nOutline = nCurrOutline
else
-- se non ho trovato contorno, lo recupero dal Box
local nBoxLayer = EgtGetFirstNameInGroup(nPartId, "Box")
local nBox = EgtGetFirstNameInGroup(nBoxLayer, "Box")
local BBox = EgtGetBBoxGlob(nBox, GDB_BB.STANDARD)
nOutline = EgtRectangle2P(nOutlineLayer, Point3d( BBox:getMin():getX(), BBox:getMin():getY(), 0), Point3d( BBox:getMax():getX(), BBox:getMax():getY(), 0), GDB_RT.GLOB)
EgtOutLog("Impossible creating silhouette for part " .. tostring(nPartId))
end
--if nCnt == 0 then
-- -- se non ho trovato contorno, lo recupero dal Box
-- local nBoxLayer = EgtGetFirstNameInGroup(nPartId, "Box")
-- local nBox = EgtGetFirstNameInGroup(nBoxLayer, "Box")
-- local BBox = EgtGetBBoxGlob(nBox, GDB_BB.STANDARD)
-- nOutline = EgtRectangle2P(nOutlineLayer, Point3d( BBox:getMin():getX(), BBox:getMin():getY(), 0), Point3d( BBox:getMax():getX(), BBox:getMax():getY(), 0), GDB_RT.GLOB)
-- EgtOutLog("Impossible creating silhouette for part " .. tostring(nPartId))
--else
-- --EgtScale( nOutline, GLOB_FRM(), 1, 1, 0, GDB_RT.GLOB)
-- --EgtModifyCurveExtrusion( nOutline, Z_AX(), GDB_RT.GLOB)
-- --EgtSaveFile("c:/Temp/ProvaNesting.nge")
-- EgtScale( nOutline, GLOB_FRM(), 1, 1, 0, GDB_RT.GLOB)
-- EgtModifyCurveExtrusion( nOutline, Z_AX(), GDB_RT.GLOB)
-- local frSum = EgtSurfFlatRegion(nOutlineLayer, nOutline)
-- EgtSaveFile("c:\\Temp\\ProvaNesting.nge")
-- -- per ogni contorno creo flat region e le sommo
-- for nIndex = 1, nCnt - 1 do
-- EgtScale( nOutline + nIndex, GLOB_FRM(), 1, 1, 0, GDB_RT.GLOB)
-- EgtModifyCurveExtrusion( nOutline + nIndex, Z_AX(), GDB_RT.GLOB)
-- local frCurr = EgtSurfFlatRegion(nOutlineLayer, nOutline + nIndex)
-- if frCurr then
-- EgtSurfFrAdd(frSum, frCurr)
-- end
-- end
-- -- calcolo contorno della flat region somma
-- nOutline = EgtExtractSurfFrChunkLoops(frSum, 0, nOutlineLayer)
-- -- cancello contorni successivi
-- for nIndex = 1, nCnt do
-- EgtErase(nOutline + nIndex)
-- end
--end
EgtSetName( nOutline, 'ON_TMP')
--[[ local nOutline
local nTrimesh
local bFirst = true
local bSecond = false
@@ -227,7 +340,7 @@ for nPartId, nCount in pairs( PART) do
nOutline = OutId
end
end
]]--
if nOutline then
-- aggiungo pezzo al nesting
EgtAutoNestAddPart( nPartId, nOutline, false, true, 90, 0, nCount)
@@ -282,9 +395,9 @@ if bOk then
-- creo gruppo di lavorazione
local MachGroupName = NewMachGroupName()
nMachGroup = EgtAddMachGroup(MachGroupName, sCurrMachName)
EgtSetInfo(nMachGroup, "PANELLEN", NEST.LEN)
EgtSetInfo(nMachGroup, "PANELWIDTH", NEST.WIDTH)
EgtSetInfo(nMachGroup, "MATERIAL", NEST.MATERIAL)
EgtSetInfo(nMachGroup, "PANELLEN", RawParts[nType].Len)
EgtSetInfo(nMachGroup, "PANELWIDTH", RawParts[nType].Width)
EgtSetInfo(nMachGroup, "MATERIAL", RawParts[nType].Material)
EgtSetInfo(nMachGroup, "AUTONEST", 1)
nPartCount = 0
-- altrimenti pezzo
@@ -302,7 +415,7 @@ if bOk then
EgtSetInfo( nMachGroup, "PART" .. nPartCount, nPartDuploId .. "," .. EgtNumToString( ptPos:getX(), 3) .. "," .. EgtNumToString( ptPos:getY(), 3) .. "," .. 0 .. "," .. 0)
EgtSetInfo( nPartDuploId, "POSX", ptPos:getX())
EgtSetInfo( nPartDuploId, "POSY", ptPos:getY())
EgtSetInfo( nPartDuploId, "ROT", 0)
EgtSetInfo( nPartDuploId, "ROT", dAngRot)
EgtSetInfo( nPartDuploId, "FLIP", 0)
end
end
@@ -329,7 +442,9 @@ end
EgtResetCurrMachGroup()
-- nascondo rettangolo del materiale per nesting
EgtErase(SheetPartId)
for SheetPartId = 1, #SheetPartIdList do
EgtErase(SheetPartIdList[SheetPartId])
end
-- EgtSaveFile("c:\\Temp\\Prova1.nge")
EgtOutLog( ' +++ NestProcess completed')