diff --git a/.vscode/settings.json b/.vscode/settings.json index 5452152..afdd2c3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -109,7 +109,12 @@ "EgtReplaceString", "EgtCircle", "EgtArc2PV", - "EgtTdbSetCurrTool" + "EgtTdbSetCurrTool", + "EgtSurfTmSubtract", + "EgtSurfTmIntersect", + "GDB_IN", + "GEO", + "dist" ], "Lua.diagnostics.disable": [ "empty-block" diff --git a/Profiles/Main.lua b/Profiles/Main.lua index 31e8a3c..4df78ce 100644 --- a/Profiles/Main.lua +++ b/Profiles/Main.lua @@ -382,6 +382,80 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- aggiungo vetro -- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) +------------------------ Finestra tripla anta battente / ricevente / ricevente ------------------------ + +-- -- definisco divisioni +-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) +-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) +-- +-- -- aggiungo prima anta +-- local SashJointType = WIN_JNT.FULL_V +-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE) +-- -- aggiungo vetro +-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo seconda anta +-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE_IN) +-- -- aggiungo vetro +-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo terza anta +-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE_OUT) +-- -- aggiungo vetro +-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) + + +------------------------ Finestra tripla anta battente / battente / ricevente ------------------------ + +-- -- definisco divisioni +-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) +-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) +-- +-- -- aggiungo prima anta +-- local SashJointType = WIN_JNT.FULL_V +-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE_OUT) +-- -- aggiungo vetro +-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo seconda anta +-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE_IN) +-- -- aggiungo vetro +-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo terza anta +-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE) +-- -- aggiungo vetro +-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) + + +------------------------ Finestra quattro ante battente / battente / ricevente / ricevente ------------------------ + +-- -- definisco divisioni +-- local nArea1Id, nAreaTmpId = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 4, _, WIN_SPLITTYPES.FRENCH) +-- local nArea2Id, nAreaTmp1Id = WinCreate.AddSplit( nAreaTmpId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 4, _, WIN_SPLITTYPES.FRENCH) +-- local nArea3Id, nArea4Id = WinCreate.AddSplit( nAreaTmp1Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 4, _, WIN_SPLITTYPES.FRENCH) +-- +-- -- aggiungo prima anta +-- local SashJointType = WIN_JNT.FULL_V +-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE_OUT) +-- -- aggiungo vetro +-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo seconda anta +-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE_IN) +-- -- aggiungo vetro +-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo terza anta +-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE_IN) +-- -- aggiungo vetro +-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) +-- +-- -- aggiungo quarta anta +-- local nSash4Id = WinCreate.AddSash( nArea4Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE_OUT) +-- -- aggiungo vetro +-- local nFill4Id = WinCreate.AddFill( nSash4Id, WIN_FILLTYPES.GLASS) + ------------------------ Finestra sei ante con montanti verticali e orizzontale ------------------------ diff --git a/Profiles/Profilo78 - Offset - Copy (46).nge b/Profiles/Profilo78 - Offset - Copy (46).nge new file mode 100644 index 0000000..bceecb3 Binary files /dev/null and b/Profiles/Profilo78 - Offset - Copy (46).nge differ diff --git a/Profiles/Profilo78 - Offset.nge b/Profiles/Profilo78 - Offset.nge index bceecb3..5f0a680 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 4d59ec7..cbc22b5 100644 --- a/Profiles/WinConst.lua +++ b/Profiles/WinConst.lua @@ -88,6 +88,10 @@ WIN_SASHTYPES = { NULL = 0, ACTIVE = 1, INACTIVE = 2, + ACTIVE_IN = 3, + ACTIVE_OUT = 4, + INACTIVE_IN = 5, + INACTIVE_OUT = 6, } WIN_SURF_APPROX = 0.05 @@ -99,6 +103,7 @@ WIN_FRAME = 'Frame' WIN_AREAOUTLINE = 'BaseOutline' WIN_OUTLINE = 'Outline' WIN_SELECTION = 'Selection' +WIN_SPLITSELECTION = 'SplitSelection' WIN_ORIGOUTLINE = 'OrigOutline' WIN_GEO = 'Geo' WIN_SOLID = 'Solid' @@ -139,6 +144,8 @@ WIN_FIXED_TOP = 'Fixed_Top' WIN_FIXED_BOTTOM = 'Fixed_Bottom' WIN_SASH_ACTIVE = 'Sash_Active' WIN_SASH_INACTIVE = 'Sash_Inactive' +WIN_FRENCH_IN = 'French_In' +WIN_FRENCH_OUT = 'French_Out' WIN_SASH_SPLIT = 'Sash_Split' WIN_FRAME_SPLIT = 'Frame_Split' @@ -209,6 +216,8 @@ WIN_PRC_TOOL_NAME = 'TOOL_NAME' WIN_PRC_OFFL = 'OFFL' WIN_PRC_OFFR = 'OFFR' +WIN_CRV_ON_FRENCH_SPLIT = 'OutlineOnFrenchSplit' + WIN_MAINGUIDE = 'MainGuide' WIN_STARTGUIDE = 'StartGuide' WIN_ENDGUIDE = 'EndGuide' @@ -256,6 +265,8 @@ WIN_DWL_BOTTOMHORIZONTALSPLITPARAEND = 'BottomHorizontalSplitParaEnd' WIN_DWL_HORIZONTALSPLITPERPSTART = 'HorizontalSplitPerpStart' WIN_DWL_HORIZONTALSPLITPERPEND = 'HorizontalSplitPerpEnd' +WIN_PRJ_ORIGSPLIT = 'OrigSplit' + WIN_HARDWARE = 'Hardware' WIN_HDW_FAVOURITE = 'HdwFavourite' WIN_HDW_FRAME = 'HdwFrame' diff --git a/Profiles/WinLib/WinCalculate.lua b/Profiles/WinLib/WinCalculate.lua index 039a3cf..8f476a5 100644 --- a/Profiles/WinLib/WinCalculate.lua +++ b/Profiles/WinLib/WinCalculate.lua @@ -233,6 +233,28 @@ local function CalcSplitProfileType( nSplitLayerId, nAreaId) -- se split di tipo french non ha profilo assegnato perchè non ha un pezzo associato end +--------------------------------------------------------------------- +local function FindAdjacentSashType( nSplitId, nSouId) + + -- recupero l'altro child dello split + local vSplitChildren = EgtGetInfo( nSplitId, WIN_CHILD, 'vi') + local vChildren = EgtIf( vSplitChildren[1] == nSouId, {vSplitChildren[2]}, {vSplitChildren[1]}) + -- cerco il suo primo figlio di tipo sash + local nAreaType + local nArea + repeat + vChildren = EgtGetInfo( vChildren[1], WIN_CHILD, 'vi') + if vChildren then + nArea = EgtGetParent( EgtGetParent( vChildren[1])) + nAreaType = EgtGetInfo( nArea or GDB_ID.NULL, WIN_AREATYPE, 'i') + end + until not vChildren or nAreaType == WIN_AREATYPES.SASH + + -- recupero il sash type + local nSashType = EgtGetInfo( nArea or GDB_ID.NULL, WIN_SASHTYPE, 'i') + return nSashType +end + --------------------------------------------------------------------- -- funzione che imposta i tipi di profilo in base al tipo di pezzi local function CalcProfileType( nAreaId) @@ -245,20 +267,21 @@ local function CalcProfileType( nAreaId) local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId) while nOutlineId do -- recupero tipo del child - local nChildId = nOutlineId + local vChildId = { nOutlineId} local nChildAreaId local nChildType -- ciclo fino a trovare un child che non sia uno split + -- ( considero solo il primo figlio perchè non è ancora gestito cambio di profilo) repeat - nChildId = EgtGetInfo( nChildId, WIN_CHILD) - if nChildId then - nChildAreaId = EgtGetParent( EgtGetParent( nChildId)) + vChildId = EgtGetInfo( vChildId[1], WIN_CHILD, 'vi') + if vChildId then + nChildAreaId = EgtGetParent( EgtGetParent( vChildId[1])) nChildType = EgtGetInfo( nChildAreaId, WIN_AREATYPE, 'i') end - until not nChildId or ( nChildType ~= WIN_AREATYPES.SPLIT and nChildType ~= WIN_AREATYPES.NULL) + until not vChildId or ( nChildType ~= WIN_AREATYPES.SPLIT and nChildType ~= WIN_AREATYPES.NULL) local sName = EgtGetName( nOutlineId) - if not nChildId or nChildType == WIN_AREATYPES.SASH then + if not vChildId or nChildType == WIN_AREATYPES.SASH then if sName == WIN_BOTTOM then EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_BOTTOM) else @@ -298,16 +321,49 @@ local function CalcProfileType( nAreaId) local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE) local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId) while nOutlineId do - -- faccio sou due volte per trovare il tipo dell'outline originale da cui deriva + -- verifico se deriva da una curva di split di tipo french ( e quindi deve avere profilo battente/ricevente) local nSouId = EgtGetInfo( nOutlineId, WIN_SOU, 'i') - nSouId = EgtGetInfo( nSouId, WIN_SOU, 'i') - local sSouName = EgtGetName( nSouId) - if sSouName == WIN_SPLIT then + local nSouPrevId + local nSplitType + repeat + nSouPrevId = nSouId + nSouId = EgtGetInfo( nSouId, WIN_SOU, 'i') + if nSouId then + local sName = EgtGetName( nSouId) + if sName == WIN_SPLIT then + local nParentId = EgtGetParent( nSouId) + nSplitType = EgtGetInfo( nParentId, WIN_SPLITTYPE, 'i') + end + end + until not nSouId or nSplitType == WIN_SPLITTYPES.FRENCH + + if nSplitType == WIN_SPLITTYPES.FRENCH then + -- setto info sulla curva per ricordare che deriva da un french split ( utile nel calcolo degli outlines) + EgtSetInfo( nOutlineId, WIN_CRV_ON_FRENCH_SPLIT, true) + if nSashType == WIN_SASHTYPES.ACTIVE then EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_ACTIVE) elseif nSashType == WIN_SASHTYPES.INACTIVE then EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_INACTIVE) - end + elseif nSashType == WIN_SASHTYPES.ACTIVE_OUT or nSashType == WIN_SASHTYPES.INACTIVE_OUT then + EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRENCH_OUT) + else + -- devo verificare il tipo dell'anta adiacente + local nAdjSashType = FindAdjacentSashType( nSouId, nSouPrevId) + if nSashType == WIN_SASHTYPES.ACTIVE_IN then + if nAdjSashType == WIN_SASHTYPES.ACTIVE_OUT then + EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRENCH_IN) + else -- adiacente è inactive + EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_ACTIVE) + end + elseif nSashType == WIN_SASHTYPES.INACTIVE_IN then + if nAdjSashType == WIN_SASHTYPES.INACTIVE_OUT then + EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRENCH_IN) + else -- adiacente è active + EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_INACTIVE) + end + end + end else local sName = EgtGetName( nOutlineId) if sName ~= WIN_BOTTOM then @@ -487,20 +543,10 @@ local function CalculateOutlineFromAreaOutline( nAreaId) EgtSetInfo( nOutlineId, WIN_COPY, nBaseOutlineId) EgtSetInfo( nOutlineId, WIN_PROFILETYPE, sSashProfile) - -- verifico se outline e' segmento battente o ricevente che quindi deriva da split - local bOnFrenchSplit = false - if nSashType ~= WIN_SASHTYPES.NULL then - -- faccio sou due volte per trovare il tipo dell'outline originale da cui deriva - local nSouId = EgtGetInfo( nBaseOutlineId, WIN_SOU, 'i') - nSouId = EgtGetInfo( nSouId, WIN_SOU, 'i') - local sSouName = EgtGetName( nSouId) - -- se deriva da split è segmento battente/ricevente - if sSouName == WIN_SPLIT then - bOnFrenchSplit = true - end - end + -- verifico se outline e' segmento battente o ricevente ( che quindi deriva da split di tipo french) + local bOnFrenchSplit = EgtGetInfo( nBaseOutlineId, WIN_CRV_ON_FRENCH_SPLIT, 'b') or false - -- se outline non è segmento battente o ricevente ( che quindi deriva da split) necessita di offset + -- se outline non è segmento battente o ricevente necessita di offset if not bOnFrenchSplit then -- recupero a ritroso il profilo dell'elemento del frame su cui poggia @@ -604,18 +650,7 @@ local function CalculateOutlineFromAreaOutline( nAreaId) -- accorcio gli offset TrimAndOrientOrderedCurveLayer( nOutlineLayerId) end - - -- disegno area di selezione per programma - local nSelectionLayerId = EgtGroup( nAreaId) - EgtSetName( nSelectionLayerId, WIN_SELECTION) - EgtSetStatus( nSelectionLayerId, GDB_ST.OFF) - local vOutlineList = EgtGetAllInGroup( nOutlineLayerId) - local nCompoId = EgtCurveCompo( nSelectionLayerId, vOutlineList, false) - local nSelectionArea = EgtSurfFlatRegion( nSelectionLayerId, nCompoId) - EgtSetColor( nSelectionArea, 'YELLOW') - EgtSetAlpha( nSelectionArea, 10) - EgtMove( nSelectionArea, 10 * Z_AX()) - EgtErase( nCompoId) + end --------------------------------------------------------------------- @@ -719,30 +754,6 @@ local function GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) return nPrevOutlineId, nNextOutlineId end ---------------------------------------------------------------------- --- funzione che dato il tipo di pezzo e di giunzione, restituisce se e' corto, lungo o angolato -local function CalcPartJointType( nProfileType, JointType) - - if JointType == WIN_JNT.ANGLED then - return WIN_PART_JNT.ANGLED - end - if nProfileType == WIN_PRF.BOTTOMRAIL or nProfileType == WIN_PRF.SPLIT then - return WIN_PART_JNT.SHORT - elseif nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP then - if JointType == WIN_JNT.FULL_H then - return WIN_PART_JNT.FULL - elseif JointType == WIN_JNT.FULL_V then - return WIN_PART_JNT.SHORT - end - elseif nProfileType == WIN_PRF.LEFT or nProfileType == WIN_PRF.RIGHT then - if JointType == WIN_JNT.FULL_V then - return WIN_PART_JNT.FULL - elseif JointType == WIN_JNT.FULL_H then - return WIN_PART_JNT.SHORT - end - end -end - --------------------------------------------------------------------- -- funzione che restituisce il tipo di controprofilo dell'outline adiacente local function GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId) @@ -783,6 +794,64 @@ local function GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevP return sPrevCtrIn end + +--------------------------------------------------------------------- +--------------------------- GEO ----------------------------------- +--------------------------------------------------------------------- +-- funzione che dato il tipo di pezzo e di giunzione, restituisce se e' corto, lungo o angolato +local function CalcPartJointType( nProfileType, JointType) + + if JointType == WIN_JNT.ANGLED then + return WIN_PART_JNT.ANGLED + end + if nProfileType == WIN_PRF.BOTTOMRAIL or nProfileType == WIN_PRF.SPLIT then + return WIN_PART_JNT.SHORT + elseif nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP then + if JointType == WIN_JNT.FULL_H then + return WIN_PART_JNT.FULL + elseif JointType == WIN_JNT.FULL_V then + return WIN_PART_JNT.SHORT + end + elseif nProfileType == WIN_PRF.LEFT or nProfileType == WIN_PRF.RIGHT then + if JointType == WIN_JNT.FULL_V then + return WIN_PART_JNT.FULL + elseif JointType == WIN_JNT.FULL_H then + return WIN_PART_JNT.SHORT + end + end +end + +--------------------------------------------------------------------- +-- funzione che crea il gruppo con i profili di un pezzo +local function CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType) + + -- creo gruppo per i profili + local nProfileLayerId = EgtGroup( nPartId) + EgtSetName( nProfileLayerId, WIN_PROFILE) + EgtSetStatus( nProfileLayerId, GDB_ST.OFF) + -- recupero profili e controprofili + local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, nProfileType == WIN_PRF.BOTTOMRAIL) + -- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom + local nOrigStartProfileId = GetOutlineProfileId( nPrevOutlineId, nProfileType == WIN_PRF.SPLIT) + local nOrigEndProfileId = GetOutlineProfileId( nNextOutlineId, nProfileType == WIN_PRF.SPLIT) + + -- creo copie di profilo e controprofili + local nMainProfileId = EgtCopy( nOrigMainProfileId, nProfileLayerId) + local sMainProfileType = EgtGetName( nMainProfileId) + EgtSetInfo( nMainProfileId, WIN_PRF_TYPE, sMainProfileType) + EgtSetName( nMainProfileId, WIN_PRF_MAIN) + local nStartProfileId = EgtCopy( nOrigStartProfileId, nProfileLayerId) + local sStartProfileType = EgtGetName( nStartProfileId) + EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType) + EgtSetName( nStartProfileId, WIN_PRF_START) + local nEndProfileId = EgtCopy( nOrigEndProfileId, nProfileLayerId) + local sEndProfileType = EgtGetName( nEndProfileId) + EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType) + EgtSetName( nEndProfileId, WIN_PRF_END) + + return nProfileLayerId +end + --------------------------------------------------------------------- local function GetDeltaProfile( nProfileId, sCtrIn) @@ -801,9 +870,9 @@ end --------------------------------------------------------------------- -- funzione che crea le curve del geo -local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, bBottomRail) +local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId) - local nCurrProfileId = GetOutlineProfileId( nOutlineId, bBottomRail) + 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) @@ -841,7 +910,7 @@ local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStar EgtInvertCurve( nPrevCurveId) else nPrevCurveId = EgtCopy( nPrevOutlineId, nGeoLayerId) - local nPrevProfileId = GetOutlineProfileId( nPrevOutlineId, nProfileType == WIN_PRF.SPLIT) + local nPrevProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) if nStartPartJointType == WIN_PART_JNT.SHORT then local sCtrIn = GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId) local dPrevCPDelta = GetDeltaProfile( nPrevProfileId, sCtrIn) @@ -869,7 +938,7 @@ local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStar nNextCurveId = EgtLinePVL( nGeoLayerId, EgtEP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX()) else nNextCurveId = EgtCopy( nNextOutlineId, nGeoLayerId) - local nNextProfileId = GetOutlineProfileId( nNextOutlineId, nProfileType == WIN_PRF.SPLIT) + local nNextProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) if nEndPartJointType == WIN_PART_JNT.SHORT then local sCtrIn = GetProfileCtrIn( nProfileType, nNextOutlineId, nOutlineId, nNextProfileId) local dNextCPDelta = GetDeltaProfile( nNextProfileId, sCtrIn) @@ -906,7 +975,7 @@ local function CalcProfilingProcessings( nPartId, nGeoLayerId) -- creo gruppo delle lavorazioni local nProcGrp = EgtGroup( nPartId) EgtSetName( nProcGrp, WIN_PRC) - + EgtSetStatus( nProcGrp, GDB_ST.OFF) -- recupero tutte le curve del geo local vGeoCrvs = EgtGetAllInGroup( nGeoLayerId) for i = 1, #vGeoCrvs do @@ -937,14 +1006,11 @@ end --------------------------------------------------------------------- -- funzione che calcola l'ingombro dei pezzi del telaio -local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, bBottomRail) +local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType) -- creo layer per ingombro local nGeoLayerId = EgtGroup( nPartId) EgtSetName( nGeoLayerId, WIN_GEO) - - -- ricavo tipo di profilo - local nProfileType = GetOutlineProfileType( nOutlineId, bBottomRail) -- recupero outline precedente e successivo local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) @@ -981,12 +1047,15 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, bBottomRail) local nStartPartJointType = CalcPartJointType( nProfileType, nStartJointType) local nEndPartJointType = CalcPartJointType( nProfileType, nEndJointType) - -- salvo i valori joint su outline per disegno solido + -- salvo i valori joint su outline per disegno solido e calcolo dowels EgtSetInfo( nOutlineId, WIN_STARTJOINT, nStartPartJointType) EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType) + -- creo il gruppo con i profili del pezzo + local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType) + -- creo lati dell'outline - local nGeoOutId = CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, bBottomRail) + local nGeoOutId = CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId) -- calcolo le lavorazioni associate ai profili CalcProfilingProcessings( nPartId, nGeoLayerId) @@ -994,7 +1063,470 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, bBottomRail) return nGeoOutId end + +--------------------------------------------------------------------------------- +---------------------------------- DOWELS ---------------------------------------- +---------------------------------------------------------------------------------- +local function AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nDowelLayerId, nGeoLayerId, nMainExtrusionId) + + 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) + + 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) + 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) + + 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 +end + --------------------------------------------------------------------- +local function AddEndDowels( nOutlineId, nEndOutlineId, nProfileLayerId, nDowelLayerId, nGeoLayerId, nMainExtrusionId) + + 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 + 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) + + 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) + 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) + + 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 +end + +--------------------------------------------------------------------- +-- funzione che calcola intersezione, geometrie e superfici dei dowel degli split +local function CalSplitDowel( nSplitLayerId, nOutlineId, nProfileType, nPartId) + + -- 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 + + -- 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)) + if not ptInters and nProfileType == WIN_PRF.SPLIT then + nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_OUT) + ptInters = EgtIP( nGeoCrvId, nSplitId, EgtSP( nSplitId)) + end + + -- 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 + + -- 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) + + -- 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 + + -- 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) + + 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 + + nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') + 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) + + -- 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) + 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) + end + 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 nPrevOutlineId, nNextOutlineId = 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 + AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) + AddEndDowels( nOutlineId, nNextOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) + + -- split dowels + AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType) +end + + +---------------------------------------------------------------------------------- +---------------------------------- SOLIDO ---------------------------------------- +---------------------------------------------------------------------------------- -- funzione che recupera tipo di inizio e fine pezzo local function CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId) @@ -1029,279 +1561,35 @@ local function CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileI sEndProfileType = WIN_OFST .. sEndProfileType end - return sStartProfileType, sEndProfileType, StartJointType, EndJointType + return sStartProfileType, sEndProfileType end --------------------------------------------------------------------- -local function AddStartDowels( nOutlineId, nPrevOutlineId, StartJointType, nMainProfileId, nStartProfileId, nDowelLayerId, nGeoInId, nSolidLayerId, nMainExtrusionId) +-- funzione che crea il solido del pezzo del telaio +local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) - local sOutlineName = EgtGetName( nOutlineId) - local sPrevOutlineName = EgtGetName( nPrevOutlineId) + -- creo layer per solido + local nSolidLayerId = EgtGroup( nPartId) + EgtSetName( nSolidLayerId, WIN_SOLID) + + -- recupero layer delle lavorazioni per i dowels + local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) + + -- recupero profili e controprofili + local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) + local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) + local nStartProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) + local nEndProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) - local nStartGuideId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_STARTGUIDE) - - if StartJointType == WIN_PART_JNT.ANGLED then - - elseif StartJointType == 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 = EgtIP( nGeoInId, nStartGuideId, ORIG(), GDB_ID.ROOT) - local dParRef = EgtCurveParamAtPoint( nStartGuideId, ptInt) - local vtRef = EgtUV( nStartGuideId, dParRef, -1, GDB_ID.ROOT) - 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) - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nSolidLayerId, nDowelId, vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, - vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - - elseif StartJointType == 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 ptInt = EgtIP( nOutlineId, nStartGuideId, ORIG(), GDB_ID.ROOT) - local dParRef = EgtCurveParamAtPoint( nOutlineId, ptInt) - local vtRef = EgtUV( nOutlineId, dParRef, -1, GDB_ID.ROOT) - 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) - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nSolidLayerId, nDowelId, vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, - vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - end -end - ---------------------------------------------------------------------- -local function AddEndDowels( nOutlineId, nEndOutlineId, EndJointType, nMainProfileId, nEndProfileId, nDowelLayerId, nGeoInId, nSolidLayerId, nMainExtrusionId) - - local sOutlineName = EgtGetName( nOutlineId) - local sEndOutlineName = EgtGetName( nEndOutlineId) - - local nEndGuideId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_ENDGUIDE) - - if EndJointType == WIN_PART_JNT.ANGLED then - - elseif EndJointType == 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 = EgtIP( nGeoInId, nEndGuideId, ORIG(), GDB_ID.ROOT) - local dParRef = EgtCurveParamAtPoint( nEndGuideId, ptInt) - local vtRef = EgtUV( nEndGuideId, dParRef, -1, GDB_ID.ROOT) - 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 - 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) - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nSolidLayerId, nDowelId, - vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - - elseif EndJointType == 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 ptInt = EgtIP( nOutlineId, nEndGuideId, ORIG(), GDB_ID.ROOT) - local dParRef = EgtCurveParamAtPoint( nOutlineId, ptInt) - local vtRef = EgtUV( nOutlineId, dParRef, -1, GDB_ID.ROOT) - 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) - -- creo solido di estrusione - local nDowelExtrusionId = EgtSurfTmByRegionExtrusion( nSolidLayerId, nDowelId, - vtRef * ( dEnd - dStart + 1)) - EgtMove( nDowelExtrusionId, vtRef) - -- sottraggo il dowel al solido - EgtSurfTmSubtract( nMainExtrusionId, nDowelExtrusionId) - EgtErase( nDowelExtrusionId) - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - end - end -end - ---------------------------------------------------------------------- --- funzione che posiziona i profili, li estrude e crea il solido -local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId, nDowelLayerId) - -- recupero outline - local nPartId = EgtGetParent( nSolidLayerId) - local nGeoLayerId = EgtGetParent( nGeoId) - local nOutlineLayerId = EgtGetParent( nOutlineId) -- recupero geo + local nGeoLayerId = EgtGetParent( nGeoId) local nPrevGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_LEFT) local nNextGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_RIGHT) - local nGeoInId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_IN) -- recupero BBox e larghezza del geo local dGeoWidth = EgtGetInfo( nGeoId, WIN_GEOWIDTH, 'd') - -- recupero tipo di giunzioni e i controprofili - local sStartProfileType, sEndProfileType, StartJointType, EndJointType = CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId) - - -- recupero outline precedente e successivo - local nPrevOutlineId, nEndOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) + -- recupero i controprofili in base al tipo di giunzioni + local sStartProfileType, sEndProfileType = CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId) -- a) MAIN EXTRUSION -- creo guida Main @@ -1326,7 +1614,7 @@ local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartP EgtSetName( nOrigMainExtrusionId, WIN_SRF_ORIGMAIN) EgtSetStatus( nOrigMainExtrusionId, GDB_ST.OFF) - + -- b) START PROFILE -- posiziono il profilo Start local nRefStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, WIN_REF) @@ -1382,7 +1670,7 @@ local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartP end end end - + -- recupero outline del profilo Start e lo estrudo local nOutStartProfileId if sStartProfileType == WIN_MINIZINKEN then @@ -1391,13 +1679,13 @@ local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartP else nOutStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, sStartProfileType) end - local nStartExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutStartProfileId, nStartGuideId, false, WIN_SURF_APPROX) -- eseguo intersezione per ottenere un solido unico -- ( tagliare le due superfici con EgtSurfTmCut e poi unirle potrebbe creare piccoli buchi legati alle diverse approssimazioni) EgtSurfTmIntersect( nMainExtrusionId, nStartExtrusionId) EgtErase( nStartExtrusionId) + -- c) END PROFILE -- posiziono il profilo End local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF) @@ -1445,6 +1733,7 @@ local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartP end end end + -- recupero outline del profilo End e lo estrudo local nOutEndProfileId if sEndProfileType == WIN_MINIZINKEN then @@ -1458,240 +1747,32 @@ local function MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartP EgtSurfTmIntersect( nMainExtrusionId, nEndExtrusionId) EgtErase( nEndExtrusionId) - -- creo fori per spine su Start - AddStartDowels( nOutlineId, nPrevOutlineId, StartJointType, nMainProfileId, nStartProfileId, nDowelLayerId, nGeoInId, nSolidLayerId, nMainExtrusionId) - -- creo fori per spine su End - AddEndDowels( nOutlineId, nEndOutlineId, EndJointType, nMainProfileId, nEndProfileId, nDowelLayerId, nGeoInId, nSolidLayerId, nMainExtrusionId) - end ----------------------------------------------------------------------------------- -------------------------------- SPLIT DOWELS ------------------------------------- ----------------------------------------------------------------------------------- --- funzione che calcola intersezione, geometrie e superfici dei dowel degli split -local function CalSplitDowel( nSplitLayerId, nOutlineId, nProfileType, nPartId) - - -- 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 - - -- 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)) - if not ptInters and nProfileType == WIN_PRF.SPLIT then - nGeoCrvId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_OUT) - ptInters = EgtIP( nGeoCrvId, nSplitId, EgtSP( nSplitId)) - end - - -- 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 - - -- recupero solido del pezzo - local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) - local nMainExtrusionId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN) - - -- creo fori per spine su Split - local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) - - -- 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 - - -- 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) - - -- 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) - - nOrigDowelId = EgtGetNextName( nOrigDowelId, WIN_DOWEL .. '*') - 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) - - -- 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) - 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) - end - 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 il solido del pezzo del telaio -local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nOutlineLayerId, bBottomRail) - - -- 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) - -- recupero layer delle lavorazioni per i dowels - local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) - - -- ricavo tipo di profilo - local nProfileType = GetOutlineProfileType( nOutlineId, bBottomRail) - - -- recupero outline precedente e successivo - local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) - - -- recupero profili e controprofili - local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, bBottomRail) - -- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom - local nOrigStartProfileId = GetOutlineProfileId( nPrevOutlineId, nProfileType == WIN_PRF.SPLIT) - local nOrigEndProfileId = GetOutlineProfileId( nNextOutlineId, nProfileType == WIN_PRF.SPLIT) - - -- creo copie di profilo e controprofili - local nMainProfileId = EgtCopy( nOrigMainProfileId, nFrameProfileLayerId) - local sMainProfileType = EgtGetName( nMainProfileId) - EgtSetInfo( nMainProfileId, WIN_PRF_TYPE, sMainProfileType) - EgtSetName( nMainProfileId, WIN_PRF_MAIN) - local nStartProfileId = EgtCopy( nOrigStartProfileId, nFrameProfileLayerId) - local sStartProfileType = EgtGetName( nStartProfileId) - EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType) - EgtSetName( nStartProfileId, WIN_PRF_START) - local nEndProfileId = EgtCopy( nOrigEndProfileId, nFrameProfileLayerId) - local sEndProfileType = EgtGetName( nEndProfileId) - EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType) - EgtSetName( nEndProfileId, WIN_PRF_END) - - -- creo solido dai profili - MakeSolidByExtrusion( nGeoId, nOutlineId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId, nProcLayerId) - - -- aggiungo dowels degli split - AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType) - - end - --------------------------------------------------------------------- -- funzione che calcola l'ingombro dei pezzi del telaio e i loro solidi local function CreatePartFromOutline( nAreaLayerId, nOutlineId, bBottomRail) - - local nAreaType = EgtGetInfo( nAreaLayerId, WIN_AREATYPE, 'i') + -- creo pezzo local nPartId = EgtGroup( GDB_ID.ROOT) - -- se BottomRail, creo riferimento - if bBottomRail then - EgtSetInfo( nOutlineId, WIN_REF_BOTTOMRAIL_PART, nPartId) - end - -- recupero outline + -- inserisco riferimento alla sua area + EgtSetInfo( nPartId, WIN_AREA, nAreaLayerId) + + local nAreaType = EgtGetInfo( nAreaLayerId, WIN_AREATYPE, 'i') local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_OUTLINE) - local nProfileType = WIN_PRF.NULL + + -- a) Telaio, anta o split if nAreaType == WIN_AREATYPES.FRAME or nAreaType == WIN_AREATYPES.SASH or nAreaType == WIN_AREATYPES.SPLIT then - -- se area senza outline, cerco quella superiore - if not nOutlineLayerId then - local nParentAreaLayerId = EgtGetParent( nAreaLayerId) - if nParentAreaLayerId then - nOutlineLayerId = EgtGetFirstNameInGroup( nParentAreaLayerId, WIN_OUTLINE) - end + + -- creo riferimenti tra pezzo e outline + EgtSetInfo( nPartId, WIN_REF_OUTLINE, nOutlineId) + if bBottomRail then + EgtSetInfo( nOutlineId, WIN_REF_BOTTOMRAIL_PART, nPartId) + else + EgtSetInfo( nOutlineId, WIN_REF_PART, nPartId) end - - -- imposto nome + + -- imposto nome del pezzo local sName = EgtGetName( nOutlineId) if bBottomRail then sName = WIN_BOTTOMRAIL @@ -1707,41 +1788,40 @@ local function CreatePartFromOutline( nAreaLayerId, nOutlineId, bBottomRail) EgtSetColor( nPartId, Color3d( 255, 159, 57)) end + -- ricavo il tipo di profilo + local nProfileType = GetOutlineProfileType( nOutlineId, bBottomRail) + -- disegno ingombro + local nGeoId = CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType) + -- disegno solido + 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 - -- imposto nome + -- imposto nome del pezzo EgtSetName( nPartId, WIN_FILL) -- ricavo tipo local nFillType = EgtGetInfo( nAreaLayerId, WIN_FILLTYPE, 'i') + -- imposto colore if nFillType == WIN_FILLTYPES.GLASS then EgtSetColor( nPartId, Color3d( 71, 161, 255)) EgtSetAlpha( nPartId, 30) elseif nFillType == WIN_FILLTYPES.WOOD then EgtSetColor( nPartId, Color3d( 194, 148, 103)) end - end - - -- inserisco riferimento alla sua area ed al suo outline - EgtSetInfo( nPartId, WIN_AREA, nAreaLayerId) - if nAreaType ~= WIN_AREATYPES.FILL then - EgtSetInfo( nPartId, WIN_REF_OUTLINE, nOutlineId) - if not bBottomRail then EgtSetInfo( nOutlineId, WIN_REF_PART, nPartId) end - end - - if nAreaType == WIN_AREATYPES.FRAME or nAreaType == WIN_AREATYPES.SASH or nAreaType == WIN_AREATYPES.SPLIT then - -- disegno ingombro - local nGeoId = CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, bBottomRail) - -- disegno solido - if bCalcSolid then - CalcFrameSolid( nPartId, nOutlineId, nGeoId, nOutlineLayerId, bBottomRail) - end - elseif nAreaType == WIN_AREATYPES.FILL then + -- disegno ingombro local nGeoLayerId = CalcFillGeo( nPartId, nOutlineLayerId) -- disegno solido if bCalcSolid then - CalcFillSolid(nPartId, nOutlineLayerId, nGeoLayerId) + CalcFillSolid( nPartId, nOutlineLayerId, nGeoLayerId) end end + return nPartId end @@ -1852,13 +1932,13 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) -- recupero guida Main local nGuideId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_MAINGUIDE) -- recupero strip piu' vicino a prev outline - local nMainStripId = GetStripNearestToOutline( nMainProfileId, nPrevOutlineId, WIN_STRIP) + local nMainStripId = GetStripNearestToOutline( nMainProfileId, nPrevOutlineId) -- estrudo MainStrip local nMainStripExtrusionId = EgtSurfTmSwept( nSolidLayerId, nMainStripId, nGuideId, false, WIN_SURF_APPROX) -- b) taglio con start -- recupero strip dello start piu' vicino ad outline - local nStartStripId = GetStripNearestToOutline( nStartProfileId, nOutlineId, WIN_STRIP) + local nStartStripId = GetStripNearestToOutline( nStartProfileId, nOutlineId) -- disegno guida start per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip e StartStrip local nMainStripMinOffsetId, nMainStripMaxOffsetId = CreateStripGuideLines( nOutlineId, nMainStripId, nMainProfileId, nSolidLayerId) @@ -1885,7 +1965,7 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) -- c) taglio con end -- recupero strip piu' vicino ad outline - local nEndStripId = GetStripNearestToOutline( nEndProfileId, nOutlineId, WIN_STRIP) + local nEndStripId = GetStripNearestToOutline( nEndProfileId, nOutlineId) -- disegno guida end per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip ed EndStrip local nEndStripMinOffsetId, nEndStripMaxOffsetId = CreateStripGuideLines( nNextOutlineId, nEndStripId, nEndProfileId, nSolidLayerId) @@ -1948,7 +2028,19 @@ local function CalculateAreaParts( nAreaId) local nSplitId = EgtGetFirstInGroup( nSplitLayerId) if nSplitId then -- creo pezzo split - CreatePartFromOutline( nAreaId, nSplitId) + local nSplitPartId = CreatePartFromOutline( nAreaId, nSplitId) + -- disegno area di selezione per programma + local nSelectionLayerId = EgtGroup( nAreaId) + EgtSetName( nSelectionLayerId, WIN_SPLITSELECTION) + EgtSetStatus( nSelectionLayerId, GDB_ST.OFF) + local nSplitPartGeoId = EgtGetFirstNameInGroup( nSplitPartId, WIN_GEO) + local vOutlineList = EgtGetAllInGroup( nSplitPartGeoId) + local nCompoId = EgtCurveCompo( nSelectionLayerId, vOutlineList, false) + local nSelectionArea = EgtSurfFlatRegion( nSelectionLayerId, nCompoId) + EgtSetColor( nSelectionArea, 'YELLOW') + EgtSetAlpha( nSelectionArea, 10) + EgtMove( nSelectionArea, 10 * Z_AX()) + EgtErase( nCompoId) end end elseif nAreaType ~= WIN_AREATYPES.FILL then @@ -1968,6 +2060,19 @@ local function CalculateAreaParts( nAreaId) end end + -- disegno area di selezione per programma + local nSelectionLayerId = EgtGroup( nAreaId) + EgtSetName( nSelectionLayerId, WIN_SELECTION) + EgtSetStatus( nSelectionLayerId, GDB_ST.OFF) + local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE) + local vOutlineList = EgtGetAllInGroup( nOutlineLayerId) + local nCompoId = EgtCurveCompo( nSelectionLayerId, vOutlineList, false) + local nSelectionArea = EgtSurfFlatRegion( nSelectionLayerId, nCompoId) + EgtSetColor( nSelectionArea, 'YELLOW') + EgtSetAlpha( nSelectionArea, 10) + EgtMove( nSelectionArea, 10 * Z_AX()) + EgtErase( nCompoId) + -- calcolo i pezzi delle sottoaree local nChildAreaId = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*') while nChildAreaId do @@ -2402,7 +2507,7 @@ function WinCalculate.AddHardware( nFrameId) local nHoleId = EgtCircle( nProcLayerId, ptCenter, dRadius) -- per lavorazione EgtModifyCurveExtrusion( nHoleId, Z_AX()) - local dDepth = 25.0 + local dDepth = tonumber(25) if #vMacro == 3 then dDepth = tonumber( vMacro[3]) end diff --git a/Profiles/WinLib/WinCreate.lua b/Profiles/WinLib/WinCreate.lua index 5c83c49..50aa5db 100644 --- a/Profiles/WinLib/WinCreate.lua +++ b/Profiles/WinLib/WinCreate.lua @@ -22,6 +22,12 @@ require( 'WinConst') -- funzioni +local function AddInfo( nId, sInfo, nVal) + local vInfo = EgtGetInfo( nId, sInfo, 'vi') or {} + table.insert( vInfo, nVal) + EgtSetInfo( nId, sInfo, vInfo) +end + -- funzione che importa il profilo function WinCreate.ImportProfile( sProfilePath) -- verifico esistenza file @@ -136,7 +142,8 @@ function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSa while nAreaOutlineId do local nOutlineId = EgtCopy( nAreaOutlineId, nAreaOutlineLayerId) EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId) - EgtSetInfo( nAreaOutlineId, WIN_CHILD, nOutlineId) + EgtRemoveInfo( nOutlineId, WIN_CHILD) + AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId) nAreaOutlineId = EgtGetNext( nAreaOutlineId) end -- imposto tipo giunzioni @@ -167,7 +174,8 @@ function WinCreate.AddFill( nAreaId, FillType) while nAreaOutlineId do local nOutlineId = EgtCopy( nAreaOutlineId, nAreaOutlineLayerId) EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId) - EgtSetInfo( nAreaOutlineId, WIN_CHILD, nOutlineId) + EgtRemoveInfo( nOutlineId, WIN_CHILD) + AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId) EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL) EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR) EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL) @@ -225,13 +233,16 @@ function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, n end -- funzione che crea tagli split multipli -function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion) +function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion, nSplitType) local AreaList = {} if MeasureType == WIN_MEASURE.ABSOLUT then local nResArea1 local nResArea2 = nAreaLayerId for nIndex = 1, #PositionList do - nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion) + if nIndex > 1 then + EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId) + end + nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion, nSplitType) table.insert( AreaList, nResArea1) if nIndex == #PositionList then table.insert( AreaList, nResArea2) @@ -242,7 +253,10 @@ function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList local nResArea2 = nAreaLayerId local dAddPosition = 0 for nIndex = 1, #PositionList do - nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion - dAddPosition) + if nIndex > 1 then + EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId) + end + nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion - dAddPosition, nSplitType) table.insert( AreaList, nResArea1) if nIndex == #PositionList then table.insert( AreaList, nResArea2) @@ -253,14 +267,20 @@ function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList local nResArea1 local nResArea2 = nAreaLayerId local dAddPosition = 0 + local sChildAreas = '' for nIndex = 1, #PositionList do - nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, EgtIf( nIndex == 1, PositionList[nIndex], PositionList[nIndex] / ( 1 - dAddPosition)), nProportion) + if nIndex > 1 then + EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId) + sChildAreas = sChildAreas .. nResArea2 .. EgtIf( nIndex < #PositionList, ',', '') + end + nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, EgtIf( nIndex == 1, PositionList[nIndex], PositionList[nIndex] / ( 1 - dAddPosition)), nProportion, nSplitType) table.insert( AreaList, nResArea1) if nIndex == #PositionList then table.insert( AreaList, nResArea2) end dAddPosition = dAddPosition + PositionList[nIndex] end + EgtSetInfo( nAreaLayerId, 'ChildSplit', sChildAreas) end return AreaList end @@ -369,7 +389,8 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) nInters = 1 local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters) EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam) elseif nInters == 1 then @@ -377,13 +398,15 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) nInters = 2 local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters) EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam) -- copio anche split local nSplitCopyId = EgtCopy( nSplitId, nArea2OutlineLayerId) EgtSetInfo( nSplitCopyId, WIN_SOU, nSplitId) - EgtSetInfo( nSplitId, WIN_CHILD, nSplitCopyId) + EgtRemoveInfo( nSplitCopyId, WIN_CHILD) + AddInfo( nSplitId, WIN_CHILD, nSplitCopyId) EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_STARTINTERS) EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_ENDINTERS) if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then @@ -402,7 +425,8 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) -- inizio area 1 nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters) EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam) elseif nInters == 2 then @@ -410,14 +434,16 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) nInters = 3 local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters) EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam) -- copio anche split local nSplitCopyId = EgtCopy( nSplitId, nArea1OutlineLayerId) EgtRemoveName( nSplitCopyId) EgtSetInfo( nSplitCopyId, WIN_SOU, nSplitId) - EgtSetInfo( nSplitId, WIN_CHILD, nSplitCopyId) + EgtRemoveInfo( nSplitCopyId, WIN_CHILD) + AddInfo( nSplitId, WIN_CHILD, nSplitCopyId) EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_STARTINTERS) EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_ENDINTERS) if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then @@ -438,12 +464,14 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) -- copio nel profilo 2 local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) elseif nInters == 2 then -- copio nel profilo 1 local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtSetInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) end -- aggiorno indice nOutlineId = EgtGetNext( nOutlineId) diff --git a/Profiles/WinProject.lua b/Profiles/WinProject.lua index a79f6b6..f8d1cea 100644 --- a/Profiles/WinProject.lua +++ b/Profiles/WinProject.lua @@ -63,16 +63,26 @@ end _G.WinCreate_AddBottomRail = WinCreate_AddBottomRail local function WinCreate_AddSplits() + local AreaIndex = 1 + while WDG['AREAID' .. AreaIndex] do + WDG['AREAID' .. AreaIndex] = nil + AreaIndex = AreaIndex + 1 + end local PositionList = {} local PositionIndex = 1 while WDG['POSITION' .. PositionIndex] do table.insert( PositionList, WDG['POSITION' .. PositionIndex]) PositionIndex = PositionIndex + 1 end - local AreaList = WinCreate.AddSplits(WDG.AREAID, WDG.SPLITTYPE, WDG.MEASURETYPE, PositionList, WDG.PROPORTION) + local AreaList = WinCreate.AddSplits(WDG.AREAID, WDG.SPLITORIENTATION, WDG.MEASURETYPE, PositionList, WDG.PROPORTION, WDG.SPLITTYPE) for AreaIndex = 1, #AreaList do WDG['AREAID' .. AreaIndex] = AreaList[ AreaIndex] end + PositionIndex = 1 + while WDG['POSITION' .. PositionIndex] do + WDG['POSITION' .. PositionIndex] = nil + PositionIndex = PositionIndex + 1 + end end _G.WinCreate_AddSplits = WinCreate_AddSplits