From d5f77ee59e206ba3f39a1e346fa5c37c86df49c1 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 6 Jun 2022 08:06:01 +0200 Subject: [PATCH] 3dPrinting : - in posizionamento pezzo sulla tavola della macchina verifico che la macchina sia per stampa 3d. --- LuaLibs/CalcSlices.lua | 5 +++-- LuaLibs/RunPartPositioning.lua | 40 ++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/LuaLibs/CalcSlices.lua b/LuaLibs/CalcSlices.lua index 2be81dd..ea38bbc 100644 --- a/LuaLibs/CalcSlices.lua +++ b/LuaLibs/CalcSlices.lua @@ -53,8 +53,8 @@ function CalcSlices.Exec( nPartId, nStmId, HMax) local dZmin = b3Box:getMin():getZ() local dZmax = b3Box:getMax():getZ() dZmax = min( dZmax, dZmin + HMax) - ---dZmin = 740 - ---dZmax = 741 + --dZmin = 1022 + --dZmax = 1023 -- se slicing giĆ  presente lo cancello for i = 1, 2 do @@ -70,6 +70,7 @@ function CalcSlices.Exec( nPartId, nStmId, HMax) local nLayCnt = 1 local nRecalc = 0 local dDeltaZStart = 0.2 + --dDeltaZStart = 0 local vZSlices = ComputeZSlices( dZmin, dDeltaZStart, dZmax) local nLayId = EgtParPlanesSurfTmInters( ORIG(), Z_AX(), vZSlices, nStmId, nPartId, GDB_RT.GLOB, TOLER) local vErr = {} diff --git a/LuaLibs/RunPartPositioning.lua b/LuaLibs/RunPartPositioning.lua index 4a2452a..4f4472e 100644 --- a/LuaLibs/RunPartPositioning.lua +++ b/LuaLibs/RunPartPositioning.lua @@ -1,4 +1,4 @@ --- RunPartPositioning.lua by Egaltech s.r.l. 2022/05/19 +-- RunPartPositioning.lua by Egaltech s.r.l. 2022/05/28 -- Gestione calcolo disposizione e lavorazioni per stampa 3d -- 2022/03/21 Creazione file @@ -13,7 +13,14 @@ EgtOutLog( ' RunPartPositioning started', 1) -- Costanti generali local AMD = require( 'AddManData') -function RunPartPositioning.Exec() +function RunPartPositioning.Exec() + -- Verifico che la macchina corrente sia adatta alla stampa 3d + local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini' + local sMachMaterial = EgtGetStringFromIni( 'General', 'Material', '', sMachIni) + if sMachMaterial ~= 'Additive' then + EgtOutBox( 'Current machine unsuitable for additive manufacturing', 'Warning', 'WARNING') + return + end -- Recupero ultimo oggetto selezionato local nPartId = EgtGetParent(EgtGetParent( EgtGetLastSelectedObj())) -- verifico sia un pezzo valido @@ -48,11 +55,11 @@ function RunPartPositioning.Exec() local nLayerId = EgtGetFirstInGroup( nPartId) EgtSetName( nLayerId, ORIGINAL_SOLID) end - + local nMchGrpId = EgtGetMachGroupId( '3dPrint') EgtRemoveMachGroup( nMchGrpId or GDB_ID.NULL) - - -- rimuovo eventuale frame + + -- Rimuovo eventuale frame local nFrameId = EgtGetFirstNameInGroup( nPartId, FRAME_PART) if nFrameId then EgtErase( nFrameId) end -- rimuovo eventuale start point @@ -67,7 +74,7 @@ function RunPartPositioning.Exec() dTabY = b3Tab:getDimY() EgtRemoveMachGroup( nQqqId or GDB_ID.NULL) - -- Richiedo coordinata posizionamento pezzo + -- Richiedo coordinata posizionamento pezzo local b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.EXACT) local dPosX = b3Tab:getDimX() / 2 local dPosY = b3Tab:getDimY() / 2 @@ -81,7 +88,7 @@ function RunPartPositioning.Exec() if not nTabPart then -- Disegno tavola nTabPart = EgtGroup( GDB_ID.ROOT) - --EgtSetLevel( nTabPart, GDB_LV.SYSTEM) + EgtSetMode( nTabPart, GDB_MD.LOCKED) EgtSetName( nTabPart, TABLE) local nTabLayer = EgtGroup( nTabPart) EgtSetName( nTabLayer, TABLE) @@ -93,15 +100,18 @@ function RunPartPositioning.Exec() EgtSetAlpha( nTabSurfId, 70) end - -- Posiziono il pezzo - EgtMove( nPartId, Point3d( dPosX, dPosY, 0) - b3Part:getMin()) - -- Aggiorno il suo box - b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.EXACT) + -- Posiziono il pezzo e aggiorno il suo box + local vtMove = Point3d( dPosX, dPosY, 0) - b3Part:getMin() + EgtMove( nPartId, vtMove) + b3Part:move( vtMove) - -- creo il frame del pezzo + -- Creo il frame del pezzo local frPart = Frame3d( b3Part:getCenter() - 0.5 * b3Part:getDimZ() * Z_AX(), Z_AX()) nFrameId = EgtFrame( nPartId, frPart, GDB_RT.GLOB) - if nFrameId then EgtSetName( nFrameId, FRAME_PART) end + if nFrameId then + EgtSetName( nFrameId, FRAME_PART) + EgtSetMode( nFrameId, GDB_MD.LOCKED) + end EgtAddMachGroup( '3dPrint') EgtSetTable( 'Tab') @@ -121,10 +131,8 @@ function RunPartPositioning.Exec() EgtSetView( SCE_VD.ISO_SW, false) EgtZoom( SCE_ZM.ALL) - - - EgtOutLog( ' +++ PlacePart completed') + EgtOutLog( ' +++ RunPartPositioning completed') end ---------------------------------------------------------------------