diff --git a/Profiles/Profilo78 - Offset - Copy (48).nge b/Profiles/Profilo78 - Offset - Copy (48).nge new file mode 100644 index 0000000..1b10c42 Binary files /dev/null and b/Profiles/Profilo78 - Offset - Copy (48).nge differ diff --git a/Profiles/Profilo78 - Offset.nge b/Profiles/Profilo78 - Offset.nge index 1b10c42..5574fd5 100644 Binary files a/Profiles/Profilo78 - Offset.nge and b/Profiles/Profilo78 - Offset.nge differ diff --git a/Profiles/WinConst.lua b/Profiles/WinConst.lua index eb051a6..c133f3c 100644 --- a/Profiles/WinConst.lua +++ b/Profiles/WinConst.lua @@ -232,6 +232,7 @@ WIN_PRC_OFFZ_1 = 'OFFZ_1' WIN_PRC_OFFY_2 = 'OFFY_2' WIN_PRC_OFFZ_2 = 'OFFZ_2' +WIN_REF_SPLIT = 'RefSplit' WIN_CRV_ON_FRENCH_SPLIT = 'OutlineOnFrenchSplit' WIN_MAINGUIDE = 'MainGuide' @@ -263,32 +264,15 @@ WIN_PRC_DWL_SIDETYPE = { } WIN_DOWEL = 'Dowel' -WIN_DWL_TOPPERPSTART = 'TopPerpStart' -WIN_DWL_TOPPERPEND = 'TopPerpEnd' -WIN_DWL_TOPPARASTART = 'TopParaStart' -WIN_DWL_TOPPARAEND = 'TopParaEnd' -WIN_DWL_BOTTOMPERPSTART = 'BottomPerpStart' -WIN_DWL_BOTTOMPERPEND = 'BottomPerpEnd' -WIN_DWL_BOTTOMPARASTART = 'BottomParaStart' -WIN_DWL_BOTTOMPARAEND = 'BottomParaEnd' -WIN_DWL_RAILBOTTOMPERPSTART = 'RailBottomPerpStart' -WIN_DWL_RAILBOTTOMPERPEND = 'RailBottomPerpEnd' -WIN_DWL_RAILBOTTOMPARASTART = 'RailBottomParaStart' -WIN_DWL_RAILBOTTOMPARAEND = 'RailBottomParaEnd' -WIN_DWL_SPLITPERPSTART = 'SplitPerpStart' -WIN_DWL_SPLITPERPEND = 'SplitPerpEnd' -WIN_DWL_SPLITPARASTART = 'SplitParaStart' -WIN_DWL_SPLITPARAEND = 'SplitParaEnd' -WIN_DWL_VERTICALSPLITPARASTART = 'VerticalSplitParaStart' -WIN_DWL_VERTICALSPLITPARAEND = 'VerticalSplitParaEnd' -WIN_DWL_VERTICALSPLITPERPSTART = 'VerticalSplitPerpStart' -WIN_DWL_VERTICALSPLITPERPEND = 'VerticalSplitPerpEnd' -WIN_DWL_HORIZONTALSPLITPARASTART = 'HorizontalSplitParaStart' -WIN_DWL_HORIZONTALSPLITPARAEND = 'HorizontalSplitParaEnd' -WIN_DWL_BOTTOMHORIZONTALSPLITPARASTART = 'BottomHorizontalSplitParaStart' -WIN_DWL_BOTTOMHORIZONTALSPLITPARAEND = 'BottomHorizontalSplitParaEnd' -WIN_DWL_HORIZONTALSPLITPERPSTART = 'HorizontalSplitPerpStart' -WIN_DWL_HORIZONTALSPLITPERPEND = 'HorizontalSplitPerpEnd' +WIN_DWL_TOP_PERP_LEN = 'TopPerpLen' +WIN_DWL_TOP_PARA_LEN = 'TopParaLen' +WIN_DWL_BOTTOM_PERP_LEN = 'BottomPerpLen' +WIN_DWL_BOTTOM_PARA_LEN = 'BottomParaLen' +WIN_DWL_RAILBOTTOM_PERP_LEN = 'RailBottomPerpLen' +WIN_DWL_RAILBOTTOM_PARA_LEN = 'RailBottomParaLen' +WIN_DWL_SPLIT_PERP_LEN = 'SplitPerpLen' +WIN_DWL_SPLIT_PARA_LEN = 'SplitParaLen' + WIN_PRJ_ORIGSPLIT = 'OrigSplit' diff --git a/Profiles/WinLib/WinCalculate.lua b/Profiles/WinLib/WinCalculate.lua index c14699e..faa3054 100644 --- a/Profiles/WinLib/WinCalculate.lua +++ b/Profiles/WinLib/WinCalculate.lua @@ -20,6 +20,8 @@ local WinCalculate = {} require( 'EgtBase') require( 'WinConst') +local s_dDowelTol = 1 + local bCalcSolid = false function WinCalculate.GetCalcSolid() return bCalcSolid @@ -201,6 +203,19 @@ local function FindAssociatedPart( nOutlineId) return nPartId end +--------------------------------------------------------------------- +-- funzione che calcola il box di un profilo ( guardando la sua curva Ref) rispetto al suo frame +local function GetProfileLocalBox( nProfileId) + -- recupero il frame del profilo + local nFrameId = EgtGetFirstNameInGroup( nProfileId, WIN_SECTIONFRAME) + local frFrame = EgtFR( nFrameId, GDB_ID.ROOT) + -- recupero il Ref del profilo e ne calcolo il box + local nRefId = EgtGetFirstNameInGroup( nProfileId, WIN_REF) + local b3Box = EgtGetBBoxRef( nRefId, GDB_BB.STANDARD, frFrame, GDB_RT.GLOB) + return b3Box +end + + --------------------------------------------------------------------- ----------------- CALCOLO DEI PROFILI ------------------------------ --------------------------------------------------------------------- @@ -233,8 +248,8 @@ end local function GetSplitType( nSplitLayerId) local nSplitType = EgtGetInfo( nSplitLayerId, WIN_SPLITTYPE, 'i') - -- se non ha split impostato verifico se ha sash prima o dopo per capire se è implicitamente di tipo mullion - if not nSplitType then + -- se non ha split specifico impostato verifico se ha sash prima o dopo per capire se è di tipo mullion + if not nSplitType or nSplitType == WIN_SPLITTYPES.NULL then local nParentAreaId = EgtGetParent( nSplitLayerId) local nParentAreaType = EgtGetInfo( nParentAreaId, WIN_AREATYPE, 'i') or WIN_AREATYPES.NULL while nParentAreaId and nParentAreaType ~= WIN_AREATYPES.SASH do @@ -248,7 +263,7 @@ local function GetSplitType( nSplitLayerId) local bSashAfter = VerifyChildArea( nAreaId) -- se ci sono assegno tipo di profilo a mullion if bSashAfter then - EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, WIN_SPLITTYPES.MULLION) + EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, WIN_SPLITTYPES.MULLION) nSplitType = WIN_SPLITTYPES.MULLION end end @@ -542,6 +557,7 @@ local function CalculateOutlineFromAreaOutline( nAreaId) if sSouName == WIN_SPLIT then local sBaseName = EgtGetName( nBaseOutlineId) EgtSetName( nOutlineId, sBaseName) + EgtSetInfo( nOutlineId, WIN_REF_SPLIT, nSouId) end -- sistemo le info @@ -630,12 +646,8 @@ local function CalculateOutlineFromAreaOutline( nAreaId) local nFrameProfileLayerId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_FRAME) local nFrameProfileId = EgtGetFirstNameInGroup( nFrameProfileLayerId, sFrameProfile) - -- recupero le relative origini - local nFrameFrameProfileId = EgtGetFirstNameInGroup( nFrameProfileId, WIN_SECTIONFRAME) - local frFrameProfileId = EgtFR( nFrameFrameProfileId) -- calcolo il box del riferimento del profilo del frame - local nRefFrameProfileId = EgtGetFirstNameInGroup( nFrameProfileId, WIN_REF) - local b3FrameProfile = EgtGetBBoxRef( nRefFrameProfileId, GDB_BB.STANDARD, frFrameProfileId) + local b3FrameProfile = GetProfileLocalBox( nFrameProfileId) -- calcolo offset perpendicolare local dOverlap = EgtGetInfo( nSashProfileId, WIN_OVERLAP, 'd') local dSashPerpOffset = abs( b3FrameProfile:getMin():getX()) - dOverlap @@ -696,15 +708,11 @@ local function CalculateOutlineFromAreaOutline( nAreaId) nParentBaseOutlineId = EgtGetInfo( nParentBaseOutlineId, WIN_SOU , 'i') sParentProfile = EgtGetInfo( nParentBaseOutlineId or GDB_ID.NULL, WIN_PROFILETYPE) end - local nParentOutlineId = EgtGetInfo( nParentBaseOutlineId, WIN_COPY) + local nParentOutlineId = EgtGetInfo( nParentBaseOutlineId, WIN_COPY, 'i') local nParentProfileId = GetOutlineProfileId( nParentOutlineId, true) - - -- recupero le relative origini - local nFrameParentProfileId = EgtGetFirstNameInGroup( nParentProfileId, WIN_SECTIONFRAME) - local frParentProfileId = EgtFR(nFrameParentProfileId) + -- calcolo il box del riferimento del profilo del frame - local nRefParentProfileId = EgtGetFirstNameInGroup( nParentProfileId, WIN_REF) - local b3FrameProfile = EgtGetBBoxRef( nRefParentProfileId, GDB_BB.STANDARD, frParentProfileId) + local b3FrameProfile = GetProfileLocalBox( nParentProfileId) -- calcolo offset perpendicolare e sulla z dell'anta local dOverlap = EgtGetInfo( nParentProfileId, WIN_FILLOVERLAP, 'd') local dFillPerpOffset = abs( b3FrameProfile:getMin():getX()) - dOverlap @@ -780,12 +788,10 @@ local function GetOutlineProfileType( nOutlineId, bBottomRail) -- ricavo tipo dal nome local sName = EgtGetName( nOutlineId) local nProfileType = WIN_PRF.NULL - if bBottomRail then - nProfileType = WIN_PRF.BOTTOMRAIL - elseif sName == WIN_TOP then + if sName == WIN_TOP then nProfileType = WIN_PRF.TOP elseif sName == WIN_BOTTOM then - nProfileType = WIN_PRF.BOTTOM + nProfileType = EgtIf( bBottomRail, WIN_PRF.BOTTOMRAIL, WIN_PRF.BOTTOM) elseif sName == WIN_LEFT then nProfileType = WIN_PRF.LEFT elseif sName == WIN_RIGHT then @@ -825,15 +831,16 @@ local function GetSplitOtherOutline( nSplitId, nSurfSplit, nOutlineId, bPrevOrNe local nCrv1 = EgtCopyGlob( nGeoOut, nGeoId) local nCrv2 = EgtCopyGlob( nGeoIn, nGeoId) local nCompoTest = EgtCurveCompo( nGeoId, nCrv1) + local dParTest = 0.2 if bPrevOutline then -- considero solo la parte finale del pezzo - EgtTrimCurveStartAtParam( nCompoTest, 0.5) + EgtTrimCurveStartAtParam( nCompoTest, 1 - dParTest) EgtAddCurveCompoLine( nCompoTest, EgtSP( nCrv2)) - EgtTrimCurveEndAtParam( nCrv2, 0.5) + EgtTrimCurveEndAtParam( nCrv2, dParTest) else -- considero solo la parte iniziale del pezzo - EgtTrimCurveEndAtParam( nCompoTest, 0.5) - EgtTrimCurveStartAtParam( nCrv2, 0.5) + EgtTrimCurveEndAtParam( nCompoTest, dParTest) + EgtTrimCurveStartAtParam( nCrv2, 1 - dParTest) EgtAddCurveCompoLine( nCompoTest, EgtSP( nCrv2)) end EgtAddCurveCompoCurve( nCompoTest, nCrv2) @@ -890,10 +897,7 @@ local function GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) -- costruisco una regione approssimata per il pezzo dello split local nGrp = EgtGetParent( nOutlineId) local nSplitProfileId = GetOutlineProfileId( nOutlineId, false) - local nRefId = EgtGetFirstNameInGroup( nSplitProfileId, WIN_REF) - local nFrameId = EgtGetFirstNameInGroup( nSplitProfileId, WIN_SECTIONFRAME) - local frProfile = EgtFR( nFrameId) - local b3Profile = EgtGetBBoxRef( nRefId, GDB_BB.STANDARD, frProfile) + local b3Profile = GetProfileLocalBox( nSplitProfileId) local nCrvOut = EgtCopyGlob( nOutlineId, nGrp) local nCrvIn = EgtCopyGlob( nOutlineId, nGrp) EgtOffsetCurve( nCrvOut, b3Profile:getMax():getX()) @@ -928,17 +932,17 @@ local function GetProfileCtrIn( nPrevOutlineId, nOutlineId, nPrevProfileId) local sPrevCtrIn = WIN_CTRIN -- gestione particolare del caso di profilo di split if not EgtGetFirstNameInGroup( nPrevProfileId, sPrevCtrIn) then - -- recupero la curva di base outline da cui deriva il precedente + -- recupero la curva di base outline da cui deriva il precedente e cerco lo split originale da cui deriva local nPrevSouId = EgtGetInfo( nPrevOutlineId, WIN_COPY, 'i') - local sPrevSouName - repeat + local sPrevSouName = EgtGetName( nPrevSouId) + while nPrevSouId and sPrevSouName ~= WIN_SPLIT do nPrevSouId = EgtGetInfo( nPrevSouId, WIN_SOU, 'i') sPrevSouName = EgtGetName( nPrevSouId or GDB_ID.NULL) - until not nPrevSouId or sPrevSouName == WIN_SPLIT + end -- verifico da quale lato si trova la curva per decidere quale controprofilo considerare - local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) - if dSide == 1 then + local _, _, nSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) + if nSide == 1 then sPrevCtrIn = WIN_CTRIN .. '1' -- dx else sPrevCtrIn = WIN_CTRIN .. '2' -- sx @@ -1024,7 +1028,7 @@ local function GetDeltaProfile( nProfileId, sCtrIn) local dCPDelta = 0 local nSectionFrId = EgtGetFirstNameInGroup( nProfileId, WIN_SECTIONFRAME) - local frSectionFrame = EgtFR( nSectionFrId) + local frSectionFrame = EgtFR( nSectionFrId, GDB_ID.ROOT) local nCPId = EgtGetFirstNameInGroup( nProfileId, sCtrIn) local b3CP = EgtGetBBoxRef( nCPId, GDB_BB.STANDARD, frSectionFrame) if sCtrIn == WIN_CTRIN .. 1 then @@ -1040,11 +1044,8 @@ end local function CreateFrameGeo( nOutlineId, vPrevOutlineId, vNextOutlineId, nStartPartJointType, nEndPartJointType, nGeoLayerId, nProfileLayerId) local nCurrProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) - local nCurrProfileRefId = EgtGetFirstNameInGroup( nCurrProfileId, WIN_REF) -- calcolo spostamento della curva iniziale dovuto a posizione riferimento - local nProfileFrameId = EgtGetFirstNameInGroup( nCurrProfileId, WIN_SECTIONFRAME) - local frProfile = EgtFR( nProfileFrameId) - local b3CurrProfileFrame = EgtGetBBoxRef( nCurrProfileRefId, GDB_BB.STANDARD, frProfile) + local b3CurrProfileFrame = GetProfileLocalBox( nCurrProfileId) local dCurrOffset = b3CurrProfileFrame:getMax():getX() -- creo copie degli outline e le offsetto opportunamente @@ -1229,8 +1230,11 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineCrvNbr, nOutlineLayerI local nEndPartJointType = CalcPartJointType( nProfileTypeE, nEndJointType) -- salvo i valori joint su outline per disegno solido e calcolo dowels - EgtSetInfo( nOutlineId, WIN_STARTJOINT, nStartPartJointType) - EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType) + -- se bottomrail è sicuramente short quindi non salvo il valore che sovrascriverebbe quello del pezzo bottom ( che potrebbe essere short o full) + if nProfileType ~= WIN_PRF.BOTTOMRAIL then + EgtSetInfo( nOutlineId, WIN_STARTJOINT, nStartPartJointType) + EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType) + end -- creo il gruppo con i profili del pezzo local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, vPrevOutlineId, vNextOutlineId, nProfileType) @@ -1248,484 +1252,526 @@ end --------------------------------------------------------------------------------- ---------------------------------- DOWELS ---------------------------------------- ---------------------------------------------------------------------------------- -local function AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nDowelLayerId, nGeoLayerId, nMainExtrusionId) +-- funzione che calcola il riferimento dove posizionare le spine +local function CreateDowelFrameDest( nRefProfileType, nPrevGeo, nGeo, nRefOutline, bFullOrShort, bSashOrFrame) - local sOutlineName = EgtGetName( nOutlineId) - local sPrevOutlineName = EgtGetName( nPrevOutlineId) - - local nGeoInId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_IN) - local nGeoLeftId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_LEFT) - - local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) - local nStartProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) - - local nStartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i') - if nStartJointType == WIN_PART_JNT.ANGLED then - - elseif nStartJointType == WIN_PART_JNT.FULL then - -- recupero profondita' d'inizio e fine - local sStart = EgtIf( sOutlineName == WIN_BOTTOM, WIN_DWL_BOTTOMPERPSTART, WIN_DWL_TOPPERPSTART) - local sEnd = EgtIf( sOutlineName == WIN_BOTTOM, WIN_DWL_BOTTOMPERPEND, WIN_DWL_TOPPERPEND) - - -- calcolo il riferimento del profilo - local nFrameProfile = EgtGetFirstNameInGroup( nStartProfileId, WIN_SECTIONFRAME) - local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) - frOrig:invert() - -- calcolo il riferimento su cui posizionare i dowel - local ptInt = EgtSP( nGeoLeftId) - local vtRef = EgtSV( nGeoLeftId) - local frDest = Frame3d( ptInt, - vtRef) - - -- ciclo sui fori trovati - local nOrigDowelId = EgtGetFirstNameInGroup( nStartProfileId, WIN_DOWEL .. '*') - while nOrigDowelId do - local dStart = EgtGetInfo( nOrigDowelId, sStart, 'd') - if not dStart then - dStart = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPSTART, 'd') or 0 - end - local dEnd = EgtGetInfo( nOrigDowelId, sEnd, 'd') - if not dEnd then - dEnd = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPEND, 'd') or 0 - end - - local nDowelId = EgtCopyGlob( nOrigDowelId, nDowelLayerId) - EgtSetColor( nDowelId, Color3d( 128, 128, 128)) - -- posiziono il dowel grazie ai riferimenti e assegno estrusione e spessore - EgtTransform( nDowelId, frOrig, GDB_RT.GLOB) - EgtTransform( nDowelId, frDest, GDB_RT.GLOB) - EgtMove( nDowelId, dStart * vtRef) - EgtModifyCurveExtrusion( nDowelId, - vtRef) - EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart)) - -- setto info di lavorazione - EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) - EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, WIN_PRC_DWL_SIDETYPE.IN) - - if bCalcSolid then - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nDowelLayerId, nDowelId, vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, - vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - end - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - - elseif nStartJointType == WIN_PART_JNT.SHORT then - -- recupero info di profondita' d'inizio e fine in base al profilo dello start - local sStart = WIN_DWL_TOPPARASTART - local sEnd = WIN_DWL_TOPPARAEND - if sPrevOutlineName == WIN_BOTTOM then - sStart = WIN_DWL_BOTTOMPARASTART - sEnd = WIN_DWL_BOTTOMPARAEND - end - if sOutlineName == WIN_SPLIT then - local sStartProfileType = EgtGetInfo( nStartProfileId, WIN_PRF_TYPE) - if sStartProfileType == WIN_RAIL_BOTTOM then - sStart = WIN_DWL_RAILBOTTOMPARASTART - sEnd = WIN_DWL_RAILBOTTOMPARAEND - elseif sStartProfileType == WIN_SASH_HORIZONTAL then - sStart = WIN_DWL_HORIZONTALSPLITPARASTART - sEnd = WIN_DWL_HORIZONTALSPLITPARAEND - elseif sStartProfileType == WIN_SASH_VERTICAL then - sStart = WIN_DWL_VERTICALSPLITPARASTART - sEnd = WIN_DWL_VERTICALSPLITPARAEND - elseif sStartProfileType == WIN_FRAME_SPLIT or sStartProfileType == WIN_SASH_SPLIT then - sStart = WIN_DWL_SPLITPARASTART - sEnd = WIN_DWL_SPLITPARAEND - end - end - - -- calcolo il riferimento del profilo - local nFrameProfile = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTIONFRAME) - local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) - frOrig:invert() - -- calcolo il riferimento su cui posizionare i dowel - local nLeftCopy = EgtCopyGlob( nGeoLeftId, nDowelLayerId) - EgtExtendCurveStartByLen( nLeftCopy, 200) - EgtExtendCurveEndByLen( nLeftCopy, 200) - local ptInt = EgtIP( nOutlineId, nLeftCopy, ORIG()) - EgtErase( nLeftCopy) - if not ptInt then - return - end - - local dParRef = EgtCurveParamAtPoint( nOutlineId, ptInt) - local vtRef = EgtUV( nOutlineId, dParRef, -1) - local frDest = Frame3d( ptInt, - vtRef) - - -- ciclo sui fori trovati - local nOrigDowelId = EgtGetFirstNameInGroup( nMainProfileId, WIN_DOWEL .. '*') - while nOrigDowelId do - local dStart = EgtGetInfo( nOrigDowelId, sStart, 'd') - if not dStart then - dStart = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPARASTART, 'd') or 0 - end - local dEnd = EgtGetInfo( nOrigDowelId, sEnd, 'd') - if not dEnd then - dEnd = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPARAEND, 'd') or 0 - end - - local nDowelId = EgtCopyGlob( nOrigDowelId, nDowelLayerId) - EgtSetColor( nDowelId, Color3d( 128, 128, 128)) - -- posiziono il dowel grazie ai riferimenti e assegno estrusione e spessore - EgtTransform( nDowelId, frOrig) - EgtTransform( nDowelId, frDest) - EgtMove( nDowelId, vtRef * dStart) - EgtModifyCurveExtrusion( nDowelId, - vtRef) - EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart)) - -- setto info di lavorazione - EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) - EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, WIN_PRC_DWL_SIDETYPE.LEFT) - - if bCalcSolid then - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nDowelLayerId, nDowelId, vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, - vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - end - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end + -- 1) la direzione z è quella del pezzo short nel caso rettangolare + local vtZ + if nRefProfileType == WIN_PRF.TOP then + vtZ = - X_AX() + elseif nRefProfileType == WIN_PRF.BOTTOM or nRefProfileType == WIN_PRF.BOTTOMRAIL then + vtZ = X_AX() + elseif nRefProfileType == WIN_PRF.LEFT then + vtZ = - Y_AX() + elseif nRefProfileType == WIN_PRF.RIGHT then + vtZ = Y_AX() end + local frDest = Frame3d( ORIG(), - vtZ) + + -- 2) punto di origine + local nPrevRight = EgtGetFirstNameInGroup( nPrevGeo, WIN_GEO_RIGHT) + local ptRef1 = EgtIf( bFullOrShort, EgtSP( nPrevRight), EgtEP( nPrevRight)) + local nLeft = EgtGetFirstNameInGroup( nGeo, WIN_GEO_LEFT) + local ptRef2 = EgtIf( bFullOrShort, EgtSP( nLeft), EgtEP( nLeft)) + -- riporto i punti sulla curva di outline su cui va posizionato il profilo con le spine + local _, ptInt1 = EgtPointCurveDist( ptRef1, nRefOutline) + local _, ptInt2 = EgtPointCurveDist( ptRef2, nRefOutline) + + -- nel caso di telaio conviene tenere il punto più "interno" visto che la correzione sarà fatta verso l'esterno + -- nel caso di anta conviene tenere quello più "esterno" visto che la correzione sarà fatta verso l'interno + ptInt1:toLoc( frDest) + ptInt2:toLoc( frDest) + local ptInt + if ptInt1:getX() > ptInt2:getX() then + ptInt = EgtIf( bSashOrFrame, Point3d( ptInt1), Point3d( ptInt2)) + else + ptInt = EgtIf( bSashOrFrame, Point3d( ptInt2), Point3d( ptInt1)) + end + ptInt:toGlob( frDest) + + -- modifico il punto di origine del frame nel punto individuato + frDest:move( ptInt - ORIG()) + + return frDest end ---------------------------------------------------------------------- -local function AddEndDowels( nOutlineId, nEndOutlineId, nProfileLayerId, nDowelLayerId, nGeoLayerId, nMainExtrusionId) +---------------------------------------------------------------------------------- +-- funzione che crea la superficie di estrusione del profilo sCtr +local function CreateSemiProfileSurf( nOutlineId, nProfileId, sCtr, nLayerId) - local sOutlineName = EgtGetName( nOutlineId) - local sEndOutlineName = EgtGetName( nEndOutlineId) - - local nGeoInId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_IN) - local nGeoRightId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_RIGHT) - - local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) - local nEndProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) - - local nEndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i') - if nEndJointType == WIN_PART_JNT.ANGLED then - - elseif nEndJointType == WIN_PART_JNT.FULL then - -- recupero profondita' d'inizio e fine - local sStart = EgtIf( sOutlineName == WIN_BOTTOM, WIN_DWL_BOTTOMPERPSTART, WIN_DWL_TOPPERPSTART) - local sEnd = EgtIf( sOutlineName == WIN_BOTTOM, WIN_DWL_BOTTOMPERPEND, WIN_DWL_TOPPERPEND) - - -- calcolo il riferimento del profilo - local nFrameProfile = EgtGetFirstNameInGroup( nEndProfileId, WIN_SECTIONFRAME) - local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) - frOrig:invert() - -- calcolo il riferimento su cui posizionare i dowel - local ptInt = EgtEP( nGeoRightId) - local vtRef = EgtEV( nGeoRightId) - local frDest = Frame3d( ptInt, - vtRef) - - -- ciclo sui fori trovati - local nOrigDowelId = EgtGetFirstNameInGroup( nEndProfileId, WIN_DOWEL .. '*') - while nOrigDowelId do - local dStart = EgtGetInfo( nOrigDowelId, sStart, 'd') - if not dStart then - dStart = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPSTART, 'd') or 0 + -- creo la curva guida + local nGuideId = EgtCopy( nOutlineId, nLayerId) + EgtExtendCurveStartByLen( nGuideId, 100) + EgtExtendCurveEndByLen( nGuideId, 100) + -- verifico se necessaria inversione della guida nel caso derivi direttamente da split + local nArea = EgtGetParent( EgtGetParent( nOutlineId)) + local nAreaType = EgtGetInfo( nArea, WIN_AREATYPE, 'i') + if nAreaType == WIN_AREATYPES.SPLIT then + local nSouId = EgtGetInfo( nOutlineId, WIN_REF_SPLIT, 'i') + if nSouId then + -- recupero vettore tangente nel punto medio della curva + local ptMidStart = EgtMP( nOutlineId) + local vtMidStart = EgtMV( nOutlineId) + -- recupero vettore tangente nello stesso punto della curva split originale + local dMidStartOnStartSou = EgtCurveParamAtPoint( nSouId, ptMidStart) + local vtMidStartSou = EgtUV( nSouId, dMidStartOnStartSou, -1) + -- se i due vettori non sono orientati nella stessa direzione + if not AreSameVectorApprox( vtMidStart, vtMidStartSou) then + EgtInvertCurve( nGuideId) end - local dEnd = EgtGetInfo( nOrigDowelId, sEnd, 'd') - if not dEnd then - dEnd = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPEND, 'd') or 0 - end - - local nDowelId = EgtCopyGlob( nOrigDowelId, nDowelLayerId) - EgtSetColor( nDowelId, Color3d( 128, 128, 128)) - -- posiziono i fori grazie ai riferimenti e assegno estrusione e spessore - EgtTransform( nDowelId, frOrig) - EgtTransform( nDowelId, frDest) - EgtMove( nDowelId, - vtRef * dStart) - EgtModifyCurveExtrusion( nDowelId, vtRef) - EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart)) - -- setto info di lavorazione - EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) - EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, WIN_PRC_DWL_SIDETYPE.IN) - - if bCalcSolid then - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nDowelLayerId, nDowelId, - vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - end - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - - elseif nEndJointType == WIN_PART_JNT.SHORT then - -- recupero profondita' d'inizio e fine - local sStart = WIN_DWL_TOPPARASTART - local sEnd = WIN_DWL_TOPPARAEND - if sEndOutlineName == WIN_BOTTOM then - sStart = WIN_DWL_BOTTOMPARASTART - sEnd = WIN_DWL_BOTTOMPARAEND - end - if sOutlineName == WIN_SPLIT then - local sEndProfileType = EgtGetInfo( nEndProfileId, WIN_PRF_TYPE) - if sEndProfileType == WIN_RAIL_BOTTOM then - sStart = WIN_DWL_RAILBOTTOMPARASTART - sEnd = WIN_DWL_RAILBOTTOMPARAEND - elseif sEndProfileType == WIN_SASH_HORIZONTAL then - -- non faccio nulla perche' e' uguale al top - elseif sEndProfileType == WIN_SASH_VERTICAL then - sStart = WIN_DWL_VERTICALSPLITPARASTART - sEnd = WIN_DWL_VERTICALSPLITPARAEND - elseif sEndProfileType == WIN_FRAME_SPLIT or sEndProfileType == WIN_SASH_SPLIT then - sStart = WIN_DWL_SPLITPARASTART - sEnd = WIN_DWL_SPLITPARAEND - end - end - - -- calcolo il riferimento del profilo - local nFrameProfile = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTIONFRAME) - local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) - frOrig:invert() - -- calcolo il riferimento su cui posizionare i dowel - local nRightCopy = EgtCopyGlob( nGeoRightId, nDowelLayerId) - EgtExtendCurveStartByLen( nRightCopy, 200) - EgtExtendCurveEndByLen( nRightCopy, 200) - local ptInt = EgtIP( nOutlineId, nRightCopy, ORIG()) - EgtErase( nRightCopy) - if not ptInt then - return - end - local dParRef = EgtCurveParamAtPoint( nOutlineId, ptInt) - local vtRef = EgtUV( nOutlineId, dParRef, -1) - local frDest = Frame3d( ptInt, - vtRef) - - -- ciclo sui fori trovati - local nOrigDowelId = EgtGetFirstNameInGroup( nMainProfileId, WIN_DOWEL .. '*') - while nOrigDowelId do - local dStart = EgtGetInfo( nOrigDowelId, sStart, 'd') - if not dStart then - dStart = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPARASTART, 'd') or 0 - end - local dEnd = EgtGetInfo( nOrigDowelId, sEnd, 'd') - if not dEnd then - dEnd = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPARAEND, 'd') or 0 - end - - local nDowelId = EgtCopyGlob( nOrigDowelId, nDowelLayerId) - EgtSetColor( nDowelId, Color3d( 128, 128, 128)) - -- posiziono i fori grazie ai riferimenti e assegno estrusione e spessore - EgtTransform( nDowelId, frOrig, GDB_RT.GLOB) - EgtTransform( nDowelId, frDest, GDB_RT.GLOB) - EgtMove( nDowelId, - vtRef * dStart) - EgtModifyCurveExtrusion( nDowelId, vtRef) - EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart)) - -- setto info di lavorazione - EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) - EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, WIN_PRC_DWL_SIDETYPE.RIGHT) - - if bCalcSolid then - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nDowelLayerId, nDowelId, - vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - end - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') end end + + -- recupero frame del profilo + local nProfileFrameId = EgtGetFirstNameInGroup( nProfileId, WIN_SECTIONFRAME) + local frOrig = EgtFR( nProfileFrameId, GDB_ID.ROOT) + frOrig:invert() + + -- calcolo il riferimento su cui posizionare il profilo per l'estrusione + local ptRef = EgtSP( nGuideId, GDB_ID.ROOT) + local vtRef = - EgtSV( nGuideId, GDB_ID.ROOT) + local frDest = Frame3d( ptRef, vtRef) + + -- recupero il profilo da estrudere + local nOrigSectionId = EgtGetFirstNameInGroup( nProfileId, sCtr) + local nSectionId = EgtCopyGlob( nOrigSectionId, nLayerId) + + -- posiziono il profilo usando i riferimenti + EgtTransform( nSectionId, frOrig, GDB_RT.GLOB) + EgtTransform( nSectionId, frDest, GDB_RT.GLOB) + + -- creo la superficie + local nSurfId = EgtSurfTmSwept( nLayerId, nSectionId, nGuideId, false, WIN_SURF_APPROX) + EgtErase( nGuideId) + EgtErase( nSectionId) + + return nSurfId end ---------------------------------------------------------------------- --- funzione che calcola intersezione, geometrie e superfici dei dowel degli split -local function CalSplitDowel( nSplitLayerId, nOutlineId, nProfileType, nPartId) +---------------------------------------------------------------------------------- +local function PositionDowel( nDowelId, frOrig, frDest, vtDir, nSurfId) - -- verifico se interseca l'outline che sto analizzando - local nSplitId = EgtGetFirstInGroup( nSplitLayerId) - local ptInt = EgtIP( nOutlineId, nSplitId, EgtSP( nSplitId)) - if not ptInt then - return - end - -- TO DO gestire il caso in cui lo split ha due intersezioni con l'outline - - -- se interseca, recupero il profilo dello split - local nOrigSplitProfileId = GetOutlineProfileId( nSplitId, false) - - -- creo copia del profilo - local nFrameProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) - local nSplitProfileId = EgtCopy( nOrigSplitProfileId, nFrameProfileLayerId) - local sSplitProfileType = EgtGetName( nOrigSplitProfileId) - EgtSetInfo( nSplitProfileId, WIN_PRF_TYPE, sSplitProfileType) - EgtSetName( nSplitProfileId, WIN_PRF_SPLIT) - - -- recupero intersezione con lato In o Out del geo - local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO) - local nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_IN) - local ptInters = EgtIP( nGeoCrvId, nSplitId, EgtSP( nSplitId)) - local sDowelRefSide = WIN_PRC_DWL_SIDETYPE.IN - if not ptInters and nProfileType == WIN_PRF.SPLIT then - nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_OUT) - ptInters = EgtIP( nGeoCrvId, nSplitId, EgtSP( nSplitId)) - sDowelRefSide = WIN_PRC_DWL_SIDETYPE.OUT - end - -- se non trovo intersezione esco ( TO DO da sistemare perchè anche se non trova intersezione potrebbe essere coinvolto dai dowels dello split!) - if not ptInters then - return - end + -- posiziono il dowel utilizzando i riferimenti + EgtTransform( nDowelId, frOrig, GDB_RT.GLOB) + EgtTransform( nDowelId, frDest, GDB_RT.GLOB) + EgtMove( nDowelId, 300 * vtDir) + -- creo il tool corrispondente al dowel + local dRad = EgtArcRadius( nDowelId) + EgtCAvSetStdTool( s_dDowelTol, 2 * dRad, 0) + -- calcolo spostamento per posizionarlo in corrispondenza della superficie + local dStart = EgtCAvToolPosStm( EgtCP( nDowelId), - vtDir, nSurfId, - vtDir) + EgtMove( nDowelId, - dStart * vtDir) - -- recupero frame del profilo e lo applico a tutte le sue geometrie - local nSplitProfileFrameId = EgtGetFirstNameInGroup( nSplitProfileId, WIN_SECTIONFRAME) - local frInvertSplitProfile = EgtFR( nSplitProfileFrameId) - frInvertSplitProfile:invert() - EgtTransform( EgtGetAllInGroup( nSplitProfileId), frInvertSplitProfile) - -- assegno come riferimento del profilo il punto di intersezione e la direzione dello split - local vtDir = - EgtSV( nSplitId) -- se non fosse lineare potrebbe essere end vector ? - EgtChangeGroupFrame( nSplitProfileId, Frame3d( ptInters, vtDir)) - - -- calcolo la direzione del dowel sempre verso l'interno del pezzo - local vtDowelDir = Vector3d( vtDir) - local _, _, nSide = EgtPointCurveDistSide( ptInters + vtDowelDir, nGeoCrvId, Z_AX()) - if nSide == 1 then - -- se a destra della curva significa che la direzione è uscente dal pezzo e va invertita - vtDowelDir = - vtDowelDir - end +end - -- recupero solido del pezzo ( se non esiste è nil) - local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) or GDB_ID.NULL - local nMainExtrusionId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN) - - -- creo fori per spine su Split - local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) +---------------------------------------------------------------------------------- +local function CreateDowel( nOrigDowelId, nLayerId, frOrig, frDest, vtDir, nTestSurfId, sLenKey, sDowelSide, nMainExtrusionId) - -- recupero profondita' d'inizio e fine - local sStart = WIN_DWL_TOPPERPSTART - local sEnd = WIN_DWL_TOPPERPEND - if nProfileType == WIN_PRF.BOTTOM then - sStart = WIN_DWL_BOTTOMPERPSTART - sEnd = WIN_DWL_BOTTOMPERPEND - elseif nProfileType == WIN_PRF.BOTTOMRAIL then - sStart = WIN_DWL_RAILBOTTOMPERPSTART - sEnd = WIN_DWL_RAILBOTTOMPERPEND - elseif nProfileType == WIN_PRF.SPLIT then - local sProfileType = EgtGetInfo( nOutlineId, WIN_PROFILETYPE) - if sProfileType == WIN_SASH_HORIZONTAL then - -- se poggia sul controprofilo CntrIn2 leggo le info dello split orizzontale, altrimenti vanno bene quelle del top - -- ( cfr AddStartDowels e AddEndDowels) - if AreSamePointApprox( ptInt, EgtSP( nSplitId)) then - sStart = WIN_DWL_HORIZONTALSPLITPERPSTART - sEnd = WIN_DWL_HORIZONTALSPLITPERPEND - end - elseif sProfileType == WIN_SASH_VERTICAL then - sStart = WIN_DWL_VERTICALSPLITPERPSTART - sEnd = WIN_DWL_VERTICALSPLITPERPEND - else -- sProfileType == WIN_FRAME_SPLIT - sStart = WIN_DWL_SPLITPERPSTART - sEnd = WIN_DWL_SPLITPERPEND - end - end + -- vtDir rivolta verso interno del pezzo - -- ciclo sui fori trovati - local nOrigDowelId = EgtGetFirstNameInGroup( nSplitProfileId, WIN_DOWEL .. '*') - while nOrigDowelId do - local dStart = EgtGetInfo( nOrigDowelId, sStart, 'd') - if not dStart then - dStart = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPSTART, 'd') - end - local dEnd = EgtGetInfo( nOrigDowelId, sEnd, 'd') - if not dEnd then - dEnd = EgtGetInfo( nOrigDowelId, WIN_DWL_TOPPERPEND, 'd') - end - local nDowelId = EgtCopyGlob( nOrigDowelId, nProcLayerId) - EgtSetColor( nDowelId, Color3d( 128, 128, 128)) - - -- posiziono il dowel e gli assegno estrusione e spessore - EgtMove( nDowelId, vtDowelDir * dStart) - EgtModifyCurveExtrusion( nDowelId, - vtDowelDir) - EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart)) - -- setto info di lavorazione - EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) - EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, sDowelRefSide) - - if bCalcSolid then - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nSolidLayerId, nDowelId, vtDowelDir * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, - vtDowelDir) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - end + local nDowelId = EgtCopyGlob( nOrigDowelId, nLayerId) + EgtSetColor( nDowelId, Color3d( 128, 128, 128)) + + -- posiziono il dowel + PositionDowel( nDowelId, frOrig, frDest, vtDir, nTestSurfId) + + -- assegno estrusione e spessore + local dLen = EgtGetInfo( nOrigDowelId, sLenKey, 'd') + s_dDowelTol + EgtModifyCurveExtrusion( nDowelId, - vtDir) + EgtModifyCurveThickness( nDowelId, - dLen) + + -- setto info di lavorazione + EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE) + EgtSetInfo( nDowelId, WIN_PRC_DWL_SIDE, sDowelSide) - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') + -- eventuale aggiornamento del solido + if nMainExtrusionId then + -- creo solido di estrusione del dowel + local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nLayerId, nDowelId, vtDir * dLen) + -- sottraggo il dowel al solido + EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) + EgtErase( nDowelExtrusionId) end end ---------------------------------------------------------------------------------- --- funzione che cicla ricorsivamente sulle aree e sottoaree relative al pezzo per aggiungere gli split dowels -local function AddAreaSplitDowels( nOutlineId, nPartId, nProfileType, nAreaLayerId) +-- funzione che calcola la correzione da applicare al frame delle spine per evitare che fuoriescano dal pezzo da un lato visibile ( esterno per ante ed interno per telaio) +local function CalcDowelFrameCorrection( nOutlineId, nPrevOutlineId, nDowelRef, frOrig, frDest, nTestSurfPos, nTestSurfPosPrev, nTestSurf, vtMove, nLayerId, sLenKey, sPrevLenKey) - -- verifico la presenza di eventuali split nell'area corrente - local nSplitLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_SPLIT) - if nSplitLayerId then - local nSplitType = EgtGetInfo( nSplitLayerId, WIN_SPLITTYPE, 'i') or WIN_SPLITTYPES.NULL - if nSplitType ~= WIN_SPLITTYPES.FRENCH then - CalSplitDowel( nSplitLayerId, nOutlineId, nProfileType, nPartId) + local dMove = 0 + -- se le curve sono due linee ortogonali non serve correzione + if EgtGetType( nOutlineId) == GDB_TY.CRV_LINE and EgtGetType( nPrevOutlineId) == GDB_TY.CRV_LINE then + local vt1 = EgtSV( nPrevOutlineId) + local vt2 = EgtSV( nOutlineId) + local dAng = GetAngleXY( vt1, vt2) + if abs( abs( dAng) - 90) < GEO.EPS_SMALL then + return dMove end end - -- verifico la presenza di split nelle sottoaree - local nChildAreaId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREA .. '*') - while nChildAreaId do - local nAreaType = EgtGetInfo( nChildAreaId, WIN_AREATYPE, 'i') - if nAreaType == WIN_AREATYPES.SPLIT then - AddAreaSplitDowels( nOutlineId, nPartId, nProfileType, nChildAreaId) + -- 1) verifico posizione per il pezzo corrente + -- posiziono il dowel + local nDowel1 = EgtCopyGlob( nDowelRef, nLayerId) + PositionDowel( nDowel1, frOrig, frDest, - frDest:getVersZ(), nTestSurfPos) + -- verifico se la faccia di fondo fuoriesce dalla superficie di test + local dLen = EgtGetInfo( nDowel1, sLenKey, 'd') + s_dDowelTol + local dMove1 = EgtCAvToolPosStm( EgtCP( nDowel1) - frDest:getVersZ() * dLen, frDest:getVersZ(), nTestSurf, vtMove) + + -- 2) verifico posizione per il pezzo precedente + -- posiziono il dowel + local nDowel2 = EgtCopyGlob( nDowelRef, nLayerId) + PositionDowel( nDowel2, frOrig, frDest, frDest:getVersZ(), nTestSurfPosPrev) + -- verifico se la faccia di fondo fuoriesce dalla superficie di test + local dPrevLen = EgtGetInfo( nDowel2, sPrevLenKey, 'd') + s_dDowelTol + local dMove2 = EgtCAvToolPosStm( EgtCP( nDowel2) + frDest:getVersZ() * dPrevLen, - frDest:getVersZ(), nTestSurf, vtMove) + + EgtErase( nDowel1) + EgtErase( nDowel2) + + -- calcolo la correzione complessiva + dMove = max( dMove1, dMove2) + return dMove +end + +---------------------------------------------------------------------------------- +local function CalcDowels( nOutlineId, nPrevOutlineId, bSashOrFrame, bBottomRail) + + -- recupero i pezzi + local nPart = EgtGetInfo( nOutlineId, WIN_REF_PART, 'i') + local nPrevPart = EgtGetInfo( nPrevOutlineId, WIN_REF_PART, 'i') + if bBottomRail then + if EgtGetName( nOutlineId) == WIN_BOTTOM then + nPart = EgtGetInfo( nOutlineId, WIN_REF_BOTTOMRAIL_PART, 'i') + else + nPrevPart = EgtGetInfo( nPrevOutlineId, WIN_REF_BOTTOMRAIL_PART, 'i') end + end + + -- recupero i layer delle lavorazioni + local nLayerId = EgtGetFirstNameInGroup( nPart, WIN_PRC) + local nPrevLayerId = EgtGetFirstNameInGroup( nPrevPart, WIN_PRC) + + -- recupero i profili + local nProfileLay = EgtGetFirstNameInGroup( nPart, WIN_PROFILE) + local nProfileId = EgtGetFirstNameInGroup( nProfileLay, WIN_PRF_MAIN) + local nPrevProfileLay = EgtGetFirstNameInGroup( nPrevPart, WIN_PROFILE) + local nPrevProfileId = EgtGetFirstNameInGroup( nPrevProfileLay, WIN_PRF_MAIN) + + -- recupero i geo + local nGeo = EgtGetFirstNameInGroup( nPart, WIN_GEO) + local nPrevGeo = EgtGetFirstNameInGroup( nPrevPart, WIN_GEO) + + -- recupero i tipi di profilo + local nPrevProfileType = GetOutlineProfileType( nPrevOutlineId, bBottomRail) + local nProfileType = GetOutlineProfileType( nOutlineId, bBottomRail) + -- caso particolare del triangolo : se lato top contro bottom il top deve essere gestito come un left/right + if nProfileType == WIN_PRF.TOP and nPrevProfileType == WIN_PRF.BOTTOM then + nProfileType = WIN_PRF.RIGHT + elseif nProfileType == WIN_PRF.BOTTOM and nPrevProfileType == WIN_PRF.TOP then + nPrevProfileType = WIN_PRF.LEFT + end + + -- recupero i solidi + local nPrevSolidId, nSolidId + if bCalcSolid then + local nSolidLay = EgtGetFirstNameInGroup( nPart, WIN_SOLID) + nSolidId = EgtGetFirstNameInGroup( nSolidLay, WIN_SRF_MAIN) + local nPrevSolidLay = EgtGetFirstNameInGroup( nPrevPart, WIN_SOLID) + nPrevSolidId = EgtGetFirstNameInGroup( nPrevSolidLay, WIN_SRF_MAIN) + end + + -- recupero il tipo di giunzione + local nJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i') + if bBottomRail then + if EgtGetName( nOutlineId) == WIN_BOTTOM then + nJointType = WIN_PART_JNT.SHORT + else + nJointType = WIN_PART_JNT.FULL + end + end + if nJointType == WIN_PART_JNT.ANGLED then + -- TO DO + + elseif nJointType == WIN_PART_JNT.FULL then + + -- calcolo il riferimento del profilo + local nFrameProfile = EgtGetFirstNameInGroup( nPrevProfileId, WIN_SECTIONFRAME) + local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) + frOrig:invert() + + -- calcolo il riferimento su cui posizionare i dowels + local frDest = CreateDowelFrameDest( nPrevProfileType, nPrevGeo, nGeo, nPrevOutlineId, true, bSashOrFrame) + + -- recupero info con la lunghezza ( dipendono dal profilo del pezzo full) + local sLenKey = EgtIf( nProfileType == WIN_PRF.BOTTOM, WIN_DWL_BOTTOM_PERP_LEN, WIN_DWL_TOP_PERP_LEN) + local sPrevLenKey = EgtIf( nProfileType == WIN_PRF.BOTTOM, WIN_DWL_BOTTOM_PARA_LEN, WIN_DWL_TOP_PARA_LEN) + + -- superficie test per il posizionamento dei dowels + local nTestSurf = CreateSemiProfileSurf( nOutlineId, nProfileId, WIN_CTRIN, nLayerId) + local nTestSurfInverted = EgtCopyGlob( nTestSurf, nLayerId) + EgtInvertSurf( nTestSurfInverted) + + -- superficie test per la traslazione dei dowels + local nTestSurf2 = CreateSemiProfileSurf( nPrevOutlineId, nPrevProfileId, EgtIf( bSashOrFrame, WIN_OUT, WIN_IN), nLayerId) + EgtInvertSurf( nTestSurf2) + -- direzione per la traslazione dei dowels + local vtMove = EgtIf( bSashOrFrame, - frDest:getVersX(), frDest:getVersX()) + + -- analizzo le singole file di dowels + for k = 1, 3 do + -- recupero i dowels della fila k-esima + local vDowels = EgtGetNameInGroup( nPrevProfileId, WIN_DOWEL .. 'Row' .. tostring( k)) + if not vDowels then + break + end + -- recupero il dowel nella posizione più problematica ( per le ante è quello più esterno, per il telaio quello più interno) + local nDowelRef = EgtIf( bSashOrFrame, vDowels[1], vDowels[#vDowels]) + -- calcolo correzione da applicare al frame affinchè i dowels non fuoriescano da un lato visibile ( esterno per ante ed interno per telaio) + local dMove = CalcDowelFrameCorrection( nOutlineId, nPrevOutlineId, nDowelRef, frOrig, frDest, nTestSurfInverted, nTestSurf, nTestSurf2, vtMove, nLayerId, sLenKey, sPrevLenKey) + local frDestDowel = Frame3d( frDest) + frDestDowel:move( dMove * vtMove) + for i = 1, #vDowels do + -- dowels per pezzo corrente + CreateDowel( vDowels[i], nLayerId, frOrig, frDestDowel, - frDestDowel:getVersZ(), nTestSurfInverted, sLenKey, WIN_PRC_DWL_SIDETYPE.IN, nSolidId) + -- dowels per prezzo precedente + CreateDowel( vDowels[i], nPrevLayerId, frOrig, frDestDowel, frDestDowel:getVersZ(), nTestSurf, sPrevLenKey, WIN_PRC_DWL_SIDETYPE.RIGHT, nPrevSolidId) + end + end + + EgtErase( nTestSurf) + EgtErase( nTestSurfInverted) + EgtErase( nTestSurf2) + + + elseif nJointType == WIN_PART_JNT.SHORT then + + -- calcolo il riferimento del profilo + local nFrameProfile = EgtGetFirstNameInGroup( nProfileId, WIN_SECTIONFRAME) + local frOrig = EgtFR( nFrameProfile, GDB_ID.ROOT) + frOrig:invert() + + -- calcolo il riferimento su cui posizionare i dowels + local frDest = CreateDowelFrameDest( nProfileType, nPrevGeo, nGeo, nOutlineId, false, bSashOrFrame) + + -- recupero info con la lunghezza ( dipendono dal profilo del pezzo full, quindi da prezzo prev) + local sLenKey = WIN_DWL_TOP_PARA_LEN + local sPrevLenKey = WIN_DWL_TOP_PERP_LEN + if nPrevProfileType == WIN_PRF.BOTTOM then + sLenKey = WIN_DWL_BOTTOM_PARA_LEN + sPrevLenKey = WIN_DWL_BOTTOM_PERP_LEN + elseif nPrevProfileType == WIN_PRF.BOTTOM_RAIL then + sLenKey = WIN_DWL_BOTTOMRAIL_PARA_LEN + sPrevLenKey = WIN_DWL_BOTTOMRAIL_PERP_LEN + end + + -- superficie test per il posizionamento dei dowels + local nTestSurf = CreateSemiProfileSurf( nPrevOutlineId, nPrevProfileId, WIN_CTRIN, nLayerId) + local nTestSurfInverted = EgtCopyGlob( nTestSurf, nLayerId) + EgtInvertSurf( nTestSurfInverted) + + -- superficie test per la traslazione dei dowels + local nTestSurf2 = CreateSemiProfileSurf( nOutlineId, nProfileId, EgtIf( bSashOrFrame, WIN_OUT, WIN_IN), nLayerId) + EgtInvertSurf( nTestSurf2) + -- direzione per la traslazione dei dowels + local vtMove = EgtIf( bSashOrFrame, - frDest:getVersX(), frDest:getVersX()) + + -- analizzo le singole file di dowels + for k = 1, 3 do + -- recupero i dowels sulla fila k-esima + local vDowels = EgtGetNameInGroup( nProfileId, WIN_DOWEL .. 'Row' .. tostring(k)) + if not vDowels then + break + end + -- recupero il dowel nella posizione più problematica ( per le ante è quello più esterno, per il telaio quello più interno) + local nDowelRef = EgtIf( bSashOrFrame, vDowels[1], vDowels[#vDowels]) + -- calcolo correzione da applicare al frame affinchè i dowels non fuoriescano da un lato visibile ( esterno per ante ed interno per telaio) + local dMove = CalcDowelFrameCorrection( nOutlineId, nPrevOutlineId, nDowelRef, frOrig, frDest, nTestSurf, nTestSurfInverted, nTestSurf2, vtMove, nLayerId, sLenKey, sPrevLenKey) + local frDestDowel = Frame3d( frDest) + frDestDowel:move( dMove * vtMove) + for i = 1, #vDowels do + -- dowels per pezzo corrente + CreateDowel( vDowels[i], nLayerId, frOrig, frDestDowel, - frDestDowel:getVersZ(), nTestSurf, sLenKey, WIN_PRC_DWL_SIDETYPE.LEFT, nSolidId) + -- dowels per prezzo precedente + CreateDowel( vDowels[i], nPrevLayerId, frOrig, frDestDowel, frDestDowel:getVersZ(), nTestSurfInverted, sPrevLenKey, WIN_PRC_DWL_SIDETYPE.IN, nPrevSolidId) + end + end + + EgtErase( nTestSurf) + EgtErase( nTestSurfInverted) + EgtErase( nTestSurf2) + end + +end + +---------------------------------------------------------------------------------- +local function CalcSplitDowels( nSplitId, vOutlines, bStartOrEnd) + + -- TO DO : da gestire incrocio dowels di tre pezzi + + -- recupero il pezzo dello split + local nSplitPart = EgtGetInfo( nSplitId, WIN_REF_PART, 'i') + -- recupero il profilo originale dello split e il suo frame + local nSplitProfile = GetOutlineProfileId( nSplitId, false) + local nSplitProfileFrameId = EgtGetFirstNameInGroup( nSplitProfile, WIN_SECTIONFRAME) + local frOrig = EgtFR( nSplitProfileFrameId, GDB_ID.ROOT) + frOrig:invert() + -- recupero il gruppo delle lavorazioni + local nSplitLayerId = EgtGetFirstNameInGroup( nSplitPart, WIN_PRC) + -- recupero eventuale solido + local nSplitSolidId + if bCalcSolid then + local nSplitSolidLayerId = EgtGetFirstNameInGroup( nSplitPart, WIN_SOLID) + nSplitSolidId = EgtGetFirstNameInGroup( nSplitSolidLayerId, WIN_SRF_MAIN) + end + -- indviduo il lato su cui andranno i dowels + local sSplitDowelSide = WIN_PRC_DWL_SIDETYPE.RIGHT + if bStartOrEnd then + sSplitDowelSide = WIN_PRC_DWL_SIDETYPE.LEFT + end + + local ptRef = EgtIf( bStartOrEnd, EgtSP( nSplitId), EgtEP( nSplitId)) + + for i = 1, #vOutlines do + + -- recupero il pezzo associato e il suo outline di riferimento + local nPartId = FindAssociatedPart( vOutlines[i]) + local nOutlineId = EgtGetInfo( nPartId, WIN_REF_OUTLINE, 'i') + local nProfileType = GetOutlineProfileType( nOutlineId, true) + + -- calcolo il frame di destinazione + -- trovo intersezione dello split con lato In o Out del geo + local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO) + local nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_IN) + local ptInters = EgtIP( nGeoCrvId, nSplitId, ptRef) + local sDowelSide = WIN_PRC_DWL_SIDETYPE.IN + if not ptInters and nProfileType == WIN_PRF.SPLIT then + nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_OUT) + ptInters = EgtIP( nGeoCrvId, nSplitId, ptRef) + sDowelSide = WIN_PRC_DWL_SIDETYPE.OUT + end + -- se non trovo intersezione esco + if not ptInters then + return + end + -- TO DO : gestione split non lineare + local frDest = Frame3d( ptInters, - EgtSV( nSplitId)) + + -- recupero il layer con le lavorazioni + local nLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) + + -- nel layer dei profili del pezzo aggiungo il profilo dello split posizionato correttamente + local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) + local nSplitProfileCopyId = EgtCopy( nSplitProfile, nProfileLayerId) + local sSplitProfileType = EgtGetName( nSplitProfile) + EgtSetInfo( nSplitProfileCopyId, WIN_PRF_TYPE, sSplitProfileType) + EgtSetName( nSplitProfileCopyId, WIN_PRF_SPLIT) + -- posiziono il profilo sulla curva di split + EgtTransform( EgtGetAllInGroup( nSplitProfileCopyId), frOrig, GDB_RT.GLOB) + EgtChangeGroupFrame( nSplitProfileCopyId, frDest, GDB_RT.GLOB) + + -- recupero eventuale solido + local nSolidId + if bCalcSolid then + local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) + nSolidId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN) + end + + -- recupero le chiavi delle lunghezze ( dipendono dal profilo del pezzo su cui poggia lo split) + local sSplitLenKey = WIN_DWL_TOP_PARA_LEN + local sLenKey = WIN_DWL_TOP_PERP_LEN + if nProfileType == WIN_PRF.BOTTOM then + sSplitLenKey = WIN_DWL_BOTTOM_PARA_LEN + sLenKey = WIN_DWL_BOTTOM_PERP_LEN + elseif nProfileType == WIN_PRF.BOTTOMRAIL then + sSplitLenKey = WIN_DWL_RAILBOTTOM_PARA_LEN + sLenKey = WIN_DWL_RAILBOTTOM_PERP_LEN + elseif nProfileType == WIN_PRF.SPLIT then + sSplitLenKey = WIN_DWL_SPLIT_PARA_LEN + sLenKey = WIN_DWL_SPLIT_PERP_LEN + end + + -- creo la superficie di test per il posizionamento dei dowels + local nProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) + local sCtr = GetProfileCtrIn( nOutlineId, nSplitId, nProfileId) + local nTestSurf = CreateSemiProfileSurf( nOutlineId, nProfileId, sCtr, nSplitLayerId) + local nTestSurfInverted = EgtCopyGlob( nTestSurf, nSplitLayerId) + if sDowelSide == WIN_PRC_DWL_SIDETYPE.OUT then + EgtInvertSurf( nTestSurf) + else + EgtInvertSurf( nTestSurfInverted) + end + + -- calcolo le direzioni entranti nei pezzi + local vtSplitDir = EgtIf( bStartOrEnd, - frDest:getVersZ(), frDest:getVersZ()) + local vtDir = frDest:getVersZ() + local _, _, nSide = EgtPointCurveDistSide( ptInters + vtDir, nGeoCrvId, Z_AX()) + if nSide == 1 then + -- se a destra della curva significa che la direzione è uscente dal pezzo e va invertita + vtDir = - vtDir + end + + -- aggiungo i dowels + local vDowels = EgtGetNameInGroup( nSplitProfile, WIN_DOWEL .. '*') or {} + for i = 1, #vDowels do + -- split + CreateDowel( vDowels[i], nSplitLayerId, frOrig, frDest, vtSplitDir, nTestSurf, sSplitLenKey, sSplitDowelSide, nSplitSolidId) + -- pezzo + CreateDowel( vDowels[i], nLayerId, frOrig, frDest, vtDir, nTestSurfInverted, sLenKey, sDowelSide, nSolidId) + end + + EgtErase( nTestSurf) + EgtErase( nTestSurfInverted) + + end +end + +---------------------------------------------------------------------------------- +-- funzione che calcola le spine +local function CalculateAreaDowels( nAreaId) + + local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') + local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE) + if nAreaType == WIN_AREATYPES.FRAME or nAreaType == WIN_AREATYPES.SASH then + -- verifico se presente bottomrail + local bBottomRail = EgtGetInfo( nOutlineLayerId, WIN_BOTTOMRAIL, 'b') or false + -- aggiungo le spine sui pezzi dell'area + local nOutline = EgtGetFirstInGroup( nOutlineLayerId) + local nPrevOutline = EgtGetLastInGroup( nOutlineLayerId) + while nOutline do + -- aggiungo spine su nOutline e nPrevOutline nel loro punto di giunzione + CalcDowels( nOutline, nPrevOutline, nAreaType == WIN_AREATYPES.SASH, false) + -- bottomrail + if bBottomRail and ( EgtGetName( nOutline) == WIN_BOTTOM or EgtGetName( nPrevOutline) == WIN_BOTTOM) then + CalcDowels( nOutline, nPrevOutline, false, true) + end + -- aggiorno per iterazione successiva + nPrevOutline = nOutline + nOutline = EgtGetNext( nOutline) + end + end + + -- verifico se c'e' uno split + local nSplitLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_SPLIT) + if nSplitLayerId then + local nSplitType = EgtGetInfo( nSplitLayerId, WIN_SPLITTYPE, 'i') or WIN_SPLITTYPES.NULL + -- se split non è di tipo french ha un pezzo associato per il quale vanno calcolate le spine + if nSplitType ~= WIN_SPLITTYPES.FRENCH then + local nSplitId = EgtGetFirstInGroup( nSplitLayerId) + -- recupero le curve su cui poggia lo split + local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( WIN_PRF.SPLIT, nSplitId, nOutlineLayerId) + CalcSplitDowels( nSplitId, vPrevOutlineId, true) + CalcSplitDowels( nSplitId, vNextOutlineId, false) + end + end + + -- calcolo le spine delle sottoaree + local nChildAreaId = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*') + while nChildAreaId do + CalculateAreaDowels( nChildAreaId) nChildAreaId = EgtGetNextName( nChildAreaId, WIN_AREA .. '*') end end ----------------------------------------------------------------------------------- --- funzione che aggiunge al solido i dowels degli split che lo intersecano -local function AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType) - - -- se profilo bottom con BottomRail esco ( gli split dowels saranno aggiuti sul BottomRail associato) - if nProfileType == WIN_PRF.BOTTOM then - local bBottomRail = EgtGetInfo( nOutlineLayerId, WIN_BOTTOMRAIL, 'b') or false - if bBottomRail then - return - end - end - - -- recupero area del pezzo - local nAreaLayerId = EgtGetParent( nOutlineLayerId) - -- aggiungo gli split dowels a partire dall'area corrente - AddAreaSplitDowels( nOutlineId, nPartId, nProfileType, nAreaLayerId) -end - ---------------------------------------------------------------------- --- funzione che crea i fori per le spine -local function CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType) - - -- creo fori per spine su Start ed End - local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) - local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) - local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) - local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO) - local nMainExtrusionId - if bCalcSolid then - local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) - nMainExtrusionId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN) - end - for i = 1, #vPrevOutlineId do - AddStartDowels( nOutlineId, vPrevOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) - end - for i = 1, #vNextOutlineId do - AddEndDowels( nOutlineId, vNextOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) - end - - -- split dowels - AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType) -end ---------------------------------------------------------------------------------- @@ -1754,6 +1800,10 @@ local function CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileI else local StartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i') + if nProfileType == WIN_PRF.BOTTOMRAIL then + -- l'info nella curva si riferisce al pezzo bottom, il bottomrail viene sempre forzato a short + StartJointType = WIN_PART_JNT.SHORT + end if StartJointType == WIN_PART_JNT.ANGLED then vsStartProfileType = { WIN_MINIZINKEN} elseif StartJointType == WIN_PART_JNT.SHORT then @@ -1763,6 +1813,9 @@ local function CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileI end local EndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i') + if nProfileType == WIN_PRF.BOTTOMRAIL then + EndJointType = WIN_PART_JNT.SHORT + end if EndJointType == WIN_PART_JNT.ANGLED then vsEndProfileType = { WIN_MINIZINKEN} elseif EndJointType == WIN_PART_JNT.SHORT then @@ -1840,7 +1893,7 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) for i = 1, #vPrevGeoId do -- posiziono il profilo Start local nRefStartProfileId = EgtGetFirstNameInGroup( vStartProfileId[i], WIN_REF) - local b3RefStartProfile = EgtGetBBoxGlob( nRefStartProfileId, GDB_BB.STANDARD) + local b3RefStartProfile = EgtGetBBoxGlob( nRefStartProfileId, GDB_BB.STANDARD) -- creo guida per estrusione con estensione in tangenza local nStartGuideId = EgtCopy( vPrevGeoId[i], nSolidLayerId) if EgtGetType( nStartGuideId) == GDB_TY.CRV_LINE then @@ -1865,13 +1918,9 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) if bSplitInsideSplitArea then -- verifico se il suo start deriva da uno split local vStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'vi') - local nStartSouId = vStartId[i] - local sStartSouName - repeat - nStartSouId = EgtGetInfo( nStartSouId, WIN_SOU, 'i') - sStartSouName = EgtGetName( nStartSouId or GDB_ID.NULL) - until not nStartSouId or sStartSouName == WIN_SPLIT - if sStartSouName == WIN_SPLIT then + local nStartOutlineId = EgtGetInfo( vStartId[i], WIN_COPY, 'i') + local nStartSouId = EgtGetInfo( nStartOutlineId, WIN_REF_SPLIT, 'i') + if nStartSouId then -- recupero vettore tangente nel punto medio della curva di contorno local ptMidStart = EgtMP( vStartId[i]) local vtMidStart = EgtMV( vStartId[i]) @@ -1934,13 +1983,9 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) if bSplitInsideSplitArea then -- verifico se end deriva da split local vEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'vi') - local nEndSouId = vEndId[i] - local sEndSouName - repeat - nEndSouId = EgtGetInfo( nEndSouId, WIN_SOU) - sEndSouName = EgtGetName( nEndSouId or GDB_ID.NULL) - until not nEndSouId or sEndSouName == WIN_SPLIT - if sEndSouName == WIN_SPLIT then + local nEndOutlineId = EgtGetInfo( vEndId[i], WIN_COPY, 'i') + local nEndSouId = EgtGetInfo( nEndOutlineId, WIN_REF_SPLIT, 'i') + if nEndSouId then -- recupero vettore tangente nel punto medio della curva di contorno local ptMidEnd = EgtMP( vEndId[i]) local vtMidEnd = EgtMV( vEndId[i]) @@ -2026,8 +2071,6 @@ local function CreatePartFromOutline( nAreaLayerId, nOutlineId, nOutlineCrvNbr, if bCalcSolid then CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) end - -- calcolo i fori per le spine - CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType) -- b) Fill elseif nAreaType == WIN_AREATYPES.FILL then @@ -2072,8 +2115,8 @@ local function GetStripNearestToOutline( nPrevProfileId, nPrevOutlineId, nOutlin until not nPrevSouId or sPrevSouName == WIN_SPLIT -- verifico da quale lato si trova la curva per decidere quale controprofilo considerare - local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) - if dSide == 1 then + local _, _, nSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) + if nSide == 1 then nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '1') -- dx else nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '2') -- sx @@ -2158,10 +2201,7 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) EgtExtendCurveEndByLen( nStartStripGuideId, 10) -- estrudo Strip start - local nStartProfileFrameId = EgtGetFirstNameInGroup( nStartProfileId, WIN_SECTIONFRAME) - local frStartProfile = EgtFR( nStartProfileFrameId, GDB_ID.ROOT) - local nRefStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, WIN_REF) - local b3RefStartProfile = EgtGetBBoxRef( nRefStartProfileId, GDB_BB.STANDARD, frStartProfile) + local b3RefStartProfile = GetProfileLocalBox( nStartProfileId) local nStartStripProfileId = EgtLine( nStartProfileId, ptStripMinStart, ptStripMinStart - Z_AX() * b3RefStartProfile:getDimY(), GDB_RT.GLOB) EgtInvertCurve( nStartStripProfileId) local nStartStripExtrusionId = EgtSurfTmSwept( nSolidLayerId, nStartStripProfileId, nStartStripGuideId, false, WIN_SURF_APPROX) @@ -2183,10 +2223,7 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) EgtInvertCurve( nEndStripGuideId) -- estrudo Strip end - local nEndProfileFrameId = EgtGetFirstNameInGroup( nEndProfileId, WIN_SECTIONFRAME) - local frEndProfile = EgtFR( nEndProfileFrameId, GDB_ID.ROOT) - local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF) - local b3RefEndProfile = EgtGetBBoxRef(nRefEndProfileId, GDB_BB.STANDARD, frEndProfile) + local b3RefEndProfile = GetProfileLocalBox( nEndProfileId) local nEndStripProfileId = EgtLine( nEndProfileId, ptStripMinEnd, ptStripMinEnd - Z_AX() * b3RefEndProfile:getDimY(), GDB_RT.GLOB) EgtInvertCurve( nEndStripProfileId) local nEndStripExtrusionId = EgtSurfTmSwept( nSolidLayerId, nEndStripProfileId, nEndStripGuideId, false, WIN_SURF_APPROX) @@ -2306,6 +2343,8 @@ function WinCalculate.CreatePartFromArea( nFrameId) CalculateAreaOutline( nFrameId) -- creo pezzi CalculateAreaParts( nFrameId) + -- calcolo le spine + CalculateAreaDowels( nFrameId) end --------------------------------------------------------------------- @@ -2657,7 +2696,7 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) if bOnlyRequest then return sInputFile end - + -- attendo scrittura output local nWait = 0 while not EgtExistsFile( sOutputFile) and nWait < 20 do