DataWall :
- aggiunta gestione feature DoubleCut - aggiunta gestione feature SawCut - modifica gestione FreeContour con una sola faccia - correzioni per nesting pareti.
This commit is contained in:
+113
-66
@@ -1,4 +1,4 @@
|
||||
-- NestProcess.lua by Egaltech s.r.l. 2021/02/13
|
||||
-- NestProcess.lua by Egaltech s.r.l. 2021/05/16
|
||||
-- Gestione nesting automatico pareti
|
||||
|
||||
-- Intestazioni
|
||||
@@ -12,7 +12,7 @@ EgtEnableDebug( false)
|
||||
--NEST.MACHINE = 'Essetre-90480019_MW'
|
||||
--NEST.FLAG = 3
|
||||
|
||||
local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. NEST.PANELLEN .. ', ' .. NEST.PANELWIDTH
|
||||
local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. NEST.LEN .. ', ' .. NEST.WIDTH
|
||||
EgtOutLog( sLog)
|
||||
|
||||
-- Cancello file di log specifico
|
||||
@@ -87,6 +87,28 @@ end
|
||||
local sBaseDir = EgtGetSourceDir()
|
||||
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Pareti
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
if not EgtExistsFile( sMachDir .. '\\Wall\\WallData.lua') then
|
||||
WALL.ERR = 12
|
||||
WALL.MSG = 'Error not configured for walls machine : ' .. sMachine
|
||||
WriteErrToLogFile( WALL.ERR, WALL.MSG)
|
||||
PostErrView( WALL.ERR, WALL.MSG)
|
||||
return
|
||||
end
|
||||
|
||||
-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie
|
||||
EgtRemoveBaseMachineDirFromPackagePath()
|
||||
EgtAddToPackagePath( sMachDir .. '\\Wall\\?.lua')
|
||||
|
||||
-- Carico le librerie
|
||||
_G.package.loaded.WallExec = nil
|
||||
local WE = require( 'WallExec')
|
||||
_G.package.loaded.WallLib = nil
|
||||
local WL = require( 'WallLib')
|
||||
_G.package.loaded.WProcessLapJoint = nil
|
||||
local LapJoint = require( 'WProcessLapJoint')
|
||||
|
||||
-- Inizializzo contatori errori e avvisi
|
||||
local nErrCnt = 0
|
||||
local nWarnCnt = 0
|
||||
@@ -100,18 +122,42 @@ 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.PANELLEN, NEST.PANELWIDTH, 0), GDB_RT.GLOB)
|
||||
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, 20, 0, 50) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, NEST.KERF, 0, 50) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount)
|
||||
|
||||
-- ciclo su pezzi per aggiungerli al nesting
|
||||
for nPartId, nCount in pairs( PART) do
|
||||
-- verifico se ruotare pareti
|
||||
-- recupero le feature di lavorazione della parete
|
||||
local bFtDown = false
|
||||
local vPartProc = WE.CollectFeatures( nPartId, b3Raw)
|
||||
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
|
||||
local vtN = EgtSurfTmFacetNormVersor( vPartProc[nInd].Id, nFacOpt, GDB_ID.ROOT)
|
||||
if vtN:getZ() < -0.09 then
|
||||
bFtDown = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- ruoto se necessario
|
||||
if bFtDown then
|
||||
local b3Solid = EgtGetBBoxGlob(nPartId, GDB_BB.IGNORE_TEXT)
|
||||
local ptRotCen = b3Solid:getCenter()
|
||||
EgtRotate( nPartId, ptRotCen, X_AX(), 180, GDB_RT.GLOB)
|
||||
end
|
||||
|
||||
-- recupero contorno
|
||||
local nOutlineLayer = EgtGetFirstNameInGroup(nPartId, "Outline")
|
||||
local nOutline = GDB_ID.NULL
|
||||
local nTrimesh = GDB_ID.NULL
|
||||
local nOutline
|
||||
local nTrimesh
|
||||
local bFirst = true
|
||||
local bSecond = false
|
||||
local bUseBox = false
|
||||
@@ -125,48 +171,53 @@ for nPartId, nCount in pairs( PART) do
|
||||
if not nTrimesh then
|
||||
nTrimesh = EgtGetFirstNameInGroup( nOutlineLayer, "4-Out")
|
||||
end
|
||||
local nAuxId = EgtGetInfo(nTrimesh, "AUXID", 'i')
|
||||
nOutline = nTrimesh + nAuxId
|
||||
|
||||
|
||||
-- local nIndex = EgtGetFirstInGroup(nOutlineLayer)
|
||||
-- while nIndex do
|
||||
-- local nType = EgtGetType(nIndex)
|
||||
-- if nType == GDB_TY.CRV_COMPO then
|
||||
-- nOutline = nIndex
|
||||
-- if bFirst then
|
||||
-- bFirst = false
|
||||
-- else
|
||||
-- bSecond = true
|
||||
-- end
|
||||
-- elseif nType == GDB_TY.SRF_MESH then
|
||||
-- nTrimesh = nIndex
|
||||
-- end
|
||||
-- nIndex = EgtGetNext(nIndex)
|
||||
-- end
|
||||
-- se c'è solo una compo verifico se ha lati inclinati
|
||||
-- if not bSecond then
|
||||
local nFacetCount = EgtSurfTmFacetCount(nTrimesh)
|
||||
for nIndex = 0, nFacetCount - 1 do
|
||||
local vtNorm = EgtSurfTmFacetNormVersor(nTrimesh, nIndex, GDB_ID.ROOT)
|
||||
if abs( vtNorm:getZ()) > 10 * GEO.EPS_SMALL then
|
||||
bUseBox = true
|
||||
break
|
||||
-- se trovato contorno
|
||||
if nTrimesh then
|
||||
-- recupero la curva associata
|
||||
local nAuxId = EgtGetInfo(nTrimesh, "AUXID", 'i')
|
||||
nOutline = nTrimesh + nAuxId
|
||||
-- verifico che il contorno sia verticale
|
||||
local nFacetCount = EgtSurfTmFacetCount(nTrimesh)
|
||||
for nIndex = 0, nFacetCount - 1 do
|
||||
local vtNorm = EgtSurfTmFacetNormVersor(nTrimesh, nIndex, GDB_ID.ROOT)
|
||||
if abs( vtNorm:getZ()) > 10 * GEO.EPS_SMALL then
|
||||
bUseBox = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- se due compo o una e lati inclinati
|
||||
if bUseBox then
|
||||
-- calcolo box della trimesh
|
||||
local b3Outline = EgtGetBBoxGlob(nTrimesh, GDB_BB.IGNORE_TEXT)
|
||||
local ptP1 = Point3d( b3Outline:getMin():getX(), b3Outline:getMin():getY(), 0)
|
||||
local ptP2 = Point3d( b3Outline:getMax():getX(), b3Outline:getMax():getY(), 0)
|
||||
-- creo outline del box
|
||||
nOutline = EgtRectangle2P(nOutlineLayer, ptP1, ptP2, GDB_RT.GLOB)
|
||||
EgtSetStatus(nOutline, GDB_ST.OFF)
|
||||
end
|
||||
-- altrimenti cerco la regione sopra
|
||||
else
|
||||
local nReg
|
||||
for i = 1, 4 do
|
||||
local sRegName = string.format( '%d-Top', i)
|
||||
nReg = EgtGetFirstNameInGroup( nOutlineLayer, sRegName)
|
||||
if nReg then
|
||||
local vtNorm = EgtSurfFrNormVersor( nReg, GDB_ID.ROOT)
|
||||
if vtNorm:getZ() > 0.99 then break end
|
||||
end
|
||||
end
|
||||
if not nReg then
|
||||
EgtOutLog("Errore: regione superiore non trovata")
|
||||
end
|
||||
local OutId, nCnt = EgtExtractSurfFrChunkLoops( nReg, 0, nOutlineLayer)
|
||||
if OutId and nCnt > 1 then
|
||||
for i = 2, nCnt do
|
||||
EgtErase( OutId + i - 1)
|
||||
end
|
||||
end
|
||||
nOutline = OutId
|
||||
end
|
||||
-- else
|
||||
-- bUseBox = true
|
||||
-- end
|
||||
-- se due compo o una e lati inclinati
|
||||
if bUseBox then
|
||||
-- calcolo box della trimesh
|
||||
local b3Outline = EgtGetBBoxGlob(nTrimesh, GDB_BB.IGNORE_TEXT)
|
||||
local ptP1 = Point3d( b3Outline:getMin():getX(), b3Outline:getMin():getY(), 0)
|
||||
local ptP2 = Point3d( b3Outline:getMax():getX(), b3Outline:getMax():getY(), 0)
|
||||
-- creo outline del box
|
||||
nOutline = EgtRectangle2P(nOutlineLayer, ptP1, ptP2, GDB_RT.GLOB)
|
||||
EgtSetStatus(nOutline, GDB_ST.OFF)
|
||||
end
|
||||
|
||||
if nOutline then
|
||||
-- aggiungo pezzo al nesting
|
||||
EgtAutoNestAddPart( nPartId, nOutline, false, true, 90, 0, nCount)
|
||||
@@ -175,7 +226,7 @@ for nPartId, nCount in pairs( PART) do
|
||||
end
|
||||
|
||||
-- aggiungo offset tra pezzi
|
||||
EgtAutoNestSetInterpartGap(50)
|
||||
EgtAutoNestSetInterpartGap(NEST.OFFSET)
|
||||
|
||||
-- Impostazione corner di inizio del nesting (NST_CORNER.BL, TL, BR, TR)
|
||||
EgtAutoNestSetStartCorner( NST_CORNER.BR)
|
||||
@@ -221,33 +272,27 @@ if bOk then
|
||||
-- creo gruppo di lavorazione
|
||||
local MachGroupName = NewMachGroupName()
|
||||
nMachGroup = EgtAddMachGroup(MachGroupName, sCurrMachName)
|
||||
EgtSetInfo(nMachGroup, "PANELLEN", NEST.PANELLEN)
|
||||
EgtSetInfo(nMachGroup, "PANELWIDTH", NEST.PANELWIDTH)
|
||||
EgtSetInfo(nMachGroup, "PANELLEN", NEST.LEN)
|
||||
EgtSetInfo(nMachGroup, "PANELWIDTH", NEST.WIDTH)
|
||||
EgtSetInfo(nMachGroup, "AUTONEST", 1)
|
||||
nPartCount = 0
|
||||
-- altrimenti pezzo
|
||||
else
|
||||
local PartId = nId
|
||||
nPartCount = nPartCount + 1
|
||||
-- if nFlag ~= 0 then
|
||||
-- EgtMirror( PartId, ORIG(), Y_AX(), GDB_RT.GLOB)
|
||||
-- end
|
||||
-- EgtRotate( PartId, ORIG(), Z_AX(), dAngRot, GDB_RT.GLOB)
|
||||
-- EgtMove( PartId, Vector3d( dX, dY, 0) + vtAdd, GDB_RT.GLOB)
|
||||
-- se c'e' un grezzo valido
|
||||
if nMachGroup and nMachGroup ~= GDB_ID.NULL then
|
||||
-- creo pezzo copia
|
||||
local nPartDuploId = EgtDuploNew(nId)
|
||||
local nPartDuploId = EgtDuploNew( nId)
|
||||
EgtRotate( nPartDuploId, ORIG(), Z_AX(), dAngRot, GDB_RT.GLOB)
|
||||
EgtMove( nPartDuploId, Vector3d( dX, dY, 0), GDB_RT.GLOB)
|
||||
local PartBBox = EgtGetBBoxGlob(nPartDuploId, GDB_BB.STANDARD)
|
||||
-- local ptPos = Point3d(PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0)
|
||||
EgtSetInfo(nMachGroup, "PART" .. nPartCount, nPartDuploId .. "," .. PartBBox:getMin():getX() .. "," .. PartBBox:getMin():getY().. "," .. 0 .. "," .. 0)
|
||||
-- EgtSetInfo(nMachGroup, "PART" .. nPartCount, nId .. "," .. 10 .. "," .. 10 .. "," .. 0 .. "," .. 0)
|
||||
|
||||
-- local PartBBox = EgtGetBBoxGlob(PartId, GDB_BB.STANDARD)
|
||||
-- local ptPos = Point3d(PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0)
|
||||
-- local bOk = EgtAddPartToRawPart(PartId, ptPos, nRawId)
|
||||
local PartBBox = EgtGetBBoxGlob( nPartDuploId, GDB_BB.STANDARD)
|
||||
local ptPos = Point3d( PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0)
|
||||
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, "FLIP", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -261,16 +306,18 @@ if bOk then
|
||||
while nMachGroup do
|
||||
EgtSetCurrMachGroup(nMachGroup)
|
||||
if EgtGetInfo(nMachGroup, "AUTONEST",'i') == 1 then
|
||||
EgtSetInfo(nMachGroup, "AUTONEST", "")
|
||||
EgtRemoveInfo(nMachGroup, "AUTONEST")
|
||||
EgtSetInfo(nMachGroup, "UPDATEUI", 1)
|
||||
dofile(EgtGetSourceDir() .. "BatchProcessNew.lua")
|
||||
end
|
||||
nMachGroup = EgtGetNextMachGroup(nMachGroup)
|
||||
end
|
||||
|
||||
else
|
||||
EgtOutLog("Errore: nesting fallito")
|
||||
end
|
||||
|
||||
EgtResetCurrMachGroup()
|
||||
-- nascondo rettangolo
|
||||
-- nascondo rettangolo del materiale per nesting
|
||||
EgtErase(SheetPartId)
|
||||
-- EgtSaveFile("c:\\Temp\\Prova1.nge")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user