diff --git a/BeamWall.ini b/BeamWall.ini index f7c4f91..814d06a 100644 --- a/BeamWall.ini +++ b/BeamWall.ini @@ -2,9 +2,10 @@ BtlEnable=1 BaseDir=C:\EgtData\BeamWall Button1=ClearProcess.lua,Images\ClearProcess.png,Cancella Lavorazioni Pezzo -Button2=DisableFeatures.lua,Images\DisableFeatures.png,Disabilita Lavorazioni -Button3=EnableFeatures.lua,Images\EnableFeatures.png,Abilita Lavorazioni -Button4=HideAll.lua,Images\HideAll.png,Nascondi i Pezzi non selezionati -Button5=ShowAll.lua,Images\ShowAll.png,Visualizza tutti i Pezzi -Button6=ShowSolid.lua,Images\ShowSolid.png,Visualizza/Nascondi Solido -Button7=ShowBuilding.lua,Images\ShowBuilding.png,Visualizza Struttura/Visualizza Pezzi +Button2=SolidProcess.lua,Images\SolidProcess.png,Trasforma Solidi in Pezzi +Button3=DisableFeatures.lua,Images\DisableFeatures.png,Disabilita Lavorazioni +Button4=EnableFeatures.lua,Images\EnableFeatures.png,Abilita Lavorazioni +Button5=HideAll.lua,Images\HideAll.png,Nascondi i Pezzi non selezionati +Button6=ShowAll.lua,Images\ShowAll.png,Visualizza tutti i Pezzi +Button7=ShowSolid.lua,Images\ShowSolid.png,Visualizza/Nascondi Solido +Button8=ShowBuilding.lua,Images\ShowBuilding.png,Visualizza Struttura/Visualizza Pezzi diff --git a/Compile.bat b/Compile.bat index d748953..f743e1a 100644 --- a/Compile.bat +++ b/Compile.bat @@ -1,5 +1,5 @@ -REM Compilazione degli script BeamWall Egaltech 2024.05.01 +REM Compilazione degli script BeamWall Egaltech 2024.12.30 REM Per togliere info di debug aggiungere flag -s prima del nome del file di input REM Compilazione 32 e 64 bit @@ -13,3 +13,4 @@ erase bin\*.lua \EgtProg\Dll32\luac54 -o bin\ShowAll.lua ShowAll.lua \EgtProg\Dll32\luac54 -o bin\ShowBuilding.lua ShowBuilding.lua \EgtProg\Dll32\luac54 -o bin\ShowSolid.lua ShowSolid.lua +\EgtProg\Dll32\luac54 -o bin\SolidProcess.lua SolidProcess.lua \ No newline at end of file diff --git a/Images/SolidProcess.png b/Images/SolidProcess.png new file mode 100644 index 0000000..ac11e6e Binary files /dev/null and b/Images/SolidProcess.png differ diff --git a/SolidProcess.lua b/SolidProcess.lua new file mode 100644 index 0000000..04b21ae --- /dev/null +++ b/SolidProcess.lua @@ -0,0 +1,118 @@ +-- 2024/12/30 +-- Parti solide gestite come travi BTL + + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + + +-- calcolo del riferimento del minimo box +local function SolidMinBox( nId, dMinFaceArea) + -- ciclo sulle facce della superficie + local nFacCnt = EgtSurfTmFacetCount( nId) + local dVolMin + local refMin + local b3Min + for i = 1, nFacCnt do + local refFace, dL, dW = EgtSurfTmFacetMinAreaRectangle( nId, i - 1, GDB_ID.ROOT) + if refFace and ( not dMinFaceArea or dL * dW > dMinFaceArea) then + local b3Box = EgtGetBBoxRef( nId, GDB_BB.STANDARD, refFace) + if b3Box then + local dVol = b3Box:getDimX() * b3Box:getDimY() * b3Box:getDimZ() + if not dVolMin or dVol < dVolMin then + dVolMin = dVol + refMin = refFace + b3Min = b3Box + end + end + end + end + return refMin, b3Min +end + +-- Trasformazione di un oggetto solido +local function ProcessOneSolid( nId1, ptPos) + + -- Calcolo il riferimento del suo box minimo + local refMin, b3Min = SolidMinBox( nId1, 100) + if not refMin then + refMin, b3Min = SolidMinBox( nId1) + end + if not refMin then + EgtOutText( 'Errore nel calcolo del box minimo della superficie (' .. tostring( nId1) .. ')') + EgtPause( 1000) + return false, 0 + end + + -- Modifico il riferimento in modo che X sia sul più lungo, quindi Z e poi Y + local dDimX = b3Min:getDimX() + local dDimY = b3Min:getDimY() + local dDimZ = b3Min:getDimZ() + if dDimX < dDimY then + refMin:rotate( refMin:getOrigin(), refMin:getVersZ(), 90) + dDimX, dDimY = dDimY, dDimX + end + if dDimX < dDimZ then + refMin:rotate( refMin:getOrigin(), refMin:getVersY(), 90) + dDimX, dDimZ = dDimZ, dDimX + end + if dDimZ < dDimY then + refMin:rotate( refMin:getOrigin(), refMin:getVersX(), 90) + dDimZ, dDimY = dDimY, dDimZ + end + + -- Porto il solido nell'origine + refMin:invert() + EgtTransform( nId1, refMin, GDB_RT.GLOB) + local b3Box = EgtGetBBoxGlob( nId1, GDB_BB.STANDARD) + local vtMove = ORIG() - b3Box:getMin() + EgtMove( nId1, vtMove, GDB_RT.GLOB) + b3Box:move( vtMove) + + -- Creo un nuovo pezzo + local PzId = EgtGroup( GDB_ID.ROOT) + local PartId = EgtGroup( PzId) + EgtSetName( PartId or GDB_ID.NULL, 'Part') + local BoxId = EgtGroup( PzId) + EgtSetName( BoxId or GDB_ID.NULL, 'Box') + local ProcId = EgtGroup( PzId) + EgtSetName( ProcId or GDB_ID.NULL, 'Proc') + + -- Sposto il solido nel pezzo + EgtRelocate( nId1, ProcId) + + -- Calcolo il box + local SboxId = EgtSurfTmBBox( BoxId, b3Box) + EgtSetColor( SboxId or GDB_ID.NULL, {206,199,113,30}) + + -- Assegno il nome + local sText = string.format( '%.0f x %.0f x %.0f', dDimX, dDimY, dDimZ) + local ptText = b3Box:getCenter() + Vector3d( 0, 0, dDimZ / 2) + local TxtId = EgtTextAdv( PartId, ptText, 0, sText, '', 100, 'S', dDimY / 4, 1, 0, GDB_TI.MC) + EgtSetColor( TxtId or GDB_ID.NULL, {0,0,0,100}) + + -- Sposto il pezzo + if ptPos then + EgtMove( PzId, ptPos - ORIG()) + end + + return true, dDimY +end + +------------------------------------------------------------------- +local ptIns = ORIG() +local bOk = true +local nId = EgtGetFirstSelectedObj() +while nId do + EgtDeselectObj( nId) + local bOneOk, dDimY = ProcessOneSolid( nId, ptIns) + EgtDraw() + bOk = bOk and bOneOk + ptIns = ptIns + Vector3d( 0, dDimY + 200, 0) + nId = EgtGetFirstSelectedObj() +end +if not bOk then + EgtOutBox( 'Una o più entità selezionate non sono superfici', 'SolidProcess', 'WARNING', 'OK') +end