Exemplo n.º 1
0
 internal static FilledRegion FromExisting(Autodesk.Revit.DB.FilledRegion instance, bool isRevitOwned)
 {
     return(new FilledRegion(instance)
     {
         IsRevitOwned = isRevitOwned
     });
 }
Exemplo n.º 2
0
        public static global::Revit.Elements.Element ByMultipleLoops(global::Revit.Elements.FilledRegionType filledRegionType, global::Revit.Elements.Views.View view, List <List <Curve> > curvesToUse)
        {
            //the current document
            Document doc = DocumentManager.Instance.CurrentDBDocument;

            //boundary loop to append nested loops to
            List <CurveLoop> boundariesLoop = new List <CurveLoop>();

            //iterate through the loops and create curve loops
            foreach (var curveList in curvesToUse)
            {
                SortCurves(curveList);
                List <Autodesk.Revit.DB.Curve> curves = new List <Autodesk.Revit.DB.Curve>();
                foreach (var curve in curveList)
                {
                    curves.Add(curve.ToRevitType(true));
                }
                boundariesLoop.Add(CurveLoop.Create(curves));
            }

            //build the filled region
            TransactionManager.Instance.EnsureInTransaction(doc);
            var filledRegion = FilledRegion.Create(doc, filledRegionType.InternalElement.Id, view.InternalElement.Id, boundariesLoop);

            TransactionManager.Instance.TransactionTaskDone();

            //return the newly created revit element
            return(filledRegion.ToDSType(true));
        }
Exemplo n.º 3
0
        public static List <Face3D> Face3Ds(this Autodesk.Revit.DB.FilledRegion filledRegion, double tolerance = Core.Tolerance.Distance)
        {
            if (filledRegion == null)
            {
                return(null);
            }

            IList <CurveLoop> curveLoops = filledRegion.GetBoundaries();

            if (curveLoops == null)
            {
                return(null);
            }

            View view = filledRegion.Document.GetElement(filledRegion.OwnerViewId) as View;

            if (view == null)
            {
                return(null);
            }

            Vector3D normal = view.ViewDirection.ToSAM_Vector3D(false);

            if (normal == null)
            {
                return(null);
            }

            Spatial.Plane           plane      = view.Plane();
            List <Planar.Polygon2D> polygon2Ds = new List <Planar.Polygon2D>();

            foreach (CurveLoop curveLoop in curveLoops)
            {
                Polygon3D polygon3D = curveLoop.ToSAM_Polygon3D(view.ViewDirection, tolerance);
                if (polygon3D == null)
                {
                    continue;
                }

                polygon2Ds.Add(plane.Convert(polygon3D));
            }

            List <Planar.Face2D> face2Ds = Planar.Create.Face2Ds(polygon2Ds, tolerance);

            if (face2Ds == null)
            {
                return(null);
            }

            return(face2Ds.ConvertAll(x => plane.Convert(x)));
        }
Exemplo n.º 4
0
 public static FilledRegion Wrap(Autodesk.Revit.DB.FilledRegion ele, bool isRevitOwned)
 {
     return(FilledRegion.FromExisting(ele, isRevitOwned));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Init element
 /// </summary>
 /// <param name="element"></param>
 private void InitElement(Autodesk.Revit.DB.FilledRegion element)
 {
     InternalSetElement(element);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="FilledRegion"></param>
 private FilledRegion(Autodesk.Revit.DB.FilledRegion FilledRegion)
 {
     SafeInit(() => InitElement(FilledRegion));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 private void InternalSetElement(Autodesk.Revit.DB.FilledRegion element)
 {
     InternalRevitElement = element;
     InternalElementId    = element.Id;
     InternalUniqueId     = element.UniqueId;
 }
Exemplo n.º 8
0
        public static FilledRegion ToSAM(this Autodesk.Revit.DB.FilledRegion filledRegion, ConvertSettings convertSettings)
        {
            if (filledRegion == null || !filledRegion.IsValidObject)
            {
                return(null);
            }

            FilledRegion result = convertSettings?.GetObject <FilledRegion>(filledRegion.Id);

            if (result != null)
            {
                return(result);
            }

            Document document = filledRegion.Document;

            if (document == null)
            {
                return(result);
            }

            Autodesk.Revit.DB.FilledRegionType filledRegionType_Revit = document.GetElement(filledRegion.GetTypeId()) as Autodesk.Revit.DB.FilledRegionType;
            if (filledRegionType_Revit == null)
            {
                return(null);
            }

            View view = filledRegion.Document.GetElement(filledRegion.OwnerViewId) as View;

            if (view == null)
            {
                return(null);
            }

            Spatial.Plane plane = view.Plane();
            if (plane == null)
            {
                return(null);
            }

            List <Face3D> face3Ds = filledRegion.Face3Ds();

            if (face3Ds == null)
            {
                return(null);
            }

            FilledRegionType     filledRegionType = filledRegionType_Revit.ToSAM(convertSettings);
            List <Planar.Face2D> face2Ds          = face3Ds.ConvertAll(x => Spatial.Query.Convert(plane, x));
            IntegerId            integerId        = Query.IntegerId(view);

            result = new FilledRegion(filledRegionType, integerId, face2Ds);

            if (result != null)
            {
                result.UpdateParameterSets(filledRegion, ActiveSetting.Setting.GetValue <TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap));
                convertSettings?.Add(filledRegion.Id, result);
            }

            return(result);
        }