diff --git a/BeamWall.ini b/BeamWall.ini new file mode 100644 index 0000000..82a75c1 --- /dev/null +++ b/BeamWall.ini @@ -0,0 +1,10 @@ +[Beam] +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 diff --git a/ClearProcess.lua b/ClearProcess.lua new file mode 100644 index 0000000..63072cc --- /dev/null +++ b/ClearProcess.lua @@ -0,0 +1,57 @@ +-- 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 new file mode 100644 index 0000000..96d84f8 --- /dev/null +++ b/DisableFeatures.lua @@ -0,0 +1,48 @@ +-- DisableFeatures.lua by Egaltech s.r.l. 2020/04/06 +-- 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() +EgtDraw() + +-- end \ No newline at end of file diff --git a/EnableFeatures.lua b/EnableFeatures.lua new file mode 100644 index 0000000..d7ad536 --- /dev/null +++ b/EnableFeatures.lua @@ -0,0 +1,48 @@ +-- DisableFeatures.lua by Egaltech s.r.l. 2020/04/06 +-- 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() +EgtDraw() + +-- end \ No newline at end of file diff --git a/HideAll.lua b/HideAll.lua new file mode 100644 index 0000000..d8c7e8a --- /dev/null +++ b/HideAll.lua @@ -0,0 +1,40 @@ +-- 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 new file mode 100644 index 0000000..5b59c0c Binary files /dev/null and b/Images/ClearProcess.png differ diff --git a/Images/DisableFeatures.png b/Images/DisableFeatures.png new file mode 100644 index 0000000..10249b4 Binary files /dev/null and b/Images/DisableFeatures.png differ diff --git a/Images/EnableFeatures.png b/Images/EnableFeatures.png new file mode 100644 index 0000000..1753231 Binary files /dev/null and b/Images/EnableFeatures.png differ diff --git a/Images/HideAll.png b/Images/HideAll.png new file mode 100644 index 0000000..3ed46af Binary files /dev/null and b/Images/HideAll.png differ diff --git a/Images/ShowAll.png b/Images/ShowAll.png new file mode 100644 index 0000000..37a0de8 Binary files /dev/null and b/Images/ShowAll.png differ diff --git a/Images/ShowBuilding.png b/Images/ShowBuilding.png new file mode 100644 index 0000000..419a955 Binary files /dev/null and b/Images/ShowBuilding.png differ diff --git a/Images/ShowSolid.png b/Images/ShowSolid.png new file mode 100644 index 0000000..383a95e Binary files /dev/null and b/Images/ShowSolid.png differ diff --git a/ShowAll.lua b/ShowAll.lua new file mode 100644 index 0000000..76100ee --- /dev/null +++ b/ShowAll.lua @@ -0,0 +1,18 @@ +-- 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 new file mode 100644 index 0000000..1f372f7 --- /dev/null +++ b/ShowBuilding.lua @@ -0,0 +1,63 @@ +-- 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 new file mode 100644 index 0000000..3a549b3 --- /dev/null +++ b/ShowSolid.lua @@ -0,0 +1,117 @@ +-- 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()