-- EgtDoorsBase.lua by EgalWare s.r.l. 2025.10.19 -- Doors Base library -- 2016.06.22 V1.000 FM First version -- 2019.10.01 V1.001 FM Add function FindProperty -- 2019.10.18 V2.000 FM Manage use Materials -- 2019.10.25 V2.001 FM Add function MakeClcPath -- 2020.09.30 V2.002 FM Fix error on call EgtVerticalDimension or EgtHorizontalDimension into AssignSize function -- 2020.09.30 V2.003 FM Fix error into AddSurfTmByExtrusion with open paths -- 2021.05.27 V2.004 FM Manage hatching regions (special) into AddSurfTmByExtrusion -- 2021.06.08 V2.005 FM Modify function MakeClcPath to clean corner for DiamondShape -- 2022.01.17 V2.006 FM Add function MakeConeClcPath -- 2024.02.21 V2.007 FM Add function mm() -- 2025.05.05 v2.7e1 DS Nuovo tipo di ConeCleanCorner che fa metà da sopra e metà da sotto senza baffi ( -1 < dMode < 0). -- 2025.10.19 v2.7j1 DS Controllo regioni in Z di lavorazioni ora verifica che facce arrivino o superino sopra o sotto della porta. require( 'EgtBase') require( 'EgtLinearDimension') -- Tavola per definizione modulo local EgtDoorsBase = {} print( 'EgtDoorsBase started') ----------------------------------------------------------------- -- *** log file id *** ----------------------------------------------------------------- if not sLogIdFile then sLogIdFile = nil end ----------------------------------------------------------------- -- *** DDF file scanning *** ----------------------------------------------------------------- local g_fh = nil local g_sUnLine = nil local g_nLine = 0 ----------------------------------------------------------------- function OpenFile( sFile) g_fh = io.open( sFile) g_nLine = 0 return g_fh end ----------------------------------------------------------------- function CloseFile() if not g_fh then return false end g_fh:close() g_fh = nil g_sUnLine = nil return true end ----------------------------------------------------------------- function GetLine() -- se c'è linea rifiutata if g_sUnLine then local sLine = g_sUnLine g_sUnLine = nil return sLine end -- altrimenti cerco una nuova linea while true do -- leggo la prossima linea local sLine = g_fh:read( '*l') g_nLine = g_nLine + 1 -- se non esiste, esco if not sLine then return nil end -- elimino spazi finali (compresi tab e simili) sLine = EgtTrimRight( sLine) -- se linea contiene qualcosa if sLine:len() > 0 then -- se non ci sono commenti local nI = sLine:find( '#', 1, true) if not nI then return sLine end -- elimino parti di commento if nI > 1 and ( sLine:sub( nI-1, nI-1) == ' ' or sLine:sub( nI-1, nI-1) == '\9') then sLine = EgtTrimRight( sLine:sub( 1, nI-2)) -- se stringa non vuota if sLine:len() > 0 then return sLine end end end end end ----------------------------------------------------------------- function UngetLine( sLine) g_sUnLine = sLine end ----------------------------------------------------------------- function GetLineNumber() return g_nLine end ----------------------------------------------------------------- -- *** Utilities *** ----------------------------------------------------------------- function OpenPrbFile( sFile, sOpenMode) local IdPrbFile = io.open( sFile, sOpenMode) return IdPrbFile end ----------------------------------------------------------------- function OpenLogFile( sFile, sOpenMode) sLogIdFile = io.open( sFile, sOpenMode) return sLogIdFile end ----------------------------------------------------------------- function DoorOutLog( sMessTowrite, nModeWrite) -- prima scrivo il log dell'egtcam if nModeWrite <= 0 then EgtOutLog( sMessTowrite) end -- poi scrivo il log del file porta if sLogIdFile and nModeWrite >= 0 then sLogIdFile:write( sMessTowrite .. '\n') end end ----------------------------------------------------------------- function CloseLogFile() if not sLogIdFile then return false end sLogIdFile:close() sLogIdFile = nil return true end function inch( val) return val * GEO.ONE_INCH end function mm( val) return val * GEO.ONE_MM end -------------------------------------------------------------------------------- function MakeClcPath( clc, ccr, CL, nGroup, dThick, bInvertPath, bDiamondShape, nIpo1, nIpo2, nIpo3) local tHint = {} local nPath local pIni, pEnd, pCen -- disegno angolo x-y+ if not bDiamondShape and ccr and ccr > 0 then -- se devo inserire lo scarico dello spigolo -- calcolo la distanza del centro che equivale alla distanza di inizio arco local dDeltaCorner = ccr * 0.1 -- calcolo il 10% del raggio local dCentrDist = (ccr-dDeltaCorner) * sin(45) local dArcDist = sqrt((ccr*ccr)-(dCentrDist*dCentrDist)) + dCentrDist local dMidPoindDist = dDeltaCorner * sin(45) -- linea iniziale pIni = Point3d(0,-clc,0) pEnd = Point3d(0,-dArcDist,0) local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) -- arco pIni = pEnd pCen = Point3d(-dMidPoindDist,dMidPoindDist,0) pEnd = Point3d(dArcDist,0,0) local nIdArc = EgtArc3P( nGroup, pIni, pCen, pEnd, GDB_RT.LOC) table.insert( tHint, nIdArc) -- linea finale pIni = pEnd pEnd = Point3d(clc,0,0) nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) else if bDiamondShape then -- linea iniziale pIni = Point3d( nIpo2, -nIpo1,0) pEnd = Point3d(0,0,0) local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) -- accorcio la linea EgtTrimExtendCurveByLen( nIdLine,(clc-nIpo3), pIni, GDB_RT.LOC) -- linea finale pIni = pEnd pEnd = Point3d( nIpo2, nIpo1,0) nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) -- accorcio la linea EgtTrimExtendCurveByLen( nIdLine,(clc-nIpo3), pEnd, GDB_RT.LOC) else -- linea iniziale pIni = Point3d(0,-clc,0) pEnd = Point3d(0,0,0) local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) -- linea finale pIni = pEnd pEnd = Point3d(clc,0,0) nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) table.insert( tHint, nIdLine) end end nPath = EgtCurveCompo( nGroup, tHint, true) if nPath then EgtModifyCurveThickness( nPath, dThick) EgtSetName( nPath, CL) if bInvertPath then -- inverto il percorso EgtInvertCurve(nPath) end end return nPath end -------------------------------------------------------------------------------- function MakeConeClcPath( CLCN, nGroup, dThick, dLengthOri, dMode) local tHint = {} local ptEnd local nAuxId local ptApPoint -- disegno angolo X+ Y- local vtExtr = VectorFromSpherical( 1, 45, -45) -- attenzione spessore deve essere negativo dThick = - abs( dThick) -- lunghezza approccio local dLongLine = EgtIf( dLengthOri, dLengthOri + 1, 1) -- lunghezza approccio inclinato local dLongAngLine = dLongLine / vtExtr:getX() -- note per variazioni local sMVar -- pulizia standard (dall'alto in basso e poi baffi sotto) if abs( dMode) < GEO.EPS_SMALL then -- prima linea discendente nAuxId = EgtLine( nGroup, Point3d(0,0,0), Point3d(0,0,dThick), GDB_RT.GLOB) table.insert( tHint, nAuxId) -- seconda linea ptApPoint = Point3d( 0, -dLongLine, dThick) nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), ptApPoint, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- creo linea di ritorno nAuxId = EgtLine( nGroup, ptApPoint, Point3d(0,0,dThick), GDB_RT.GLOB) table.insert( tHint, nAuxId) -- quarta linea ptApPoint = Point3d( dLongLine, 0, dThick) nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), ptApPoint, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- creo linea di ritorno nAuxId = EgtLine( nGroup, ptApPoint, Point3d(0,0,dThick), GDB_RT.GLOB) table.insert( tHint, nAuxId) -- ultima linea di distacco (5mm in direzione utensile) ptEnd = Point3d(0,0,dThick) + ( 5 * vtExtr) nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- da sotto il pezzo in alto elseif dMode < -1.5 then -- parto da sopra + 15 (per evitare movimenti in feed) ptApPoint = ORIG() + ( dLongAngLine * vtExtr) ; ptApPoint:setZ( 15.0) ptEnd = Point3d( ptApPoint) ; ptEnd:setZ( dThick) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- mi porto in basso staccato ptApPoint = Point3d( ptEnd) ptEnd = ptApPoint - ( dLongAngLine * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- risalita fino a sopra + 0.5 ptApPoint = Point3d( ptEnd) ptEnd:setZ( 0.5) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- variazioni sMVar = '{ent=1,code=MaxFeed}' -- dall'alto a metà, poi da sotto il pezzo in su elseif dMode < 0 then -- linea discendente a metà spessore - 1 ptApPoint = Point3d(0,0,-dMode) ptEnd = Point3d(0,0,( ( dThick/2) - 1)) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea di distacco (pari a dLongAngLine in direzione utensile) ptApPoint = ptEnd ptEnd = ptApPoint + ( dLongAngLine * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea discendente alla profondità pari allo spessore ptApPoint = ptEnd ptEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), dThick) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea discendente inclinata sulla direzione dello spigolo ptApPoint = ptEnd ptEnd = ptApPoint - ( dLongAngLine * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- risalita a metà spessore + 1 ptApPoint = ptEnd ptEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), ( ( dThick/2) + 1)) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- ultima linea di distacco (5mm in direzione utensile) ptApPoint = ptEnd ptEnd = Point3d(0,0,( ( dThick/2) + 1)) + ( 5 * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- baffi in alto, poi discesa a metà infine da sotto il pezzo in su else -- prima linea discendente al valore di dMode ptEnd = Point3d(0,0,-dMode) nAuxId = EgtLine( nGroup, Point3d(0,0,0), ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- seconda linea ptApPoint = Point3d( 0, -dLongLine, -dMode) nAuxId = EgtLine( nGroup, ptEnd, ptApPoint, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- creo linea di ritorno nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- quarta linea ptApPoint = Point3d( dLongLine, 0, -dMode) nAuxId = EgtLine( nGroup, ptEnd, ptApPoint, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- creo linea di ritorno nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea discendente a metà spessore - 1 ptApPoint = ptEnd ptEnd = Point3d(0,0,( ( dThick/2) - 1)) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea di distacco (pari a dLongAngLine in direzione utensile) ptApPoint = ptEnd ptEnd = ptApPoint + ( dLongAngLine * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea discendente alla profondità pari allo spessore ptApPoint = ptEnd ptEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), dThick) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- linea discendente inclinata sulla direzione dello spigolo ptApPoint = ptEnd ptEnd = ptApPoint - ( dLongAngLine * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- risalita a metà spessore + 1 ptApPoint = ptEnd ptEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), ( ( dThick/2) + 1)) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) -- ultima linea di distacco (5mm in direzione utensile) ptApPoint = ptEnd ptEnd = Point3d(0,0,( ( dThick/2) + 1)) + ( 5 * vtExtr) nAuxId = EgtLine( nGroup, ptApPoint, ptEnd, GDB_RT.GLOB) table.insert( tHint, nAuxId) end -- trasformo in percorso local nPath if #tHint > 0 then nPath = EgtCurveCompo( nGroup, tHint, true) end if nPath then EgtModifyCurveExtrusion( nPath, vtExtr, GDB_RT.GLOB) EgtModifyCurveThickness( nPath, 0) EgtSetName( nPath, CLCN) EgtSetInfo( nPath, 'ActiveStopMach', 1) EgtSetInfo( nPath, 'SetMaxElev', 1) if sMVar then EgtSetInfo( nPath, 'MVar', sMVar) end end return nPath end -------------------------------------------------------------------------------- local function SetUpRegion( nSrfU, ptIni, ptMin, ptMax, sNameDwReg, sNameUpReg, bReference, bGenOutput, dThId, vtExtr, bMove) local bSurfUp if not DGD.Dws then if bMove then EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) end if ptIni:getZ() < ptMin:getZ() + GEO.EPS_SMALL then -- se geometria è sulla faccia sotto EgtSetName( nSrfU, sNameDwReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = false elseif ptIni:getZ() > ptMax:getZ() - GEO.EPS_SMALL then -- se geometria è sulla faccia sopra EgtSetName( nSrfU, sNameUpReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = true else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfU) end else if DGD.nTypePz == 3 then -- se frame left if bMove then EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) end if abs( ptIni:getX() - ptMin:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto EgtSetName( nSrfU, sNameDwReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = false elseif abs( ptIni:getX() - ptMax:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra EgtSetName( nSrfU, sNameUpReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = true else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfU) end elseif DGD.nTypePz == 4 then -- se frame right if bMove then EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) end if abs( ptIni:getX() - ptMax:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto EgtSetName( nSrfU, sNameDwReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = false elseif abs( ptIni:getX() - ptMin:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra EgtSetName( nSrfU, sNameUpReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = true else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfU) end elseif DGD.nTypePz == 5 then -- se frame top if bMove then EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) end if abs( ptIni:getY() - ptMax:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto EgtSetName( nSrfU, sNameDwReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = false elseif abs( ptIni:getY() - ptMin:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra EgtSetName( nSrfU, sNameUpReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = true else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfU) end elseif DGD.nTypePz == 6 then -- se frame bottom if bMove then EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) end if abs( ptIni:getY() - ptMin:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto EgtSetName( nSrfU, sNameDwReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = false elseif abs( ptIni:getY() - ptMax:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra EgtSetName( nSrfU, sNameUpReg) EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side bSurfUp = true else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfU) end end end if bGenOutput then return bSurfUp end end -------------------------------------------------------------------------------- function AddSurfTmByExtrusion( ParId, EntId, bSingleGeom, nSpecialGeom, bSideSurf) local nIdGeom local Ls = EgtGetFirstNameInGroup( EgtGetParent(ParId), 'SOLID') local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) if bSingleGeom then nIdGeom = EntId else nIdGeom = EgtGetFirstInGroup( EntId) -- ottengo la prima geometria end if not nSpecialGeom then nSpecialGeom = 0 end local nSpecialGeomMaster = nSpecialGeom while nIdGeom do local nNextId local dThId local bExclude = false local bReference local nIdNew if bSingleGeom then nNextId = nil dThId = EgtCurveThickness( nIdGeom) bReference = EgtGetInfo( nIdGeom, 'ReferHw', 'b') or false else nNextId = EgtGetNext(nIdGeom) local sNameGeom = EgtGetName( nIdGeom) if sNameGeom then sNameGeom = string.lower(sNameGeom) if sNameGeom == 'flat_up_tmp' or sNameGeom == 'flat_dw_tmp' or sNameGeom == 'flat_up_tmp_sp' or sNameGeom == 'flat_dw_tmp_sp' or sNameGeom == 'extrusion' or sNameGeom == 'flat_up_blind' or sNameGeom == 'flat_dw_blind' or sNameGeom == 'flat_up_sd_blind' or sNameGeom == 'flat_dw_sd_blind' then bExclude = true end if EgtGetInfo( EntId, 'ConeCleanCorner', 'b') then bExclude = true end end if not bExclude then dThId = EgtCurveThickness( nIdGeom) bReference = EgtGetInfo( nIdGeom, 'ReferHw', 'b') or false end end if not bExclude then -- recupero versore estrusione in globale local vtExtr = EgtCurveExtrusion( nIdGeom, GDB_ID.ROOT) -- recupero versore estrusione in locale local vtExtrLoc = EgtCurveExtrusion( nIdGeom) local frEnt = EgtGetGlobFrame( nIdGeom) local vtMPlane, dDist, dArea = EgtCurveArea( nIdGeom) -- verifico se è un percorso di hatch local bHatch = EgtGetInfo( nIdGeom, 'hatch', 'b') nSpecialGeom = EgtGetInfo( nIdGeom, 'SpecialGeom', 'i') -- se è un percorso aperto ed è segnato come hatch creo il percorso di contorno if not vtMPlane and bHatch and not nSpecialGeom then local nId, nId1, nId2, nId3, nId4 -- faccio gli offset in più e in meno e li unisco con le linee per creare il percorso nId1 = EgtCopyGlob( nIdGeom, EntId) EgtOffsetCurve( nId1, 0.5) nId3 = EgtCopyGlob( nIdGeom, EntId) EgtOffsetCurve( nId3, -0.5) -- inverto il percorso 2 EgtInvertCurve( nId3) -- prendo i punti da collegare local pIni = EgtEP( nId1) local pEnd = EgtSP( nId3) nId2 = EgtLine( EntId, pIni, pEnd, GDB_RT.LOC) pIni = EgtEP( nId3) pEnd = EgtSP( nId1) nId4 = EgtLine( EntId, pIni, pEnd, GDB_RT.LOC) -- creo percorso nId = EgtCurveCompo( EntId, {nId1,nId2,nId3,nId4}, true) EgtModifyCurveThickness( nId, dThId) EgtSetInfo( nId, 'hatch', bHatch) EgtSetInfo( nId, 'SpecialGeom', 3) end if not nSpecialGeom then nSpecialGeom = nSpecialGeomMaster end -- se il percorso è aperto provo a chiudere il percorso if not vtMPlane then local _, nNumCurve = EgtCurveDomain( nIdGeom) -- se ho più curve, provo a chiuderlo if nNumCurve > 0 then --faccio la copia del percorso nIdNew = EgtCopyGlob( nIdGeom, ParId) EgtSelectObj(nIdNew) local ptStart = EgtSP( nIdNew) local ptEnd = EgtEP( nIdNew) if ptStart and ptEnd then local nJoin = EgtLine( ParId, ptEnd, ptStart) if nJoin then -- unisco nIdNew, _ = EgtCurveCompoByChain( ParId, {nIdNew, nJoin}, ptStart) if nIdNew then vtMPlane, dDist, dArea = EgtCurveArea( nIdNew) if not vtMPlane then -- ottengo il piano dalla curva così come è _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) EgtErase( nIdNew) nIdNew = nil end else -- ottengo il piano dalla curva così come è _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) EgtErase( nJoin) end else -- ottengo il piano dalla curva così come è _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) EgtErase( nIdNew) end else -- ottengo il piano dalla curva così come è _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) EgtErase( nIdNew) end else -- ottengo il piano dalla curva così come è _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) end end vtMPlane:toGlob(frEnt) local bInvert if dArea and dArea * ( vtMPlane * vtExtr) < 0 then -- se oraria la inverto EgtInvertCurve( nIdGeom) bInvert = true end -- creo le superfici sopra e sotto local bTrhu if not DGD.Dws then bTrhu = ( abs( dThId) > b3Solid:getDimZ() - GEO.EPS_SMALL) else if DGD.nTypePz == 5 or DGD.nTypePz == 6 then -- se frames top o bottom bTrhu = ( abs( dThId) > b3Solid:getDimY() - GEO.EPS_SMALL) else -- altrimenti frames destro e sinistro bTrhu = ( abs( dThId) > b3Solid:getDimX() - GEO.EPS_SMALL) end end if bTrhu then -- se spessore passante creo le superfici di sopra e di sotto -- aggiungo estrusione se non è un percorso speciale (da hatching dei componenti cutout) if nSpecialGeom <= 1 then local bCanExtrude -- se è un percorso importato con hatching leggo la nota del percorso if nSpecialGeom == 1 then if not bHatch then bCanExtrude = true end else bCanExtrude = true end -- se puù essere fatta estrusione if bCanExtrude then local nExtrs = EgtSurfTmByExtrusion( ParId, nIdGeom, vtExtrLoc * dThId) if nExtrs then EgtSetName( nExtrs, 'Extrusion') EgtSetInfo( nExtrs, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side end end end local nSrfU, nSrfD if nIdNew then -- supefice sopra nSrfU = EgtSurfFlatRegion( ParId, nIdNew) -- supefice sotto nSrfD = EgtSurfFlatRegion( ParId, nIdNew) else -- supefice sopra nSrfU = EgtSurfFlatRegion( ParId, nIdGeom) -- supefice sotto nSrfD = EgtSurfFlatRegion( ParId, nIdGeom) end -- punti massimo e minimo del solido local ptMin = b3Solid:getMin() local ptMax = b3Solid:getMax() local pIni = EgtSP( nIdGeom, GDB_ID.ROOT) if nSrfU then SetUpRegion( nSrfU, pIni, ptMin, ptMax, EgtIf( nSpecialGeom >= 2, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), EgtIf( nSpecialGeom >= 2, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), bReference) end if nSrfD then EgtInvertSurf(nSrfD) SetUpRegion( nSrfD, pIni, ptMin, ptMax, EgtIf( nSpecialGeom >= 2, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), EgtIf( nSpecialGeom >= 2, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), bReference, false, dThId, vtExtrLoc, true) end else -- aggiungo estrusione se non è un percorso speciale (da percorso di hatching) if nSpecialGeom <= 1 then local nExtrs = EgtSurfTmByExtrusion( ParId, nIdGeom, vtExtrLoc * dThId) if nExtrs then EgtSetName( nExtrs, 'Extrusion') EgtSetInfo( nExtrs, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side end end local nSrfU, nSrfD if nIdNew then -- supefice sopra nSrfU = EgtSurfFlatRegion( ParId, nIdNew) -- supefice sotto nSrfD = EgtSurfFlatRegion( ParId, nIdNew) else -- supefice sopra nSrfU = EgtSurfFlatRegion( ParId, nIdGeom) -- supefice sotto nSrfD = EgtSurfFlatRegion( ParId, nIdGeom) end -- punti massimo e minimo del solido local ptMin = b3Solid:getMin() local ptMax = b3Solid:getMax() local pIni = EgtSP( nIdGeom, GDB_ID.ROOT) local bSurfUp if nSrfU then bSurfUp = SetUpRegion( nSrfU, pIni, ptMin, ptMax, EgtIf( bSpecialGeom, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), EgtIf( bSpecialGeom, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), bReference, true) end if nSrfD then -- if not DGD.Dws then EgtMove( nSrfD, Point3d(dThId * vtExtrLoc) - ORIG()) -- EgtMove( nSrfD, Point3d(0,0,(dThId * vtExtrLoc:getZ())) - ORIG()) -- else -- if DGD.nTypePz == 3 or DGD.nTypePz == 4 then -- se frame left o right -- EgtMove( nSrfD, Point3d((dThId * vtExtrLoc:getX()),0,0) - ORIG()) -- else -- se frame top o bottom -- EgtMove( nSrfD, Point3d(0,(dThId * vtExtrLoc:getY()),0) - ORIG()) -- end -- end if bSurfUp then if bSideSurf then EgtSetName( nSrfD, 'FLAT_UP_SD_BLIND') else EgtSetName( nSrfD, 'FLAT_UP_BLIND') end EgtSetInfo( nSrfD, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side elseif not bSurfUp and bSurfUp ~= nil then if bSideSurf then EgtSetName( nSrfD, 'FLAT_DW_SD_BLIND') else EgtSetName( nSrfD, 'FLAT_DW_BLIND') end EgtSetInfo( nSrfD, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello EgtErase(nSrfD) end end end -- se ho invertito ripristino come precedente if bInvert then EgtInvertCurve( nIdGeom) end if nIdNew then EgtErase( nIdNew) end if nSpecialGeom and nSpecialGeom == 3 then EgtErase( nIdGeom) end end nIdGeom = nNextId end return true end -------------------------------------------------------------------------------- function AddFlatSurf( ParId, EntId) local nIdGeom local sSurfName local Ls = EgtGetFirstNameInGroup( EgtGetParent(ParId), 'SOLID') nIdGeom = EgtGetFirstInGroup( EntId) -- ottengo la prima geometria while nIdGeom do sSurfName = EgtGetName( nIdGeom) local nNextId = EgtGetNext(nIdGeom) -- muovo le superfici nel layer SOLID if sSurfName then sSurfName = string.lower(sSurfName) if sSurfName == 'flat_up_tmp' or sSurfName == 'flat_dw_tmp' or sSurfName == 'flat_up_tmp_sp' or sSurfName == 'flat_dw_tmp_sp' or sSurfName == 'extrusion' or sSurfName == 'flat_up_blind' or sSurfName == 'flat_dw_blind' or sSurfName == 'flat_up_sd_blind' or sSurfName == 'flat_dw_sd_blind' then EgtRelocateGlob( nIdGeom, Ls) end end nIdGeom = nNextId end return true end -------------------------------------------------------------------------------- function InvertSurfName( ParId) local nIdGeom local sGeomName nIdGeom = EgtGetFirstInGroup( ParId) -- ottengo la prima geometria while nIdGeom do sGeomName = EgtGetName( nIdGeom) local nNextId = EgtGetNext(nIdGeom) -- controllo il nome della geometria if sGeomName then sGeomName = string.upper(sGeomName) if sGeomName == 'FLAT_UP_TMP' then EgtSetName( nIdGeom, 'FLAT_DW_TMP') elseif sGeomName == 'FLAT_DW_TMP' then EgtSetName( nIdGeom, 'FLAT_UP_TMP') elseif sGeomName == 'FLAT_UP_BLIND' then EgtSetName( nIdGeom, 'FLAT_DW_BLIND') elseif sGeomName == 'FLAT_DW_BLIND' then EgtSetName( nIdGeom, 'FLAT_UP_BLIND') elseif sGeomName == 'FLAT_UP_SD_BLIND' then EgtSetName( nIdGeom, 'FLAT_DW_SD_BLIND') elseif sGeomName == 'FLAT_DW_SD_BLIND' then EgtSetName( nIdGeom, 'FLAT_UP_SD_BLIND') end end nIdGeom = nNextId end return true end -------------------------------------------------------------------------------- local function CreateSizeLayer( ParId, nIdLayer, szLayerName) if not nIdLayer then nIdLayer = EgtGroup(ParId,GDB_RT.LOC) EgtSetName(nIdLayer, szLayerName) EgtSetColor(nIdLayer,BLACK()) -- EgtSetStatus( nIdLayer, GDB_ST.OFF) end return nIdLayer end -------------------------------------------------------------------------------- function AssignSize( ParId, nIdLDoor, nTypePiece, nCodeQ, ptP1, ptP2, dValue, bHoriz, nUp, nRigth, cSizeColor, bRadius, sSufx, bAngle, nCustomGrid) -- codice valido if nCodeQ and nCodeQ >= 0 and nCodeQ <= 17 then if nCodeQ == 0 and DGD.DIM_DOOR then -- quoto porta nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_DOOR') elseif nCodeQ == 1 and DGD.DIM_VISION then -- quoto vision cutout nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_VISION') elseif nCodeQ == 2 and DGD.DIM_LOUVER then -- quoto louver cutout nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_LOUVER') elseif nCodeQ == 3 and DGD.DIM_LOCK then -- quoto lock nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_LOCK') elseif nCodeQ == 5 and DGD.DIM_HINGE then -- quoto hinges nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_HINGE') elseif nCodeQ == 6 and DGD.DIM_MAIL_SLOT then -- quoto mail_slot nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_MAIL_SLOT') elseif nCodeQ == 7 and DGD.DIM_FLUSH_PULL then -- quoto flush_pull nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_FLUSH_PULL') elseif nCodeQ == 8 and DGD.DIM_PEEP_HOLE then -- quoto viewer nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_PEEP_HOLE') elseif nCodeQ == 9 and DGD.DIM_ROLLER_LATCH then -- quoto roller latch nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_ROLLER_LATCH') elseif nCodeQ == 10 and DGD.DIM_EDGE_PULL then -- quoto edgepull nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_EDGE_PULL') elseif nCodeQ == 11 and DGD.DIM_FLUSH_BOLT then -- quoto flushbolt nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_FLUSH_BOLT') elseif nCodeQ == 12 and DGD.DIM_PIVOT then -- quoto pivot nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_PIVOT') elseif nCodeQ == 14 and DGD.DIM_STRIKE then -- quoto strike nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_STRIKE') elseif nCodeQ == 17 and DGD.DIM_EPT then -- quoto EPT nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_EPT') end -- imposto la griglia in base al tipo di pezzo -- if nTypePiece == 3 or nTypePiece == 4 or nTypePiece == 5 then if nTypePiece == 3 or nTypePiece == 4 then EgtSetGridFrame( {{0,0,0},{0,0,1},{0,1,0},{-1,0,0}}) elseif nTypePiece == 5 or nTypePiece == 6 then if nCustomGrid then EgtSetGridFrame( Frame3d( 0,0,0, nCustomGrid)) else if nCodeQ == 0 then EgtSetGridFrame( {{0,DGD.dW,0},{0,-1,0},{0,0,1},{-1,0,0}}) else EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) end end else EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) end local dLenghtArrow = min((0.05 * min(DGD.dH,DGD.dW)), abs(0.3 * dValue)) local dTextSize = min( 30, max( DGD.dW, DGD.dH)) local dTextDist = 5 local sLenTxt = EgtNumToString( EgtToUiUnits( dValue),3)..EgtIf(sSufx, sSufx, '') -- se devo quotare raccordo if bRadius and nIdLDoor then local dDistQuote = 50 + dLenghtArrow local dAmpArc = EgtIf( nRigth ~= 0, dDistQuote*2, dDistQuote*4) --CreateLinearDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'R', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK()), dValue, dAmpArc) CreateLinearDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'R', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) --EgtAlignedDimension( EgtVerticalDimension(nIdLDoor,ptP1, ptP2,{ptP1:getX()+EgtIf( nRigth ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getY(), ptP1:getZ()},sLenTxt,GDB_RT.GRID), EgtIf( cSizeColor, cSizeColor,BLACK()))) elseif bAngle and nIdLDoor then dLenghtArrow = abs(0.5 * dValue) dTextDist = 25 local dDistQuote = 150 + dLenghtArrow + dTextDist -- riassegno il valore da stampare perché i gradi non vanno convertiti sLenTxt = EgtNumToString( dValue)..EgtIf(sSufx, sSufx, '') CreateAngleDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dValue, dDistQuote, (dDistQuote*0.25), dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'A', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) elseif not bHoriz and nIdLDoor then local dDistQuote = 50 + dLenghtArrow if nRigth > 0 then dDistQuote = dDistQuote + DGD.QXP elseif nRigth == 0 then dDistQuote = dDistQuote + DGD.QXM end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --CreateLinearDimensionOnY( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false), 'H', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) local nIdDim = EgtVerticalDimension(nIdLDoor,ptP1, ptP2,{ptP1:getX()+EgtIf( nRigth ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getY(), ptP1:getZ()},sLenTxt,GDB_RT.GRID) if nIdDim then EgtSetColor( nIdDim, EgtIf( cSizeColor, cSizeColor,BLACK())) end local bBox = EgtGetBBox( ParId, 0) if nRigth > 0 then DGD.QXP = bBox:getMax():getX() - ptP1:getX() elseif nRigth == 0 then DGD.QXM = ptP1:getX() - bBox:getMin():getX() end elseif nIdLDoor then local dDistQuote = 50 + dLenghtArrow if nUp > 0 then dDistQuote = dDistQuote + DGD.QYP elseif nUp == 0 then dDistQuote = dDistQuote + DGD.QYM end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --CreateLinearDimensionOnX( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nUp ~= 0, true, false), 'W', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) local nIdDim = EgtHorizontalDimension(nIdLDoor,ptP1,ptP2,{ptP1:getX(), ptP1:getY()+EgtIf( nUp ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getZ()}, sLenTxt,GDB_RT.GRID) if nIdDim then EgtSetColor( nIdDim, EgtIf( cSizeColor, cSizeColor,BLACK())) end local bBox = EgtGetBBox( ParId, 0) if nUp > 0 then DGD.QYP = bBox:getMax():getY() - ptP1:getY() elseif nUp == 0 then DGD.QYM = ptP1:getY() - bBox:getMin():getY() end end EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) return nIdLDoor end return 0 end -------------------------------------------------------------------------------- function MatchName ( sToFind, sFind) if sToFind and sFind then local sCompare = string.gsub( sToFind, ' ', '') if string.lower(sCompare) == string.lower(sFind) then return true end end return false end -------------------------------------------------------------------------------- function FindMaterial ( sToFind, sFind) if MatchName( sToFind, sFind) then return true end return false end -------------------------------------------------------------------------------- function FindProperty ( tTableToFind, sFind) if sFind and tTableToFind and #tTableToFind > 0 then for i = 1, #tTableToFind do if MatchName( tTableToFind[i], sFind) then return true end end end return false end ----------------------------------------------------------------- function ResetDoorsLibs() package.loaded.ConcealedHinge = nil package.loaded.EdgePullFlat = nil package.loaded.EdgePullMortiseCyl = nil -- package.loaded.EgtDoorsBase = nil package.loaded.EgtDoorsData = nil package.loaded.EgtDoorsMsg = nil package.loaded.EPT = nil package.loaded.FaceDecoration = nil package.loaded.FlushBolt = nil package.loaded.FlushPull = nil package.loaded.Groove = nil package.loaded.ImportNgeFile = nil package.loaded._Latch = nil package.loaded._LatchCorner = nil package.loaded._LatchStrike = nil package.loaded.LockMortiseCyl = nil package.loaded.LouverCutOut = nil package.loaded.MachiningBase = nil package.loaded.MailSlot = nil package.loaded._Mortise = nil package.loaded._MortiseCorner = nil package.loaded.MortiseHinge = nil package.loaded.OverHead = nil package.loaded._OPivot = nil package.loaded._OverHeadArm = nil package.loaded.OverHeadArm = nil package.loaded._OverHeadPocket = nil package.loaded.OverHeadPocket = nil package.loaded.Pivot = nil package.loaded._PivotL = nil package.loaded.Rabbet = nil package.loaded.RollerLatch = nil package.loaded.Strike = nil package.loaded._Strike = nil package.loaded.Viewer = nil package.loaded.VisionCutOut = nil package.loaded.Machining = nil package.loaded.CurrCamInfo = nil package.loaded.CurrDoorsCustomData = nil end return EgtDoorsBase