Esempio n. 1
0
 /// <summary>
 /// Create from existing
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static FilledRegionType FromExisting(Autodesk.Revit.DB.FilledRegionType instance, bool isRevitOwned)
 {
     return(new FilledRegionType(instance)
     {
         IsRevitOwned = isRevitOwned
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Construct a Revit FilledRegion element by Curves
        /// </summary>
        /// <param name="view">View to place filled region on</param>
        /// <param name="boundary">Boundary curves</param>
        /// <param name="regionType">Region Type</param>
        /// <returns></returns>
        public static FilledRegion ByCurves(Revit.Elements.Views.View view, IEnumerable <Autodesk.DesignScript.Geometry.Curve> boundary, FilledRegionType regionType)
        {
            Autodesk.Revit.DB.FilledRegionType type = regionType.InternalRevitElement;

            CurveLoop loop = new CurveLoop();

            foreach (Autodesk.DesignScript.Geometry.Curve curve in boundary)
            {
                loop.Append(curve.ToRevitType());
            }

            if (loop.IsOpen())
            {
                throw new Exception(Properties.Resources.CurveLoopNotClosed);
            }

            Autodesk.Revit.DB.View revitView = (Autodesk.Revit.DB.View)view.InternalElement;

            if (!view.IsAnnotationView())
            {
                throw new Exception(Properties.Resources.ViewDoesNotSupportAnnotations);
            }

            return(new FilledRegion(revitView, type.Id, new List <CurveLoop>()
            {
                loop
            }));
        }
Esempio n. 3
0
 public static FilledRegionType Wrap(Autodesk.Revit.DB.FilledRegionType ele, bool isRevitOwned)
 {
     return(FilledRegionType.FromExisting(ele, isRevitOwned));
 }
Esempio n. 4
0
 /// <summary>
 /// FilledRegionType
 /// </summary>
 /// <param name="FilledRegion"></param>
 private FilledRegionType(Autodesk.Revit.DB.FilledRegionType FilledRegion)
 {
     SafeInit(() => InitElement(FilledRegion));
 }
Esempio n. 5
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 private void InternalSetElement(Autodesk.Revit.DB.FilledRegionType element)
 {
     InternalRevitElement = element;
     InternalElementId    = element.Id;
     InternalUniqueId     = element.UniqueId;
 }
Esempio n. 6
0
 /// <summary>
 /// Init Element
 /// </summary>
 private void InitElement(Autodesk.Revit.DB.FilledRegionType element)
 {
     InternalSetElement(element);
 }
Esempio n. 7
0
 /// <summary>
 /// FilledRegionType
 /// </summary>
 /// <param name="FilledRegion"></param>
 private FilledRegionType(Autodesk.Revit.DB.FilledRegionType FilledRegion) : base(FilledRegion)
 {
 }
Esempio 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);
        }