-- -- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT -- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT -- EEEE GGGG GGGG TTTT -- EEEE GGGG TTTT -- EEEEEEE GGGG GGGGGGG TTTT -- EEEEEEE GGGG GGGGGGG TTTT -- EEEE GGGG GGGG TTTT -- EEEE GGGG GGGG TTTT -- EEEEEEEEEE GGGGGGGGGG TTTT -- EEEEEEEEEE GGGGGG TTTT -- -- by Egalware s.r.l. -- Window project software by Egalware s.r.l. 2023/05/02 -- Tabella per definizione modulo local WinLib = {} -- Include require( 'EgtBase') _G.package.loaded.WinConst = nil require( 'WinConst') -- funzioni -- funzione che crea un taglio split function WinLib.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion) local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_OUTLINE) local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD) -- recupero contorno local OutlineIds = {} local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId) while nOutlineId do table.insert( OutlineIds, nOutlineId) nOutlineId = EgtGetNext( nOutlineId) end if SplitType == WIN_SPLIT.VERTICAL then -- creo linea local nCalcPosition = 0 if MeasureType == WIN_MEASURE.ABSOLUT then nCalcPosition = nPosition elseif MeasureType == WIN_MEASURE.PROPORTIONAL then nCalcPosition = b3OutlineLayer:getDimX() / nProportion * nPosition end local nTotSplitId = EgtLine( nOutlineLayerId, Point3d( nCalcPosition, 0, 0), Point3d( nCalcPosition, b3OutlineLayer:getDimY(), 0)) EgtSetName( nTotSplitId, WIN_VERTICAL) -- la taglio con i contorni local nCompoOutlineId = EgtCurveCompo( nOutlineLayerId, OutlineIds, false) local nFROutlineId = EgtSurfFlatRegion( nOutlineLayerId, nCompoOutlineId) local nSplitId, _ = EgtTrimCurveWithRegion( nTotSplitId, nFROutlineId, true, false) EgtErase( { nCompoOutlineId, nFROutlineId}) elseif SplitType == WIN_SPLIT.HORIZONTAL then local nFrameSplitId = EgtLine( nOutlineLayerId, Point3d( 0, nPosition, 0), Point3d( 0, nPosition, 0)) EgtSetName( nFrameSplitId, WIN_HORIZONTAL) end end -- funzione che crea le aree da un taglio split function WinLib.CreateAreaFromSplit( nOutlineLayerId, nFrameSplitId) end -- funzione che restituisce BBox del Ref del profilo function WinLib.GetRefWithBBoxFromProfile( nProfileFrameLayerId, sProfileType) local nProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, sProfileType) local nProfileRefId = EgtGetFirstNameInGroup( nProfileId, WIN_REF) local b3Ref = EgtGetBBox( nProfileRefId, GDB_BB.STANDARD) return nProfileId, b3Ref end -- funzione che restituisce ref e calcola delta controprofilo dal profilo passatogli function WinLib.GetDeltaProfile( nProfileFrameLayerId, sProfileType) local nProfileId, b3Ref = WinLib.GetRefWithBBoxFromProfile( nProfileFrameLayerId, sProfileType) local nCPId = EgtGetFirstNameInGroup( nProfileId, WIN_CTRIN) local b3CP = EgtGetBBox( nCPId, GDB_BB.STANDARD) local dCPDelta = b3Ref:getDimY() - b3CP:getDimY() return dCPDelta, b3Ref end -- funzione che calcola l'ingombro dei pezzi del telaio function WinLib.CalcFrameGeo( nPartId, nOutlineId) -- recupero profilo local nProfileLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE) local nProfileFrameLayerId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_FRAME) -- creo layer per ingombro local nGeoLayerId = EgtGroup( nPartId) EgtSetName( nGeoLayerId, WIN_GEO) -- ricavo tipo dal nome local sName = EgtGetName( nOutlineId) local nProfileType = WIN_PRF.NULL if sName == WIN_TOP then nProfileType = WIN_PRF.TOP elseif sName == WIN_BOTTOM then nProfileType = WIN_PRF.BOTTOM elseif sName == WIN_LEFT then nProfileType = WIN_PRF.LEFT elseif sName == WIN_RIGHT then nProfileType = WIN_PRF.RIGHT end local nOutlineLayerId = EgtGetParent( nOutlineId) local b3OutlineId = EgtGetBBoxGlob( nOutlineId, GDB_BB.STANDARD) local nNewGeoId if nProfileType == WIN_PRF.TOP then -- recupero tipo di giunzioni local StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i') local EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i') -- recupero ref e controprofilo del top e calcolo delta local dTopCPDelta, b3TopRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_TOP) -- recupero outline precedente local nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT) local nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT) -- calcolo vettori direzione local vtNextOutline = EgtSV( nNextOutlineId) local vtPrevOutline = EgtSV( nPrevOutlineId) local vtCurrOutline = EgtSV( nOutlineId) -- calcolo punti con inclinazione local dSenNext = ( vtCurrOutline ^ vtNextOutline):getZ() local dSenPrev = ( vtPrevOutline ^ vtCurrOutline):getZ() local dCosNext = ( vtCurrOutline * vtNextOutline) local dCosPrev = ( vtCurrOutline * vtPrevOutline) local ptBL = ORIG() local ptBR = ptBL + X_AX() * EgtCurveLength( nOutlineId) - X_AX() * dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - X_AX() * dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) local ptTR = ptBR + X_AX() * b3TopRef:getDimY() / dSenNext * dCosNext + Y_AX() * b3TopRef:getDimY() local ptTL = ORIG() - X_AX() * b3TopRef:getDimY() / dSenPrev * dCosPrev + Y_AX() * b3TopRef:getDimY() -- creo rettangolo ingombro nNewGeoId = EgtCurveCompoFromPoints( nGeoLayerId, { ptBL, ptBR, ptTR, ptTL,ptBL}) EgtSetInfo( nNewGeoId, WIN_GEOOUTLINEBOTTOM, EgtCurveLength( nOutlineId) - dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0)) --nNewGeoId = EgtRectangle2P( nGeoLayerId, ORIG(), ORIG() + X_AX() * b3OutlineId:getDimX() - X_AX() * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - X_AX() * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) + Y_AX() * b3TopRef:getDimY()) if StartJointType == WIN_JNT.FULL_V then EgtSetInfo( nNewGeoId, WIN_STARTCPDELTA, dTopCPDelta) end if EndJointType == WIN_JNT.FULL_V then EgtSetInfo( nNewGeoId, WIN_ENDCPDELTA, dTopCPDelta) end EgtModifyCurveExtrusion( nNewGeoId, Z_AX()) EgtModifyCurveThickness( nNewGeoId, -b3TopRef:getDimX()) EgtSetName( nNewGeoId, WIN_TOP) elseif nProfileType == WIN_PRF.BOTTOM then -- recupero tipo di giunzioni local StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i') local EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i') -- recupero ref e controprofilo del top e calcolo delta local dTopCPDelta, b3TopRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_TOP) -- recupero ref del bottom local _, b3BottomRef = WinLib.GetRefWithBBoxFromProfile( nProfileFrameLayerId, WIN_SASH_BOTTOM) -- recupero outline precedente local nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT) local nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT) -- calcolo vettori direzione local vtNextOutline = EgtSV( nNextOutlineId) local vtPrevOutline = EgtSV( nPrevOutlineId) local vtCurrOutline = EgtSV( nOutlineId) -- calcolo punti con inclinazione local dSenNext = ( vtCurrOutline ^ vtNextOutline):getZ() local dSenPrev = ( vtPrevOutline ^ vtCurrOutline):getZ() local dCosNext = ( vtCurrOutline * vtNextOutline) local dCosPrev = ( vtCurrOutline * vtPrevOutline) local ptBL = ORIG() local ptBR = ptBL + X_AX() * EgtCurveLength( nOutlineId) - X_AX() * dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - X_AX() * dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) local ptTR = ptBR + X_AX() * b3TopRef:getDimY() / dSenNext * dCosNext + Y_AX() * b3BottomRef:getDimY() local ptTL = ORIG() - X_AX() * b3TopRef:getDimY() / dSenPrev * dCosPrev + Y_AX() * b3BottomRef:getDimY() -- creo rettangolo ingombro nNewGeoId = EgtCurveCompoFromPoints( nGeoLayerId, { ptBL, ptBR, ptTR, ptTL,ptBL}) EgtSetInfo( nNewGeoId, WIN_GEOOUTLINEBOTTOM, EgtCurveLength( nOutlineId) - dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0)) --nNewGeoId = EgtRectangle2P( nGeoLayerId, ORIG(), ORIG() + X_AX() * b3OutlineId:getDimX() - X_AX() * EgtIf(StartJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) - X_AX() * EgtIf(EndJointType == WIN_JNT.FULL_V, dTopCPDelta, 0) + Y_AX() * b3BottomRef:getDimY()) if StartJointType == WIN_JNT.FULL_V then EgtSetInfo( nNewGeoId, WIN_STARTCPDELTA, dTopCPDelta) end if EndJointType == WIN_JNT.FULL_V then EgtSetInfo( nNewGeoId, WIN_ENDCPDELTA, dTopCPDelta) end EgtModifyCurveExtrusion( nNewGeoId, Z_AX()) EgtModifyCurveThickness( nNewGeoId, -b3BottomRef:getDimX()) EgtSetName( nNewGeoId, WIN_BOTTOM) elseif nProfileType == WIN_PRF.LEFT then -- recupero tipo di giunzioni local StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i') local EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i') -- recupero ref e controprofilo del top e calcolo delta local dTopCPDelta, b3TopRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_TOP) -- recupero ref e controprofilo del bottom e calcolo delta local dBottomCPDelta, b3BottomRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_BOTTOM) -- recupero outline precedente local nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM) local nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP) -- calcolo vettori direzione local vtNextOutline = EgtSV( nNextOutlineId) local vtPrevOutline = EgtSV( nPrevOutlineId) local vtCurrOutline = EgtSV( nOutlineId) -- calcolo punti con inclinazione local dSenNext = ( vtCurrOutline ^ vtNextOutline):getZ() local dSenPrev = ( vtPrevOutline ^ vtCurrOutline):getZ() local dCosNext = ( vtCurrOutline * vtNextOutline) local dCosPrev = ( vtCurrOutline * vtPrevOutline) local ptBL = ORIG() local ptBR = ptBL + X_AX() * EgtCurveLength( nOutlineId) - X_AX() * dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_H, dTopCPDelta, 0) - X_AX() * dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0) local ptTR = ptBR + X_AX() * b3TopRef:getDimY() / dSenNext * dCosNext + Y_AX() * b3TopRef:getDimY() local ptTL = ORIG() - X_AX() * b3TopRef:getDimY() / dSenPrev * dCosPrev + Y_AX() * b3TopRef:getDimY() -- creo rettangolo ingombro nNewGeoId = EgtCurveCompoFromPoints( nGeoLayerId, { ptBL, ptBR, ptTR, ptTL,ptBL}) EgtSetInfo( nNewGeoId, WIN_GEOOUTLINEBOTTOM, EgtCurveLength( nOutlineId) - dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_H, dTopCPDelta, 0) - dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0)) --nNewGeoId = EgtRectangle2P( nGeoLayerId, ORIG(), ORIG() + X_AX() * b3OutlineId:getDimY() - X_AX() * EgtIf(StartJointType == WIN_JNT.FULL_H, dTopCPDelta, 0) - X_AX() * EgtIf(EndJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0) + Y_AX() * b3TopRef:getDimY()) if StartJointType == WIN_JNT.FULL_H then EgtSetInfo( nNewGeoId, WIN_STARTCPDELTA, dTopCPDelta) end if EndJointType == WIN_JNT.FULL_H then EgtSetInfo( nNewGeoId, WIN_ENDCPDELTA, dBottomCPDelta) end EgtModifyCurveExtrusion( nNewGeoId, Z_AX()) EgtModifyCurveThickness( nNewGeoId, -b3TopRef:getDimX()) EgtSetName( nNewGeoId, WIN_LEFT) elseif nProfileType == WIN_PRF.RIGHT then -- recupero tipo di giunzioni local StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i') local EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i') -- recupero ref e controprofilo del top e calcolo delta local dTopCPDelta, b3TopRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_TOP) -- recupero ref e controprofilo del bottom e calcolo delta local dBottomCPDelta, b3BottomRef = WinLib.GetDeltaProfile( nProfileFrameLayerId, WIN_SASH_BOTTOM) -- recupero outline precedente local nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP) local nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM) -- calcolo vettori direzione local vtNextOutline = EgtSV( nNextOutlineId) local vtPrevOutline = EgtSV( nPrevOutlineId) local vtCurrOutline = EgtSV( nOutlineId) -- calcolo punti con inclinazione local dSenNext = ( vtCurrOutline ^ vtNextOutline):getZ() local dSenPrev = ( vtPrevOutline ^ vtCurrOutline):getZ() local dCosNext = ( vtCurrOutline * vtNextOutline) local dCosPrev = ( vtCurrOutline * vtPrevOutline) local ptBL = ORIG() local ptBR = ptBL + X_AX() * EgtCurveLength( nOutlineId) - X_AX() * dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0) - X_AX() * dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_H, dTopCPDelta, 0) local ptTR = ptBR + X_AX() * b3TopRef:getDimY() / dSenNext * dCosNext + Y_AX() * b3TopRef:getDimY() local ptTL = ORIG() - X_AX() * b3TopRef:getDimY() / dSenPrev * dCosPrev + Y_AX() * b3TopRef:getDimY() -- creo rettangolo ingombro nNewGeoId = EgtCurveCompoFromPoints( nGeoLayerId, { ptBL, ptBR, ptTR, ptTL,ptBL}) EgtSetInfo( nNewGeoId, WIN_GEOOUTLINEBOTTOM, EgtCurveLength( nOutlineId) - dSenPrev * EgtIf(StartJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0) - dSenNext * EgtIf(EndJointType == WIN_JNT.FULL_H, dTopCPDelta, 0)) --nNewGeoId = EgtRectangle2P( nGeoLayerId, ORIG(), ORIG() + X_AX() * b3OutlineId:getDimY() - X_AX() * EgtIf(StartJointType == WIN_JNT.FULL_H, dBottomCPDelta, 0) - X_AX() * EgtIf(EndJointType == WIN_JNT.FULL_H, dTopCPDelta, 0) + Y_AX() * b3TopRef:getDimY()) if StartJointType == WIN_JNT.FULL_H then EgtSetInfo( nNewGeoId, WIN_STARTCPDELTA, dBottomCPDelta) end if EndJointType == WIN_JNT.FULL_H then EgtSetInfo( nNewGeoId, WIN_ENDCPDELTA, dTopCPDelta) end EgtModifyCurveExtrusion( nNewGeoId, Z_AX()) EgtModifyCurveThickness( nNewGeoId, -b3TopRef:getDimX()) EgtSetName( nNewGeoId, WIN_RIGHT) end return nNewGeoId end -- funzione che posiziona i profili, li estrude e crea il solido function WinLib.CalcStartEndProfileType(nProfileType) local StartJointType local EndJointType local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME) local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE) local sStartProfileType local sEndProfileType if nProfileType == WIN_PRF.BOTTOM then StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i') EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i') if StartJointType == WIN_JNT.FULL_H then sStartProfileType = WIN_OUTOFST elseif StartJointType == WIN_JNT.FULL_V then sStartProfileType = WIN_CTRINOFST elseif StartJointType == WIN_JNT.ANGLED then --sStartProfileType = WIN_OUTOFST end if EndJointType == WIN_JNT.FULL_H then sEndProfileType = WIN_OUTOFST elseif EndJointType == WIN_JNT.FULL_V then sEndProfileType = WIN_CTRINOFST elseif EndJointType == WIN_JNT.ANGLED then --sEndProfileType = WIN_OUTOFST end elseif nProfileType == WIN_PRF.RIGHT then StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i') EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i') if StartJointType == WIN_JNT.FULL_H then sStartProfileType = WIN_CTRINOFST elseif StartJointType == WIN_JNT.FULL_V then sStartProfileType = WIN_OUTOFST elseif StartJointType == WIN_JNT.ANGLED then --sStartProfileType = WIN_OUTOFST end if EndJointType == WIN_JNT.FULL_H then sEndProfileType = WIN_CTRINOFST elseif EndJointType == WIN_JNT.FULL_V then sEndProfileType = WIN_OUTOFST elseif EndJointType == WIN_JNT.ANGLED then --sEndProfileType = WIN_OUTOFST end elseif nProfileType == WIN_PRF.TOP then StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i') EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i') if StartJointType == WIN_JNT.FULL_H then sStartProfileType = WIN_OUTOFST elseif StartJointType == WIN_JNT.FULL_V then sStartProfileType = WIN_CTRINOFST elseif StartJointType == WIN_JNT.ANGLED then --sStartProfileType = WIN_OUTOFST end if EndJointType == WIN_JNT.FULL_H then sEndProfileType = WIN_OUTOFST elseif EndJointType == WIN_JNT.FULL_V then sEndProfileType = WIN_CTRINOFST elseif EndJointType == WIN_JNT.ANGLED then --sEndProfileType = WIN_OUTOFST end elseif nProfileType == WIN_PRF.LEFT then StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i') EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i') if StartJointType == WIN_JNT.FULL_H then sStartProfileType = WIN_CTRINOFST elseif StartJointType == WIN_JNT.FULL_V then sStartProfileType = WIN_OUTOFST elseif StartJointType == WIN_JNT.ANGLED then --sStartProfileType = WIN_OUTOFST end if EndJointType == WIN_JNT.FULL_H then sEndProfileType = WIN_CTRINOFST elseif EndJointType == WIN_JNT.FULL_V then sEndProfileType = WIN_OUTOFST elseif EndJointType == WIN_JNT.ANGLED then --sEndProfileType = WIN_OUTOFST end end return sStartProfileType, sEndProfileType, StartJointType, EndJointType end -- funzione che posiziona i profili, li estrude e crea il solido function WinLib.MakeSolidByExtrusion(nGeoId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId) -- recupero outline local nPartId = EgtGetParent( nSolidLayerId) local nAreaId = EgtGetInfo( nPartId, WIN_AREA) local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE) local sOutlineName = '' local sPrevOutlineName = '' local sNextOutlineName = '' if nProfileType == WIN_PRF.BOTTOM then sOutlineName = WIN_BOTTOM sPrevOutlineName = WIN_LEFT sNextOutlineName = WIN_RIGHT elseif nProfileType == WIN_PRF.RIGHT then sOutlineName = WIN_RIGHT sPrevOutlineName = WIN_BOTTOM sNextOutlineName = WIN_TOP elseif nProfileType == WIN_PRF.TOP then sOutlineName = WIN_TOP sPrevOutlineName = WIN_RIGHT sNextOutlineName = WIN_LEFT elseif nProfileType == WIN_PRF.LEFT then sOutlineName = WIN_LEFT sPrevOutlineName = WIN_TOP sNextOutlineName = WIN_BOTTOM end local nOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sOutlineName) local nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sPrevOutlineName) local nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sNextOutlineName) -- calcolo vettori direzione degli outline local vtNextOutline = EgtSV( nNextOutlineId) local vtCurrOutline = EgtSV( nOutlineId) local vtPrevOutline = EgtSV( nPrevOutlineId) -- recupero posizione e BBox del geo local b3Geo = EgtGetBBox(nGeoId, GDB_BB.STANDARD) -- recupero BBox del profilo Main local nRefMainProfileId = EgtGetFirstNameInGroup( nMainProfileId, WIN_REF) local b3RefMainProfile = EgtGetBBoxGlob( nRefMainProfileId, GDB_BB.STANDARD) -- recupero frame del profilo local nMainProfileFrameId = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTIONFRAME) local frInvertMainProfile = EgtFR( nMainProfileFrameId) frInvertMainProfile:invert() -- lo applico a tutte le geometrie del profilo EgtTransform( EgtGetAllInGroup( nMainProfileId), frInvertMainProfile) -- assegno come riferimento del profilo il punto start dell'outline EgtChangeGroupFrame( nMainProfileId, Frame3d( Point3d( b3Geo:getMin():getX(), b3Geo:getMin():getY(), b3Geo:getMax():getZ()), - X_AX())) -- recupero outline del profilo Main e lo estrudo local nMainOutlineId = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTION) if nProfileType == WIN_PRF.BOTTOM then EgtInvertCurve( nMainOutlineId) end local nMainExtrusionId = EgtSurfTmByExtrusion( nSolidLayerId, nMainOutlineId, X_AX() * b3Geo:getDimX()) -- posiziono il profilo Start local nRefStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, WIN_REF) local b3RefStartProfile = EgtGetBBoxGlob(nRefStartProfileId, GDB_BB.STANDARD) local dDelta = EgtGetInfo( nGeoId, WIN_STARTCPDELTA, 'd') or 0 -- recupero frame del profilo local nStartProfileFrameId = EgtGetFirstNameInGroup( nStartProfileId, WIN_SECTIONFRAME) local frInvertStartProfile = EgtFR( nStartProfileFrameId) frInvertStartProfile:move( - Y_AX() * dDelta) frInvertStartProfile:invert() -- lo applico a tutte le geometrie del profilo EgtTransform( EgtGetAllInGroup( nStartProfileId), frInvertStartProfile) -- assegno come riferimento del profilo il punto start dell'outline --do return end EgtChangeGroupFrame( nStartProfileId, Frame3d( ORIG(), - vtPrevOutline)) local dSenNext = ( vtCurrOutline ^ vtNextOutline):getZ() local dSenPrev = ( vtPrevOutline ^ vtCurrOutline):getZ() local dCosNext = ( vtCurrOutline * vtNextOutline) local dCosPrev = ( vtCurrOutline * vtPrevOutline) local dDeltaStartAngle = b3RefStartProfile:getDimX() * dCosPrev / dSenPrev EgtMove( nStartProfileId, vtPrevOutline * dDeltaStartAngle) -- in base al tipo di incastro e di pezzo, ricavo i controprofili local sStartProfileType local sEndProfileType -- recupero tipo di giunzioni sStartProfileType, sEndProfileType, StartJointType, EndJointType = WinLib.CalcStartEndProfileType( nProfileType) -- recupero outline del profilo Start e lo estrudo local nOutStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, sStartProfileType) --if (StartJointType == WIN_JNT.FULL_H and ( nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.RIGHT)) or -- (StartJointType == WIN_JNT.FULL_V and ( nProfileType == WIN_PRF.LEFT)) then -- EgtInvertCurve( nOutStartProfileId) --end if StartJointType == WIN_JNT.FULL_H and nProfileType == WIN_PRF.BOTTOM then EgtInvertCurve( nOutStartProfileId) end local nStartExtrusionId = EgtSurfTmByExtrusion( nSolidLayerId, nOutStartProfileId, - vtPrevOutline * ( b3RefMainProfile:getDimY() / dSenPrev + dDeltaStartAngle)) -- taglio estrusi per ottenere solido local nExtrCopyId = EgtCopy( nMainExtrusionId, nSolidLayerId) EgtSurfTmCut( nMainExtrusionId, nStartExtrusionId, true, false) EgtSurfTmCut( nStartExtrusionId, nExtrCopyId, true, false) -- posiziono il profilo End --EgtRotate( EgtGetAllInGroup( nEndProfileId), ORIG(), Z_AX(), 90) --EgtRotate( EgtGetAllInGroup( nEndProfileId), ORIG(), Y_AX(), 180) local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF) local b3RefEndProfile = EgtGetBBoxGlob(nRefEndProfileId, GDB_BB.STANDARD) local dDelta = EgtGetInfo( nGeoId, WIN_ENDCPDELTA, 'd') or 0 --vtMove = vtMove - X_AX() * dDelta --EgtMove( nStartProfileId, vtMove) --EgtMove( EgtGetAllInGroup( nEndProfileId), ORIG() - Point3d( b3RefEndProfile:getMax():getX(), b3RefEndProfile:getMax():getY(), b3RefEndProfile:getMax():getZ()) + X_AX() * dDelta, GDB_RT.GLOB) -- recupero frame del profilo local nEndProfileFrameId = EgtGetFirstNameInGroup( nEndProfileId, WIN_SECTIONFRAME) local frInvertEndProfile = EgtFR( nEndProfileFrameId) frInvertEndProfile:move( - Y_AX() * dDelta) EgtMove(nEndProfileFrameId, - Y_AX() * dDelta) frInvertEndProfile:invert() -- lo applico a tutte le geometrie del profilo EgtTransform( EgtGetAllInGroup( nEndProfileId), frInvertEndProfile) -- assegno come riferimento del profilo il punto start dell'outline local b3Outline = EgtGetBBox( nOutlineId, GDB_BB.STANDARD) local dBottomOutline = EgtGetInfo( nGeoId, WIN_GEOOUTLINEBOTTOM, 'd') EgtChangeGroupFrame( nEndProfileId, Frame3d( ORIG() + X_AX() * dBottomOutline , - vtNextOutline)) --EgtChangeGroupFrame( nEndProfileId, Frame3d( Point3d( b3Outline:getMax():getX(), b3Outline:getMin():getY(), b3Outline:getMax():getZ()), - vtNextOutline)) local dDeltaEndAngle = b3RefEndProfile:getDimX() * dCosNext / dSenNext EgtMove( nEndProfileId, - vtNextOutline * dDeltaEndAngle) --EgtRotate( nEndProfileId, Point3d( b3Geo:getMin():getX(), b3Geo:getMin():getY(), b3Geo:getMax():getZ()), Y_AX(), -90) --local dSecondAngle = EgtIf( nProfileType == WIN_PRF.LEFT, 90, -90) --EgtRotate( nEndProfileId, Point3d( b3Geo:getMin():getX(), b3Geo:getMin():getY(), b3Geo:getMax():getZ()), Z_AX(), dSecondAngle) --local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF) --local b3RefEndProfile = EgtGetBBoxGlob(nRefEndProfileId, GDB_BB.STANDARD) --local vtMove = Point3d( b3Geo:getMax():getX(),b3Geo:getMin():getY(),b3Geo:getMin():getZ()) - Point3d( b3RefEndProfile:getMax():getX(), b3RefEndProfile:getMin():getY(), b3RefEndProfile:getMin():getZ()) ---- sposto del delta controprofilo se necessario --local dDelta = EgtGetInfo( nGeoId, WIN_ENDCPDELTA, 'd') or 0 --vtMove = vtMove + X_AX() * dDelta --EgtMove( nEndProfileId, vtMove) -- recupero outline del profilo End e lo estrudo local nOutEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, sEndProfileType) if (EndJointType == WIN_JNT.FULL_H and nProfileType == WIN_PRF.RIGHT) or (EndJointType == WIN_JNT.FULL_V and (nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.LEFT)) then EgtInvertCurve( nOutEndProfileId) end local nEndExtrusionId = EgtSurfTmByExtrusion( nSolidLayerId, nOutEndProfileId, vtNextOutline * ( b3RefMainProfile:getDimY() / dSenNext + dDeltaEndAngle)) -- taglio estrusi per ottenere solido EgtSurfTmCut( nMainExtrusionId, nEndExtrusionId, true, false) EgtSurfTmCut( nEndExtrusionId, nExtrCopyId, true, false) EgtErase( nExtrCopyId) end -- funzione che crea il solido del pezzo del telaio function WinLib.CalcFrameSolid(nPartId, nGeoId) -- recupero profilo local nProfileId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE) local nProfileFrameLayerId = EgtGetFirstNameInGroup( nProfileId, WIN_FRAME) -- creo layer per solido e per profili di estrusione local nSolidLayerId = EgtGroup( nPartId) EgtSetName( nSolidLayerId, WIN_SOLID) local nFrameProfileLayerId = EgtGroup( nPartId) EgtSetName( nFrameProfileLayerId, WIN_PROFILE) -- ricavo tipo dal nome local sName = EgtGetName( nGeoId) local nProfileType = WIN_PRF.NULL if sName == WIN_TOP then nProfileType = WIN_PRF.TOP elseif sName == WIN_BOTTOM then nProfileType = WIN_PRF.BOTTOM elseif sName == WIN_LEFT then nProfileType = WIN_PRF.LEFT elseif sName == WIN_RIGHT then nProfileType = WIN_PRF.RIGHT end local nOrigMainProfileId = GDB_ID.NULL local nMainProfileId = GDB_ID.NULL local nOrigStartProfileId = GDB_ID.NULL local nStartProfileId = GDB_ID.NULL local nOrigEndProfileId = GDB_ID.NULL local nEndProfileId = GDB_ID.NULL -- recupero profilo e controprofili per tipo if nProfileType == WIN_PRF.BOTTOM then nOrigMainProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_BOTTOM) nOrigStartProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigEndProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) elseif nProfileType == WIN_PRF.RIGHT then nOrigMainProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigStartProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_BOTTOM) nOrigEndProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) elseif nProfileType == WIN_PRF.TOP then nOrigMainProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigStartProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigEndProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) elseif nProfileType == WIN_PRF.LEFT then nOrigMainProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigStartProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_TOP) nOrigEndProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, WIN_SASH_BOTTOM) end -- creo copie di profilo e controprofili nMainProfileId = EgtCopy( nOrigMainProfileId, nFrameProfileLayerId) nStartProfileId = EgtCopy( nOrigStartProfileId, nFrameProfileLayerId) nEndProfileId = EgtCopy( nOrigEndProfileId, nFrameProfileLayerId) -- creo solido dai profili WinLib.MakeSolidByExtrusion(nGeoId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId) end -- funzione che calcola l'ingombro dei pezzi del telaio function WinLib.CreatePartFromOutline( nFrameLayerId, nOutlineId) -- ricavo tipo dal nome local sName = EgtGetName( nOutlineId) local nProfileType = WIN_PRF.NULL if sName == WIN_TOP then nProfileType = WIN_PRF.TOP elseif sName == WIN_BOTTOM then nProfileType = WIN_PRF.BOTTOM elseif sName == WIN_LEFT then nProfileType = WIN_PRF.LEFT elseif sName == WIN_RIGHT then nProfileType = WIN_PRF.RIGHT end -- creo pezzo local nPartId = EgtGroup( GDB_ID.ROOT) EgtSetName( nPartId, sName) if nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP then EgtSetColor( nPartId, Color3d( 204, 102, 0)) elseif nProfileType == WIN_PRF.RIGHT or nProfileType == WIN_PRF.LEFT then EgtSetColor( nPartId, Color3d( 251, 128, 4)) end -- inserisco riferimento alla sua area EgtSetInfo( nPartId, WIN_AREA, nFrameLayerId) -- disegno ingombro local nGeoId = WinLib.CalcFrameGeo( nPartId, nOutlineId) -- disegno solido WinLib.CalcFrameSolid(nPartId, nGeoId) -- offset per distanziare i pezzi local dYPosOffset = 300 * ( nProfileType - 1) EgtChangeGroupFrame( nPartId, Frame3d( Point3d( 0, dYPosOffset, 0))) end -- funzione che posiziona un pezzo function WinLib.PositionPart(nPartId) -- ricavo tipo dal nome local sName = EgtGetName( nPartId) local sDelta = '' if sName == WIN_BOTTOM then sDelta = WIN_STARTCPDELTA elseif sName == WIN_RIGHT then sDelta = WIN_STARTCPDELTA elseif sName == WIN_TOP then sDelta = WIN_STARTCPDELTA elseif sName == WIN_LEFT then sDelta = WIN_STARTCPDELTA end -- calcolo nuovo riferimento local nGeoPartLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO) local nGeoPartId = EgtGetFirstNameInGroup( nGeoPartLayerId, sName) local dDelta = EgtGetInfo( nGeoPartId, sDelta, 'd') or 0 local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME) local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE) local nFramePartId = EgtGetFirstNameInGroup( nOutlineLayerId, sName) local vtStart = EgtSV( nFramePartId) local ptStart = EgtSP( nFramePartId) + vtStart * dDelta local _, _, dAngRight = SphericalFromVector(vtStart) local frStart = Frame3d( ptStart) frStart:rotate( frStart:getOrigin(), Z_AX(), dAngRight) EgtChangeGroupFrame( nPartId, frStart) end -- funzione che assembla i pezzi function WinLib.AssembleFrame() local nBottomPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_BOTTOM) WinLib.PositionPart(nBottomPartId) local nRightPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_RIGHT) WinLib.PositionPart(nRightPartId) local nTopPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_TOP) WinLib.PositionPart(nTopPartId) local nLeftPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_LEFT) WinLib.PositionPart(nLeftPartId) -- assemblo i pezzi --local nRightPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_RIGHT) --local nGeoRightLayerId = EgtGetFirstNameInGroup( nRightPartId, WIN_GEO) --local nGeoRightId = EgtGetFirstNameInGroup( nGeoRightLayerId, WIN_RIGHT) --local dDelta = EgtGetInfo( nGeoRightId, WIN_BOTTOMCPDELTA, 'd') --local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME) --local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE) --local nFrameRightId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT) --local vtRight = EgtSV( nFrameRightId) --local ptRight = EgtSP( nFrameRightId) + vtRight * dDelta --local _, _, dAngRight = SphericalFromVector(vtRight) --local frRight = Frame3d( ptRight) --frRight:rotate( frRight:getOrigin(), Z_AX(), dAngRight) --EgtChangeGroupFrame( nRightPartId, frRight) end --------------------------------------------------------------------- return WinLib