-- 2018/09/01 -- Appiattimento di una curva -- Istruzioni : -- 1) selezionare la curva da appiattire -- 3) eseguire il componente. -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) -- Recupero primo oggetto selezionato (curva da appiattire) local nId = EgtGetFirstSelectedObj() local nType = EgtGetType( nId) if nType ~= GDB_TY.CRV_LINE and nType ~= GDB_TY.CRV_ARC and nType ~= GDB_TY.CRV_BEZ and nType ~= GDB_TY.CRV_COMPO then EgtOutText( 'Il primo oggetto selezionato non è una curva') EgtPause( 500) return end -- Recupero Estrusione e la annullo local vtExtr = EgtCurveExtrusion( nId) EgtModifyCurveExtrusion( nId, V_NULL()) -- Recupero piano medio della curva e verifico se abbastanza piatta local bFlat, vtN, dDist = EgtCurveIsFlat( nId, 0.1) if not bFlat then EgtOutText( 'La curva è molto ingobbita (scostamento oltre 0.1 mm)') end -- Eseguo l'appiattimento local bOk = EgtProjectCurveOnPlane( nId, dDist * vtN, vtN, GDB_RT.LOC) -- Imposto versore estrusione if vtExtr and vtExtr * vtN < 0 then vtN = - vtN end EgtModifyCurveExtrusion( nId, vtN) EgtDraw() EgtPause( 500)