-- 2015/09/__ -- PIANO CUCINA A 'L' AD ANGOLO RETTO -- Intestazioni require('EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) EgtAddToPackagePath(EgtGetSourceDir() .. 'LuaLibs\\?.lua') require( 'EgtCompo') -- Valori limite local LgMin = 10 local AngMin =15 local AngMax = 180 - 1 -- Parametri : dichiarazione e valori standard --.T (tipo) : 0=null, 1=bool, 2=int, 3=len, 4=num, 5=string local CMP = {} CMP.N1 = 'A' -- lunghezza lungo lato muro 1 CMP.T1 = 3 CMP.V1 = 1800 CMP.N2 = 'B' -- lunghezza lungo lato muro 2 CMP.T2 = 3 CMP.V2 = 2000 CMP.N3 = 'C' -- profondità lato muro 1 CMP.T3 = 3 CMP.V3 = 600 CMP.N4 = 'D' -- profondità lato muro 2 CMP.T4 = 3 CMP.V4 = 650 CMP.N5 = '←→' -- Simmetria dx/sx (false = angolo a sx) ) CMP.T5 = 1 CMP.V5 = false CMP.N6 = '↑↓' -- Ribaltamento su/giù (true = 'L' capovolta) CMP.T6 = 1 CMP.V6 = false CMP.Npar = 6 CMP.Nome = 'PCucinaA1' CMP.WithInt = true _G.CMP = CMP -- Aggiorno con ultimi valori salvati (se presenti) CMP.DATA = EgtGetSourceDir() .. CMP.Nome ..'.dat' LoadCompoData() function CMP_Draw(bPreview) -- Carico i messaggi local Msg = require('EgtCompoMsg') -- Assegnazioni local L1 = CMP.V1 local L2 = CMP.V2 local L3 = CMP.V3 local L4 = CMP.V4 local Simm = CMP.V5 local Rib = CMP.V6 local L5 = L1 - L4 local L6 = L2- L3 local L5label = 'E' -- lato interno 1 local L6label = 'F' -- lato interno 2 local D1label = 'd' -- diagonale CMP.ERR = 0 CMP.MSG = '' --Verifica di compatibilità dei dati di input if L1 < LgMin then L1 = LgMin CMP.ERR = 1 CMP.MSG = Msg[2]..GetLenLimit(LgMin) --Le dimensioni dei lati devono essere maggiori di... end if L2 < LgMin then L2 = LgMin if CMP.ERR == 0 then CMP.ERR = 2 CMP.MSG = Msg[2]..GetLenLimit(LgMin) --Le dimensioni dei lati devono essere maggiori di... end end if L3 < LgMin then L3 = LgMin if CMP.ERR == 0 then CMP.ERR = 3 CMP.MSG = Msg[2]..GetLenLimit(LgMin) --Le dimensioni dei lati devono essere maggiori di... end end if L4 < LgMin then L4 = LgMin if CMP.ERR == 0 then CMP.ERR = 4 CMP.MSG = Msg[2]..GetLenLimit(LgMin) --Le dimensioni dei lati devono essere maggiori di... end end if L5 < LgMin then L5 = LgMin L1 = L4 + L5 if CMP.ERR == 0 then CMP.ERR = 5 CMP.MSG = Msg[201]..GetLenLimit(LgMin) -- Differenza L1-L4 troppo piccola end end if L6 < LgMin then L6= LgMin L2 = L3 + L6 if CMP.ERR == 0 then CMP.ERR = 6 CMP.MSG = Msg[202]..GetLenLimit(LgMin) -- Differenza L2-L3 troppo piccola end end -- Se Preview cancello tutto if bPreview then EgtNewFile() EgtSetDefaultMaterial( BLACK()) end -- Pezzo e Layer local Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- pezzo local Ly = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale EgtSetName(Ly,'OutLoop') local Lr = EgtGroup(Pz,GDB_RT.LOC) -- layer regione EgtSetName(Lr,'Region') local Lc = EgtGroup(Pz,GDB_RT.LOC) -- layer di costruzione local La = EgtGroup(Pz,GDB_RT.LOC) -- layer ausiliario (diagonali e relative etichette, assi) EgtSetName(La,"LayAux") local Le = EgtGroup(Pz,GDB_RT.LOC) -- layer delle etichette pezzo EgtSetName(Le,"Etichette") local Lq = EgtGroup(Pz,GDB_RT.LOC) -- layer delle linee di quotatura EgtSetName(Lq,"Quotature") EgtSetCurrPartLayer(Pz,Ly) -- Costruzione della figura local l2 = EgtLinePDL(Ly,ORIG(),0,L2) EgtSetName(l2,"A1") local l4 = EgtLinePDL(Ly,EgtEP(l2),90,L4) EgtSetName(l4,"A2") local l6 = EgtLinePDL(Ly,EgtEP(l4),180,L6) EgtSetName(l6,"A3") local l5 = EgtLinePDL(Ly,EgtEP(l6),90,L5) EgtSetName(l5,"A4") local l3 = EgtLinePDL(Ly,EgtEP(l5),180,L3) EgtSetName(l3,"A5") local l1 = EgtLine(Ly,EgtEP(l3),EgtSP(l2)) EgtSetName(l1,"A6") -- assi local a1 = EgtLinePDL(La,EgtMP(l3),-90,L1-L4/2) local a2 = EgtLinePDL(La,EgtMP(l4),180,L2-L3/2) local a3 = EgtLine(La,EgtSP(l5),EgtSP(l2)) -- diagonale local d1, D1 if CMP.ERR == 0 then d1 = EgtLine(La,EgtEP(l3),EgtEP(l2)) D1 = EgtCurveLength(d1) end if Lc then EgtErase(Lc) end -- Riempimento della figura local e1 = EgtCurveCompo(Ly,{l1,l2,l4,l6,l5,l3},false) local s1 = EgtSurfFlatRegion(Lr,e1) if CMP.ERR == 0 then EgtSetColor(s1,AQUA()) else EgtSetColor(s1,ORANGE()) end EgtSetAlpha(s1,25) EgtErase(e1) -- Simmetria if Simm then EgtMirror({Ly,Lr,La},ORIG(),X_AX(),GDB_RT.GLOB) EgtInvertCurve({l1,l2,l4,l6,l5,l3,d1}) EgtSetInfo(La,"SIMM","1") end -- Ribaltamento della figura if Rib then EgtMirror({Ly,Lr,La,Le},ORIG(),Y_AX(),GDB_RT.GLOB) EgtInvertCurve({l1,l2,l4,l6,l5,l3}) EgtSetInfo(La,"RIB","1") end EgtReorderCurvesInGroup(Ly,ORIG()) -- Dimensioni dell'oggetto local bbox = EgtGetBBoxGlob(Ly,GDB_BB.STANDARD) local dimX = EgtToUiUnits(bbox:getDimX()) local dimY = EgtToUiUnits(bbox:getDimY()) local dim = bbox:getRadius() * 0.1 if CMP.ERR == 0 then CMP.MSG = Msg[1] .. EgtNumToString(dimX,2) .. ' x ' .. EgtNumToString(dimY,2) end local pVal if Rib then pVal= bbox:getMin() - Vector3d(0,dim*3,0) -- (in questo caso rimane invariato) else pVal= bbox:getMin() - Vector3d(0,dim*3,0) end -- Dimensioni sull'oggetto local sDim = EgtNumToString(dimX,2) .. ' x ' .. EgtNumToString(dimY,2) local dDim = bbox:getRadius() * 0.1 local LbOn if L1 > L2 then LbOn = AddLabelPnt(Lr,EgtMP(a1,GDB_ID.ROOT),sDim,dDim,90,BLACK()) else LbOn = AddLabelPnt(Lr,EgtMP(a2,GDB_ID.ROOT),sDim,dDim,0,BLACK()) end EgtSetStatus(LbOn,GDB_ST.OFF) -- Etichette sulla figura local stdoffset = 1 local LblL1 = AddLabel(Le,l1,stdoffset,CMP.N1,dim,-90,RED()) EgtSetInfo(LblL1,"Var",1) local LblL2 = AddLabel(Le,l2,stdoffset,CMP.N2,dim,-90,RED()) EgtSetInfo(LblL2,"Var",2) local LblL3 = AddLabel(Le,l3,stdoffset,CMP.N3,dim,-90,RED()) EgtSetInfo(LblL3,"Var",3) local LblL4 = AddLabel(Le,l4,stdoffset,CMP.N4,dim,-90,RED()) EgtSetInfo(LblL4,"Var",4) local LblL5 = AddLabel(Le,l5,stdoffset,L5label,dim,-90,GREEN()) local LblL6 = AddLabel(Le,l6,stdoffset,L6label,dim,-90,GREEN()) local LblD1 if CMP.ERR == 0 then LblD1 = AddLabelAl(La,d1,stdoffset*.75,D1label,dim/2,90,GREEN()) end -- Etichette sotto la figura local lLenL5 = EgtToUiUnits(L5) local sLenL5 = EgtNumToString(lLenL5,1) local ValL5 = EgtTextAdv(Le,pVal,0,L5label..'='..sLenL5,'',100,'S',dim*.75,1,0,GDB_TI.BL,GDB_RT.GLOB) EgtSetColor(ValL5,GREEN()) EgtSetStatus(ValL5,GDB_ST.SEL) local ValL5Len = (EgtEP(ValL5,GDB_RT.GLOB)-EgtSP(ValL5,GDB_RT.GLOB)):getX() + dim/2 pVal = pVal + Vector3d(ValL5Len,0,0) local lLenL6 = EgtToUiUnits(L6) local sLenL6 = EgtNumToString(lLenL6,1) local ValL6 = EgtTextAdv(Le,pVal,0,L6label..'='..sLenL6,'',100,'S',dim*.75,1,0,GDB_TI.BL,GDB_RT.GLOB) EgtSetColor(ValL6,GREEN()) EgtSetStatus(ValL6,GDB_ST.SEL) local ValL6Len = (EgtEP(ValL6,GDB_RT.GLOB)-EgtSP(ValL6,GDB_RT.GLOB)):getX() + dim/2 pVal = pVal + Vector3d(ValL6Len,0,0) if CMP.ERR == 0 then local lLenD1 = EgtToUiUnits(D1) local sLenD1 = EgtNumToString(lLenD1,1) local ValD1 = EgtTextAdv(La,pVal,0,D1label..'='..sLenD1,'',100,'S',dim*.5,1,0,GDB_TI.BL,GDB_RT.GLOB) EgtSetColor(ValD1,GREEN()) EgtSetStatus(ValD1,GDB_ST.SEL) end -- Se non Preview if not bPreview then -- cancello etichette e parti ausiliarie (es.: altezze, diagonali ) EgtErase({La,Le}) -- rendo visibile label sul pezzo EgtSetStatus(LbOn,GDB_ST.ON) end -- Se ok if CMP.ERR == 0 then -- scrivo i parametri nelle info del pezzo WriteCompoDataToPart( Pz, CMP.Nome, CMP.Npar) -- salvo i parametri come nuovo default SaveCompoData( CMP.Npar) end end _G.CMP_Draw = CMP_Draw CMP_Draw(true) EgtZoom(SCE_ZM.ALL)