diff --git a/Beam.ini b/Beam.ini index f296cf4..bdd7342 100644 --- a/Beam.ini +++ b/Beam.ini @@ -3,13 +3,6 @@ BtlEnable=1 BaseDir=C:\EgtData\Beam BtlExec=BatchProcess.lua Button1=Process.lua,Images\Process.png,Lavora Travi -Button2=ClearProcess.lua,Images\ClearProcess.png,Cancella Lavorazione Trave -Button3=Swap.lua,Images\Swap.png,Scambia estremi trave -Button4=Rotate.lua,Images\Rotate.png,Ruota trave -Button5=DisableFeatures.lua,Images\DisableFeatures.png,Disabilita lavorazioni -Button6=EnableFeatures.lua,Images\EnableFeatures.png,Abilita lavorazioni -Button7=BeamMachinings,Images\BeamMachinings.png,Lista lavorazioni -Button8=HideAll.lua,Images\HideAll.png,Nascondi tutte le travi non selezionate -Button9=ShowAll.lua,Images\ShowAll.png,Visualizza tutte le travi -Button10=ShowSolid.lua,Images\ShowSolid.png,Visualizza/Nascondi solido -Button11=ShowBuilding.lua,Images\ShowBuilding.png,Visualizza struttura/Visualizza pezzi +Button2=Swap.lua,Images\Swap.png,Scambia estremi trave +Button3=Rotate.lua,Images\Rotate.png,Ruota trave +Button4=BeamMachinings,Images\BeamMachinings.png,Lista lavorazioni diff --git a/ClearProcess.lua b/ClearProcess.lua deleted file mode 100644 index 63072cc..0000000 --- a/ClearProcess.lua +++ /dev/null @@ -1,57 +0,0 @@ --- ClearProcess.lua by Egaltech s.r.l. 2020/03/30 --- Se la trave non è parte di un gruppo di lavoro, cancello geometrie aggiunte - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - --- Recupero la prima trave selezionata -local ObjId = EgtGetFirstSelectedObj() -local PartId = EgtGetParent( EgtGetParent( ObjId or GDB_ID.NULL) or GDB_ID.NULL) -if not PartId then return end - --- Recupero appartenenza a gruppi di lavoro -local vMGrps = {} -local sLst = EgtGetInfo( PartId, GDB_SI.LIST) -if sLst then - vLst = EgtSplitString( sLst) - if vLst then - for i = 1, #vLst do - local MGrpId = EgtGetParent( EgtGetParent( EgtGetParent( vLst[i]) or GDB_ID.NULL) or GDB_ID.NULL) - if MGrpId then - table.insert( vMGrps, EgtGetName( MGrpId)) - end - end - end -end - --- Chiedo conferma della cancellazione -if #vMGrps > 0 then - local sOut = 'I seguenti gruppi di lavoro verranno cancellati :\n ' .. table.concat( vMGrps, ',') .. '.\nConfermi ?' - if not EgtOutBox( sOut, 'Cancella Lavorazioni', 'QUESTION') then - return - end -end - --- Cancello i gruppi di lavoro e le geometrie aggiuntive relative -for i = 1, #vMGrps do - EgtRemoveMachGroup( EgtGetMachGroupId( vMGrps[i]) or GDB_ID.NULL) - EgtErase( EgtGetFirstNameInGroup( PartId, vMGrps[i]) or GDB_ID.NULL) -end - --- Cancello eventuali altre geometrie aggiuntive per gruppi di lavoro -local LayId = EgtGetFirstLayer( PartId) -while LayId do - local NextLayId = EgtGetNextLayer( LayId) - if EgtGetInfo( LayId, GDB_SI.MGRPONLY) then - EgtErase( LayId) - end - LayId = NextLayId -end - --- Aggiorno interfaccia grafica -EgtDeselectPartObjs( PartId) -EgtDraw() - --- end \ No newline at end of file diff --git a/DisableFeatures.lua b/DisableFeatures.lua deleted file mode 100644 index d6d781e..0000000 --- a/DisableFeatures.lua +++ /dev/null @@ -1,48 +0,0 @@ --- DisableFeatures.lua by Egaltech s.r.l. 2019/11/22 --- Gestione disabilitazione delle feature selezionate - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - -if EgtGetSelectedObjCount() == 0 then - EgtOutBox( 'Nessuna lavorazione selezionata', 'Disabilita lavorazioni', 'ERROR') -end - --- Elenco dei pezzi interessati -local vParts = {} - --- Disabilito features selezionate -local nId = EgtGetFirstSelectedObj() -while nId do - -- verifico sia una feature - local nParentId = EgtGetParent( nId) - if EgtIsLayer( nParentId or GDB_ID.NULL) and EgtGetName( nParentId) == 'Processings' and - EgtGetInfo( nId, 'GRP', 'i') and EgtGetInfo( nId, 'PRC', 'i') then - EgtSetInfo( nId, 'DO', 0) - EgtSetColor( nId, Color3d( 160, 160, 160)) - local nAuxId = EgtGetInfo( nId, 'AUXID', 'i') - if nAuxId then - EgtSetColor( nId + nAuxId, Color3d( 160, 160, 160)) - end - table.insert( vParts, EgtGetParent( nParentId)) - end - nId = EgtGetNextSelectedObj() -end - --- Cancello eventuale solido dei pezzi interessati -table.sort( vParts) -local PrevPartId = GDB_ID.NULL -for i = 1, #vParts do - if vParts[i] ~= PrevPartId then - local SolidLy = EgtGetFirstNameInGroup( vParts[i], 'Solid') - EgtErase( SolidLy or GDB_ID.NULL) - PrevPartId = vParts[i] - end -end - -EgtDeselectAll() -EgtZoom( SCE_ZM.ALL) - --- end \ No newline at end of file diff --git a/EnableFeatures.lua b/EnableFeatures.lua deleted file mode 100644 index 517c5d3..0000000 --- a/EnableFeatures.lua +++ /dev/null @@ -1,48 +0,0 @@ --- DisableFeatures.lua by Egaltech s.r.l. 2019/11/22 --- Gestione abilitazione delle feature selezionate - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - -if EgtGetSelectedObjCount() == 0 then - EgtOutBox( 'Nessuna lavorazione selezionata', 'Abilita lavorazioni', 'ERROR') -end - --- Elenco dei pezzi interessati -local vParts = {} - --- Abilito features selezionate -local nId = EgtGetFirstSelectedObj() -while nId do - -- verifico sia una feature - local nParentId = EgtGetParent( nId) - if EgtIsLayer( nParentId or GDB_ID.NULL) and EgtGetName( nParentId) == 'Processings' and - EgtGetInfo( nId, 'GRP', 'i') and EgtGetInfo( nId, 'PRC', 'i') then - EgtRemoveInfo( nId, 'DO') - EgtResetColor( nId) - local nAuxId = EgtGetInfo( nId, 'AUXID', 'i') - if nAuxId then - EgtResetColor( nId + nAuxId) - end - table.insert( vParts, EgtGetParent( nParentId)) - end - nId = EgtGetNextSelectedObj() -end - --- Cancello eventuale solido dei pezzi interessati -table.sort( vParts) -local PrevPartId = GDB_ID.NULL -for i = 1, #vParts do - if vParts[i] ~= PrevPartId then - local SolidLy = EgtGetFirstNameInGroup( vParts[i], 'Solid') - EgtErase( SolidLy or GDB_ID.NULL) - PrevPartId = vParts[i] - end -end - -EgtDeselectAll() -EgtZoom( SCE_ZM.ALL) - --- end \ No newline at end of file diff --git a/HideAll.lua b/HideAll.lua deleted file mode 100644 index d8c7e8a..0000000 --- a/HideAll.lua +++ /dev/null @@ -1,40 +0,0 @@ --- HideAll.lua by Egaltech s.r.l. 2019/03/16 --- Gestione nascondimento di tutte le Travi non selezionate - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - --- se non ci sono pezzi selezionati, esco -if not EgtGetFirstSelectedObj() then return end - --- nascondo tutti i pezzi non selezionati -local bCurrPL = false -local nPartId = EgtGetFirstPart() -while nPartId do - local nStat = GDB_ST.ON - local nLayId = EgtGetFirstLayer( nPartId) - while nLayId do - local nEntId = EgtGetFirstInGroup( nLayId) - if nEntId then - nStat = EgtGetCalcStatus( nEntId) - break - else - nLayId = EgtGetNextLayer( nLayId) - end - end - if nStat ~= GDB_ST.SEL then - EgtSetMode( nPartId, GDB_MD.HIDDEN) - else - EgtDeselectPartObjs( nPartId) - if not bCurrPL then - bCurrPL = EgtSetCurrPartLayer( nPartId, EgtGetFirstLayer( nPartId)) - end - end - nPartId = EgtGetNextPart( nPartId) -end - -EgtZoom( SCE_ZM.ALL) - --- end \ No newline at end of file diff --git a/Images/ClearProcess.png b/Images/ClearProcess.png deleted file mode 100644 index d627bcc..0000000 Binary files a/Images/ClearProcess.png and /dev/null differ diff --git a/Images/DisableFeatures.png b/Images/DisableFeatures.png deleted file mode 100644 index 10249b4..0000000 Binary files a/Images/DisableFeatures.png and /dev/null differ diff --git a/Images/EnableFeatures.png b/Images/EnableFeatures.png deleted file mode 100644 index 1753231..0000000 Binary files a/Images/EnableFeatures.png and /dev/null differ diff --git a/Images/HideAll.png b/Images/HideAll.png deleted file mode 100644 index 3ed46af..0000000 Binary files a/Images/HideAll.png and /dev/null differ diff --git a/Images/Process.png b/Images/Process.png index c040a0d..13070d5 100644 Binary files a/Images/Process.png and b/Images/Process.png differ diff --git a/Images/ShowAll.png b/Images/ShowAll.png deleted file mode 100644 index 37a0de8..0000000 Binary files a/Images/ShowAll.png and /dev/null differ diff --git a/Images/ShowBuilding.png b/Images/ShowBuilding.png deleted file mode 100644 index 419a955..0000000 Binary files a/Images/ShowBuilding.png and /dev/null differ diff --git a/Images/ShowSolid.png b/Images/ShowSolid.png deleted file mode 100644 index 383a95e..0000000 Binary files a/Images/ShowSolid.png and /dev/null differ diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 8c1a175..11907c3 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/31 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/04/06 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -43,6 +43,7 @@ function ProcessLapJoint.Identify( Proc) return ( (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 17) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20) or + (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 25) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 33) or @@ -83,6 +84,8 @@ local function AssignQValues( Proc) sUseRoughToolWithBAxis90 = 'Q04' -- i sUseRoughToolWithBAxis0 = 'Q05' -- i sInsertBoreOnCorner = 'Q06' -- i + elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 25 then + sInsertBoreOnCorner = 'Q01' -- i elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30 then sMakeContourWithSmallTool = 'Q01' -- i sMakeOnlyContourOrFullPocket = 'Q02' -- i @@ -440,6 +443,7 @@ function ProcessLapJoint.Classify( Proc) -- se più di 2 facce else local bClosedOrthoFaces + local nDeletedface -- recupero la faccia con il maggior numero di adiacenze e minor elevazione local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) @@ -450,6 +454,46 @@ function ProcessLapJoint.Classify( Proc) return false end end + -- se è una feature scanalatura (con 5 facce) e non è stata riconosciuta come fessura, eseguo altre verifiche + if Proc.Prc == 16 and Proc.Fct == 5 and not bClosedOrthoFaces then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + return false + end + -- dalla copia della superfice, ciclo eliminando una faccia per volta per verificare se trova fessura + for i = 1, Proc.Fct do + local nNewProc = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + -- elimino una faccia + nDeletedface = i-1 + if EgtSurfTmRemoveFacet( nNewProc, nDeletedface) then + -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa + nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( nNewProc, nPartId) + if not nFacInd or nFacInd < 0 then + if nFacInd == -1 then + bClosedOrthoFaces = nFacInd2 + EgtErase( nNewProc) + break + else + EgtErase( nNewProc) + return false + end + end + -- altrimenti esco + else + EgtErase( nNewProc) + break + end + end + -- se riconosciuta fessura ricalcolo l'elevazione dalla faccia di fondo + if bClosedOrthoFaces then + nFacInd = nDeletedface + -- rendo nulla la faccia opzionale perchè si tratta di una fessura + nFacInd2 = nil + dElev = BL.GetFaceElevation( Proc.Id, nFacInd) + bClosedOrthoFaces = false -- non lo setto come tunnel + end + end -- se facce formano un tunnel e sono ortogonali if bClosedOrthoFaces then -- ottengo le dimensioni del tunnel @@ -1402,7 +1446,7 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, end --------------------------------------------------------------------- -local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev, bForceUseBlade, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces) +local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev, bForceUseBlade, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nBottomFace) local sWarn -- Recupero le facce adiacenti alla principale local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] @@ -1439,22 +1483,25 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, -- Determino se estremi aperti o chiusi local bOpenStart = false local bOpenEnd = false - local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] - EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,'), 3) - for j = 1, #vAdj2 do - if vAdj2[j] == nFacInd then - -- Se non esiste faccia adiacente a lato precedente -> inizio aperto - local i = EgtIf( j > 1, j - 1, #vAdj2) - while vAdj2[i] == nFacInd do - i = EgtIf( i > 1, i - 1, #vAdj2) + -- se non ho la faccia di fondo ( che comporta essere una fessura) verifico se ho lati aperti + if not nBottomFace then + local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] + EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,'), 3) + for j = 1, #vAdj2 do + if vAdj2[j] == nFacInd then + -- Se non esiste faccia adiacente a lato precedente -> inizio aperto + local i = EgtIf( j > 1, j - 1, #vAdj2) + while vAdj2[i] == nFacInd do + i = EgtIf( i > 1, i - 1, #vAdj2) + end + bOpenStart = ( vAdj2[i] < 0) + -- Se non esiste faccia adiacente a lato successivo -> fine aperto + local k = EgtIf( j < #vAdj2, j + 1, 1) + while vAdj2[k] == nFacInd do + k = EgtIf( k < #vAdj2, k + 1, 1) + end + bOpenEnd = ( vAdj2[k] < 0) end - bOpenStart = ( vAdj2[i] < 0) - -- Se non esiste faccia adiacente a lato successivo -> fine aperto - local k = EgtIf( j < #vAdj2, j + 1, 1) - while vAdj2[k] == nFacInd do - k = EgtIf( k < #vAdj2, k + 1, 1) - end - bOpenEnd = ( vAdj2[k] < 0) end end -- Recupero il massimo affondamento possibile con la lama @@ -1534,10 +1581,9 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, return false, sErr end local bGoFromHead = true - -- verifico se la lunghezza utensile riesce ad arrivare sul fondo procedo nella modalità precedente - -- altrimenti se feature ha il flag come semitunnel allora provo a lavorarla come le fessure + -- se la lunghezza utensile non riesce ad arrivare sul fondo assegno la possibilità di lavorare di testa o di fianco if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then - -- se ho il flag che indica che ha forma di semitunnel lavoro dal fianco + -- lavora di testa se è un tunnel, lavora di fianco se non è un tunnel bGoFromHead = not bOrthoFaces end -- se continuo a lavorare di testa @@ -2682,11 +2728,18 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part) EgtOutLog( sErr) return false, sErr end + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end local bClosedOrthoFaces local nFacInd, dFacElev, nFacInd2, dFacElev2 + local nBottomFace -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) - if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bClosedOrthoFaces = nFacInd2 @@ -2696,12 +2749,42 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part) return false, sErr end end - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' - EgtOutLog( sErr) - return false, sErr + -- se è una feature scanalatura (con 5 facce) e non è stata riconosciuta come fessura, eseguo altre verifiche + if Proc.Prc == 16 and Proc.Fct == 5 and not bClosedOrthoFaces then + -- dalla copia della superfice, ciclo eliminando una faccia per volta per verificare se trova fessura + for i = 1, Proc.Fct do + local nNewProc = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + -- elimino una faccia + nBottomFace = i-1 + if EgtSurfTmRemoveFacet( nNewProc, nBottomFace) then + -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa + nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( nNewProc, nPartId) + if not nFacInd or nFacInd < 0 then + if nFacInd == -1 then + bClosedOrthoFaces = nFacInd2 + EgtErase( nNewProc) + break + else + EgtErase( nNewProc) + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeMoreFaces could not find reference face' + EgtOutLog( sErr) + return false, sErr + end + end + -- altrimenti esco + else + EgtErase( nNewProc) + break + end + end + -- se riconosciuta fessura ricalcolo l'elevazione dalla faccia di fondo + if bClosedOrthoFaces then + nFacInd = nBottomFace + -- rendo nulla la faccia opzionale perchè si tratta di una fessura + nFacInd2 = nil + dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) + bClosedOrthoFaces = false -- non setto come tunnel + end end -- verifico se sono presenti i parametri Q per la profondità smusso e -- per eseguire in esclusiva solo lo smusso @@ -2711,7 +2794,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part) if nChamfer < 0 then return false, sErrCham end - -- se è un tunnel provo a vedere se è possibile lavorarlo di con la svuotatura o con la sega catena + -- se è un tunnel provo a vedere se è possibile lavorarlo con la svuotatura o con la sega catena if bClosedOrthoFaces then local bTryWithBlades = true -- lavoro fessura con svuotature (singola o doppia contrapposta) @@ -3062,7 +3145,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part) end -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame if bTryWithBlades and nChamfer < 2 then - bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, bForceUseBlade, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces) + bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, bForceUseBlade, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nBottomFace) if not bOk and sStat == 'MNF' then sPocketing = ML.FindPocketing( sMchFind, dDiam) if not sPocketing then diff --git a/ShowAll.lua b/ShowAll.lua deleted file mode 100644 index 76100ee..0000000 --- a/ShowAll.lua +++ /dev/null @@ -1,18 +0,0 @@ --- ClearAll.lua by Egaltech s.r.l. 2017/11/16 --- Gestione visualizzazione di tutte le Travi - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - -local nId = EgtGetFirstPart() -while nId do - EgtSetMode( nId, GDB_MD.STD) - -- EgtSetStatus( nId, GDB_ST.ON) - nId = EgtGetNextPart( nId) -end - -EgtZoom( SCE_ZM.ALL) - --- end \ No newline at end of file diff --git a/ShowBuilding.lua b/ShowBuilding.lua deleted file mode 100644 index 1f372f7..0000000 --- a/ShowBuilding.lua +++ /dev/null @@ -1,63 +0,0 @@ --- ShowBuilding.lua by Egaltech s.r.l. 2018/11/21 --- Gestione visualizzazione travi come struttura - --- Intestazioni -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - --- recupero il gruppo di assemblaggio -local AsseBaseId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'AsseBase') -if not AsseBaseId then return end - --- recupero il primo oggetto nel gruppo e verifico se devo assemblare o disassemblare -local AsseId = EgtGetFirstInGroup( AsseBaseId) -if not AsseId then return end -local bMake = ( EgtGetGroupObjs( AsseId) == 0) - --- ciclo sul gruppo di assemblaggio -while AsseId do - -- salvo il successivo nel gruppo dell'assemblato - local NextId = EgtGetNext( AsseId) - -- costruisco l'assemblato - if bMake then - -- recupero il pezzo sorgente - local SouId = EgtGetInfo( AsseId, GDB_SI.SOURCE, 'i') - if SouId then - EgtSetMode( SouId, GDB_MD.STD) - EgtSetStatus( SouId, GDB_ST.ON) - -- se già utilizzato, ne faccio una copia - if not EgtIsPart( SouId) then - local CopyId = EgtCopy( SouId, GDB_ID.ROOT) - if CopyId then - EgtRemoveInfo( CopyId, GDB_SI.BASE) - EgtRemoveInfo( CopyId, GDB_SI.LIST) - EgtSetInfo( CopyId, GDB_SI.COPY, SouId) - SouId = CopyId - EgtSetInfo( AsseId, GDB_SI.SOURCE, SouId) - end - end - EgtSetStatus( EgtGetFirstNameInGroup( SouId, 'Box') or GDB_ID.NULL, GDB_ST.OFF) - EgtGroupSwap( SouId, AsseId, true, true) - end - -- ritorno ai pezzi - else - local BasId = EgtGetInfo( AsseId, GDB_SI.BASE, 'i') - if BasId then - EgtGroupSwap( AsseId, BasId, true, true) - local CopId = EgtGetInfo( AsseId, GDB_SI.COPY, 'i') - if CopId then - EgtErase( AsseId) - EgtSetInfo( BasId, GDB_SI.SOURCE, CopId) - else - EgtSetStatus( EgtGetFirstNameInGroup( AsseId, 'Box') or GDB_ID.NULL, GDB_ST.ON) - end - end - end - -- passo al successivo - AsseId = NextId -end - -EgtZoom( SCE_ZM.ALL) - --- end \ No newline at end of file diff --git a/ShowSolid.lua b/ShowSolid.lua deleted file mode 100644 index 3a549b3..0000000 --- a/ShowSolid.lua +++ /dev/null @@ -1,117 +0,0 @@ --- ShowSolid.lua by Egaltech s.r.l. 2020/01/03 --- Gestione calcolo solido di una Trave - -require( 'EgtBase') -_ENV = EgtProtectGlobal() -EgtEnableDebug( false) - --- Funzione per visualizzazione del solido o standard -local function Show( PartId, bSolid) - local BoxLy = EgtGetFirstNameInGroup( PartId, 'Box') - EgtSetStatus( BoxLy or GDB_ID.NULL, EgtIf( bSolid, GDB_ST.OFF, GDB_ST.ON)) - local OutlineLy = EgtGetFirstNameInGroup( PartId, 'Outline') - EgtSetStatus( OutlineLy or GDB_ID.NULL, EgtIf( bSolid, GDB_ST.OFF, GDB_ST.ON)) - local ProcessingsLy = EgtGetFirstNameInGroup( PartId, 'Processings') - EgtSetStatus( ProcessingsLy or GDB_ID.NULL, EgtIf( bSolid, GDB_ST.OFF, GDB_ST.ON)) - local SolidLy = EgtGetFirstNameInGroup( PartId, 'Solid') - EgtSetStatus( SolidLy or GDB_ID.NULL, EgtIf( bSolid, GDB_ST.ON, GDB_ST.OFF)) -end - --- Funzione per regolarizzare, se necessario, la superficie della feature -local function RegularizeTriMesh( SurfId, DestGrpId, dStep) - -- solo per superfici trimesh con poche facce (max4) - local nFacetCnt = EgtSurfTmFacetCount( SurfId) - if nFacetCnt > 4 then - return SurfId - end - -- box della superficie - local b3Surf = EgtGetBBox( SurfId, GDB_BB.STANDARD) - if not b3Surf or b3Surf:isEmpty() or b3Surf:getDimX() < 2 * dStep then - return SurfId - end - -- recupero le facce e le divido in X - local dXmin = b3Surf:getMin():getX() - 1 - local dXmax = b3Surf:getMax():getX() + 1 - local nStep = floor( ( dXmax - dXmin) / dStep + 0.9) - dStep = ( dXmax - dXmin) / nStep - local NewSurfId - for nF = 0, nFacetCnt - 1 do - local FacId = EgtCopySurfTmFacet( SurfId, nF, DestGrpId) - local b3Fac = EgtGetBBox( FacId, GDB_BB.STANDARD) - local dX2 = dXmin - for nI = 1, nStep do - local dX1 = dX2 - dX2 = dX2 + dStep - if b3Fac:getMin():getX() < dX2 and b3Fac:getMax():getX() > dX1 then - EgtCutSurfTmPlane( FacId, Point3d( dX1, 0, 0), -X_AX(), true) - EgtCutSurfTmPlane( FacId, Point3d( dX2, 0, 0), X_AX(), false) - local LoopId = EgtExtractSurfTmFacetLoops( FacId, 0, DestGrpId) - EgtMergeCurvesInCurveCompo( LoopId, 0.001) - local TmpSurfId = EgtSurfTmByFlatContour( DestGrpId, LoopId, 0.01) - EgtErase( LoopId) - if NewSurfId then - NewSurfId = EgtSurfTmBySewing( DestGrpId, {NewSurfId, TmpSurfId}) - else - NewSurfId = TmpSurfId - end - EgtErase( FacId) - FacId = EgtCopySurfTmFacet( SurfId, nF, DestGrpId) - end - end - EgtErase( FacId) - end - return NewSurfId -end - --- Recupero il pezzo del primo oggetto selezionato -local ObjId = EgtGetFirstSelectedObj() -local PartId = EgtGetParent( EgtGetParent( ObjId or GDB_ID.NULL) or GDB_ID.NULL) -if not PartId or not EgtIsPart( PartId) then - EgtOutBox( 'Nessuna trave selezionata', 'Show Solid', 'ERROR') - return -end -EgtDeselectAll() - --- Recupero il Box -local BoxLy = EgtGetFirstNameInGroup( PartId, 'Box') -local BoxId = EgtGetFirstNameInGroup( BoxLy or GDB_ID.NULL, 'Box') -if not BoxId then - EgtOutBox( 'Trave senza Box', 'Show Solid', 'ERROR') - return -end - --- Verifico esistenza del solido -local SolidLy = EgtGetFirstNameInGroup( PartId, 'Solid') -if not SolidLy then - SolidLy = EgtGroup( PartId) - EgtSetName( SolidLy, 'Solid') -end -local SolidId = EgtGetFirstNameInGroup( SolidLy, 'Solid') -if not SolidId then - SolidId = EgtSurfTmBBox( SolidLy, EgtGetBBoxGlob( BoxId, GDB_BB.STANDARD), true, GDB_RT.GLOB) - EgtSetName( SolidId, 'Solid') - EgtSetColor( SolidId, Color3d( 228, 196, 64)) - Show( PartId, true) -else - Show( PartId, ( EgtGetStatus( SolidLy) == GDB_ST.OFF)) - EgtDraw() - return -end -local b3Solid = EgtGetBBox( SolidId, GDB_BB.STANDARD) -local dStep = 1.23 * min( max( b3Solid:getDimY(), b3Solid:getDimZ()), 2 * min( b3Solid:getDimY(), b3Solid:getDimZ())) - --- Ciclo sulle features -local ProcLy = EgtGetFirstNameInGroup( PartId, 'Processings') -local ProcId = EgtGetFirstInGroup( ProcLy) -while ProcId do - if EgtGetInfo( ProcId, 'DO', 'i') ~= 0 and EgtGetInfo( ProcId, 'TRIM', 'i') ~= 0 and EgtGetType( ProcId) == GDB_TY.SRF_MESH then - local NewSurfId = RegularizeTriMesh( ProcId, SolidLy, dStep) - EgtSurfTmIntersect( SolidId, NewSurfId) - if NewSurfId ~= ProcId then - EgtErase( NewSurfId) - end - end - ProcId = EgtGetNext( ProcId) -end - -EgtDraw()