/// <summary>
 /// Create a extrusion roof.
 /// </summary>
 private void createExtrusionRoof()
 {
     try
     {
         if (m_roofsManager.Profile.Size != 0)
         {
             Autodesk.Revit.DB.Level          level    = this.refLevelComboBox.SelectedItem as Autodesk.Revit.DB.Level;
             Autodesk.Revit.DB.RoofType       roofType = this.extrusionRoofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType;
             Autodesk.Revit.DB.ReferencePlane refPlane = refPanesComboBox.SelectedItem as Autodesk.Revit.DB.ReferencePlane;
             if (level != null && roofType != null && refPlane != null)
             {
                 Autodesk.Revit.DB.ExtrusionRoof roof = m_roofsManager.CreateExtrusionRoof(refPlane, level, roofType, m_start, m_end);
                 if (roof == null)
                 {
                     TaskDialog.Show("Revit", "Invalid profile");
                 }
                 else
                 {
                     this.extrusionRoofsListView.Items.Add(new RoofItem(roof));
                     this.extrusionRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                 }
             }
         }
         else
         {
             TaskDialog.Show("Revit", "You should supply profile to create extrusion roof, click select button to select profile in Revit.");
         }
     }
     catch (Exception ex)
     {
         TaskDialog.Show("Revit", ex.Message);
     }
 }
 /// <summary>
 /// Create a new footprint roof.
 /// </summary>
 private void createFootPrintRoof()
 {
     try
     {
         if (m_roofsManager.FootPrint.Size != 0)
         {
             Autodesk.Revit.DB.Level    level    = levelsComboBox.SelectedItem as Autodesk.Revit.DB.Level;
             Autodesk.Revit.DB.RoofType roofType = roofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType;
             if (level != null && roofType != null)
             {
                 Autodesk.Revit.DB.FootPrintRoof roof = m_roofsManager.CreateFootPrintRoof(level, roofType);
                 if (roof == null)
                 {
                     TaskDialog.Show("Revit", "Invalid footprint2");
                 }
                 else
                 {
                     this.footPrintRoofsListView.Items.Add(new RoofItem(roof));
                     this.footPrintRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                 }
             }
         }
         else
         {
             TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit.");
         }
     }
     catch (Exception ex)
     {
         TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops.");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Create a RoofType from a user selected Element.
 /// </summary>
 /// <param name="RoofType"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static RoofType FromExisting(Autodesk.Revit.DB.RoofType RoofType, bool isRevitOwned)
 {
     return(new RoofType(RoofType)
     {
         IsRevitOwned = isRevitOwned
     });
 }
Beispiel #4
0
        void CommitInstance
        (
            Document doc, IGH_DataAccess DA, int Iteration,
            Rhino.Geometry.Curve boundary,
            Autodesk.Revit.DB.RoofType roofType,
            Autodesk.Revit.DB.Level level
        )
        {
            var element = PreviousElement(doc, Iteration);

            if (!element?.Pinned ?? false)
            {
                ReplaceElement(doc, DA, Iteration, element);
            }
            else
            {
                try
                {
                    var scaleFactor = 1.0 / Revit.ModelUnits;
                    if (scaleFactor != 1.0)
                    {
                        boundary?.Scale(scaleFactor);
                    }

                    if
                    (
                        boundary == null ||
                        boundary.IsShort(Revit.ShortCurveTolerance) ||
                        !boundary.IsClosed ||
                        !boundary.TryGetPlane(out var boundaryPlane, Revit.VertexTolerance) ||
                        boundaryPlane.ZAxis.IsParallelTo(Rhino.Geometry.Vector3d.ZAxis) == 0
                    )
                    {
                        throw new Exception(string.Format("Parameter '{0}' must be an horizontal planar closed curve.", Params.Input[0].Name));
                    }

                    var curveArray = boundary.ToHost().ToCurveArray();
                    var footPintToModelCurvesMapping = new ModelCurveArray();
                    element = CopyParametersFrom(doc.Create.NewFootPrintRoof(curveArray, level, roofType, out footPintToModelCurvesMapping), element);

                    if (element != null)
                    {
                        var boundaryBBox = boundary.GetBoundingBox(true);
                        element.get_Parameter(BuiltInParameter.ROOF_BASE_LEVEL_PARAM).Set(level.Id);
                        element.get_Parameter(BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM).Set(boundaryBBox.Min.Z - level.Elevation);
                    }

                    ReplaceElement(doc, DA, Iteration, element);
                }
                catch (Exception e)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message);
                    ReplaceElement(doc, DA, Iteration, null);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Initialize a roof element
        /// </summary>
        private void InitRoof(CurveArray curves, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.RoofType roofType)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            Autodesk.Revit.DB.RoofBase roof = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.RoofBase>(Document);
            if (roof == null)
            {
                ModelCurveArray footprint = new ModelCurveArray();
                roof = Document.Create.NewFootPrintRoof(curves, level, roofType, out footprint);
            }
            else
            {
                ModelCurveArray footprint = new ModelCurveArray();
                roof = Document.Create.NewFootPrintRoof(curves, level, roofType, out footprint);
            }

            InternalSetRoof(roof);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, InternalRoof);
        }
Beispiel #6
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Rhino.Geometry.Curve boundary = null;
            DA.GetData("Boundary", ref boundary);

            Autodesk.Revit.DB.RoofType roofType = null;
            if (!DA.GetData("Type", ref roofType) && Params.Input[1].Sources.Count == 0)
            {
                roofType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.RoofType)) as RoofType;
            }

            Autodesk.Revit.DB.Level level = null;
            DA.GetData("Level", ref level);
            if (level == null && boundary != null)
            {
                var boundaryBBox = boundary.GetBoundingBox(true);
                using (var collector = new FilteredElementCollector(Revit.ActiveDBDocument))
                {
                    foreach (var levelN in collector.OfClass(typeof(Level)).ToElements().Cast <Level>().OrderBy(c => c.Elevation))
                    {
                        if (level == null)
                        {
                            level = levelN;
                        }
                        else if (boundaryBBox.Min.Z >= levelN.Elevation)
                        {
                            level = levelN;
                        }
                    }
                }
            }

            DA.DisableGapLogic();
            int Iteration = DA.Iteration;

            Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, boundary, roofType, level));
        }
Beispiel #7
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Rhino.Geometry.Curve boundary = null;
            DA.GetData("Boundary", ref boundary);

            Autodesk.Revit.DB.RoofType roofType = null;
            if (!DA.GetData("Type", ref roofType) && Params.Input[1].Sources.Count == 0)
            {
                roofType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.RoofType)) as RoofType;
            }

            Autodesk.Revit.DB.Level level = null;
            DA.GetData("Level", ref level);
            if (level == null && boundary != null)
            {
                var boundaryBBox = boundary.GetBoundingBox(true);
                level = Revit.ActiveDBDocument.FindLevelByElevation(boundaryBBox.Min.Z / Revit.ModelUnits);
            }

            DA.DisableGapLogic();
            int Iteration = DA.Iteration;

            Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, boundary, roofType, level));
        }
Beispiel #8
0
        /// <summary>
        /// Initialize a roof element
        /// </summary>
        private void InitRoof(CurveArray curves, Autodesk.Revit.DB.ReferencePlane reference, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.RoofType roofType, double extrusionStart, double extrusionEnd)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            Autodesk.Revit.DB.RoofBase roof = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.RoofBase>(Document);
            if (roof == null)
            {
                roof = Document.Create.NewExtrusionRoof(curves, reference, level, roofType, extrusionStart, extrusionEnd);
            }
            else
            {
                roof = Document.Create.NewExtrusionRoof(curves, reference, level, roofType, extrusionStart, extrusionEnd);
            }

            InternalSetRoof(roof);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, InternalRoof);
        }
Beispiel #9
0
 private Roof(CurveArray curves, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.RoofType roofType)
 {
     SafeInit(() => InitRoof(curves, level, roofType));
 }
Beispiel #10
0
 /// <summary>
 /// Private constructor
 /// </summary>
 private Roof(CurveArray curves, Autodesk.Revit.DB.ReferencePlane reference, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.RoofType roofType, double extrusionStart, double extrusionEnd)
 {
     SafeInit(() => InitRoof(curves, reference, level, roofType, extrusionStart, extrusionEnd));
 }
Beispiel #11
0
 public static RoofType Wrap(Autodesk.Revit.DB.RoofType ele, bool isRevitOwned)
 {
     return(RoofType.FromExisting(ele, isRevitOwned));
 }
Beispiel #12
0
 /// <summary>
 /// Private constructor for the Element
 /// </summary>
 /// <param name="roofType"></param>
 private RoofType(Autodesk.Revit.DB.RoofType roofType) : base(roofType)
 {
 }