Exemplo n.º 1
0
        /// <summary>
        /// Exports a curtain roof to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="hostElement">
        /// The host object element to be exported.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportExtrusionRoof(ExporterIFC exporterIFC, ExtrusionRoof hostElement, IFCProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGridSet grids = hostElement.CurtainGrids;

            if (grids == null || grids.Size == 0)
            {
                return;
            }

            ICollection <ElementId> allSubElements = new HashSet <ElementId>();

            foreach (CurtainGrid grid in grids)
            {
                foreach (ElementId panelId in grid.GetPanelIds())
                {
                    allSubElements.Add(panelId);
                }
                foreach (ElementId subElem in grid.GetMullionIds())
                {
                    allSubElements.Add(subElem);
                }
            }
            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provides a unified interface to get the curtain grids associated with an element.
        /// </summary>
        /// <param name="element">The host element.</param>
        /// <returns>A CurtainGridSet with 0 or more CurtainGrids, or null if invalid.</returns>
        public static CurtainGridSet GetCurtainGridSet(Element element)
        {
            CurtainGridSet curtainGridSet = null;

            if (element is Wall)
            {
                Wall wall = element as Wall;
                if (!CurtainSystemExporter.IsLegacyCurtainWall(wall))
                {
                    CurtainGrid curtainGrid = wall.CurtainGrid;
                    curtainGridSet = new CurtainGridSet();
                    if (curtainGrid != null)
                    {
                        curtainGridSet.Insert(curtainGrid);
                    }
                }
            }
            else if (element is FootPrintRoof)
            {
                FootPrintRoof footPrintRoof = element as FootPrintRoof;
                curtainGridSet = footPrintRoof.CurtainGrids;
            }
            else if (element is ExtrusionRoof)
            {
                ExtrusionRoof extrusionRoof = element as ExtrusionRoof;
                curtainGridSet = extrusionRoof.CurtainGrids;
            }
            else if (element is CurtainSystem)
            {
                CurtainSystem curtainSystem = element as CurtainSystem;
                curtainGridSet = curtainSystem.CurtainGrids;
            }

            return(curtainGridSet);
        }
        /// <summary>
        /// Create a extrusion roof.
        /// </summary>
        /// <param name="profile">The profile combined of straight lines and arcs.</param>
        /// <param name="refPlane">The reference plane for the extrusion roof.</param>
        /// <param name="level">The reference level of the roof to be created.</param>
        /// <param name="roofType">The type of the newly created roof.</param>
        /// <param name="extrusionStart">The extrusion start point.</param>
        /// <param name="extrusionEnd">The extrusion end point.</param>
        /// <returns>Return a new created extrusion roof.</returns>
        public ExtrusionRoof CreateExtrusionRoof(
            CurveArray profile,
            ReferencePlane refPlane,
            Level level,
            RoofType roofType,
            double extrusionStart,
            double extrusionEnd)
        {
            ExtrusionRoof extrusionRoof         = null;
            Transaction   createRoofTransaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "ExtrusionRoof");

            createRoofTransaction.Start();
            try
            {
                extrusionRoof = m_creationDoc.NewExtrusionRoof(profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
                createRoofTransaction.Commit();
            }
            catch (System.Exception e)
            {
                createRoofTransaction.RollBack();
                throw e;
            }

            return(extrusionRoof);
        }
Exemplo n.º 4
0
        CurtainSystemToWireframe()
        {
            if (m_revitApp.ActiveUIDocument.Selection.GetElementIds().Count == 0)
            {
                MessageBox.Show("Please select elements and re-run test.", "No Elements Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            GraphicsStreamRevit grStream = new GraphicsStreamRevit(m_revitApp);

            grStream.PushView(m_revitApp.ActiveUIDocument.Document.ActiveView);

            Options opts = m_revitApp.Application.Create.NewGeometryOptions();

            opts.ComputeReferences = true;
            opts.View = m_revitApp.ActiveUIDocument.Document.ActiveView;
            grStream.PushGeometryOptions(opts);

            // transform everything by 50 in both the X and Y axes
            Transform xform = new Transform(Transform.Identity);

            xform.Origin = new XYZ(50.0, 50.0, 0.0);
            grStream.PushXform(xform);
            Document dbDoc         = m_revitApp.ActiveUIDocument.Document;
            var      selElementIds = m_revitApp.ActiveUIDocument.Selection.GetElementIds();

            foreach (ElementId elemId in selElementIds)
            {
                Element elem = dbDoc.GetElement(elemId);
                if (elem is Wall)
                {
                    Wall wall = elem as Wall;

                    if (wall.WallType.Kind == WallKind.Curtain)
                    {
                        WriteCurtainCells(wall.CurtainGrid, grStream); // call same function for each
                    }
                }
                else if (elem is ExtrusionRoof)
                {
                    ExtrusionRoof roof = elem as ExtrusionRoof;

                    foreach (CurtainGrid grid in roof.CurtainGrids)
                    {
                        WriteCurtainCells(grid, grStream);
                    }
                }
                else if (elem is CurtainSystem)
                {
                    CurtainSystem curtSys = elem as CurtainSystem;

                    foreach (CurtainGrid grid in curtSys.CurtainGrids)
                    {
                        WriteCurtainCells(grid, grStream);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Exports a roof to IfcRoof.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="roof">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The IFCProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, RoofBase roof, GeometryElement geometryElement, IFCProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // export parts or not
                bool exportParts = PartExporter.CanExportParts(roof);
                bool exportAsExtrusionCurtainRoof = false;
                bool exportAsFootprintCurtainRoof = false;
                if (roof is ExtrusionRoof)
                {
                    ExtrusionRoof extrusionRoof = roof as ExtrusionRoof;
                    exportAsExtrusionCurtainRoof = ((extrusionRoof.CurtainGrids != null) && (extrusionRoof.CurtainGrids.Size != 0));
                }
                else if (roof is FootPrintRoof)
                {
                    FootPrintRoof footprintRoof = roof as FootPrintRoof;
                    exportAsFootprintCurtainRoof = ((footprintRoof.CurtainGrids != null) && (footprintRoof.CurtainGrids.Size != 0));
                }

                if (exportParts)
                {
                    if (!PartExporter.CanExportElementInPartExport(roof, roof.Level.Id, false))
                    {
                        return;
                    }
                    ExportRoofAsParts(exporterIFC, roof, geometryElement, productWrapper); // Right now, only flat roof could have parts.
                }
                else if (exportAsExtrusionCurtainRoof)
                {
                    CurtainSystemExporter.ExportExtrusionRoof(exporterIFC, roof as ExtrusionRoof, productWrapper);
                }
                else if (exportAsFootprintCurtainRoof)
                {
                    CurtainSystemExporter.ExportFootPrintRoof(exporterIFC, roof as FootPrintRoof, productWrapper);
                }
                else
                {
                    string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, roof);

                    IFCAnyHandle roofHnd = ExporterIFCUtils.ExportRoofAsContainer(exporterIFC, ifcEnumType, roof,
                                                                                  geometryElement, productWrapper);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(roofHnd))
                    {
                        ExportRoof(exporterIFC, ifcEnumType, roof, geometryElement, productWrapper);
                    }

                    PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, roof, productWrapper);

                    // call for host objects; curtain roofs excused from call (no material information)
                    HostObjectExporter.ExportHostObjectMaterials(exporterIFC, roof, productWrapper.GetAnElement(),
                                                                 geometryElement, productWrapper, ElementId.InvalidElementId, IFCLayerSetDirection.Axis3);
                }
                tr.Commit();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a extrusion roof.
        /// </summary>
        /// <param name="refPlane">The reference plane for the extrusion roof.</param>
        /// <param name="level">The reference level of the roof to be created.</param>
        /// <param name="roofType">The type of the newly created roof.</param>
        /// <param name="extrusionStart">The extrusion start point.</param>
        /// <param name="extrusionEnd">The extrusion end point.</param>
        /// <returns>Return a new created extrusion roof.</returns>
        public ExtrusionRoof CreateExtrusionRoof(ReferencePlane refPlane,
                                                 Level level, RoofType roofType, double extrusionStart, double extrusionEnd)
        {
            ExtrusionRoof roof = null;

            roof = m_extrusionRoofManager.CreateExtrusionRoof(m_profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
            if (roof != null)
            {
                m_extrusionRoofs.Insert(roof);
            }
            return(roof);
        }
Exemplo n.º 7
0
        /***************************************************/

        public static List <CurtainGrid> CurtainGrids(this ExtrusionRoof roof)
        {
            List <CurtainGrid> result = new List <CurtainGrid>();

            if (roof.CurtainGrids != null)
            {
                foreach (CurtainGrid cg in roof.CurtainGrids)
                {
                    result.Add(cg);
                }
            }

            return(result);
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("NewExtrusionRoof");

                RoofType fs
                    = new FilteredElementCollector(doc)
                      .OfClass(typeof(RoofType))
                      .Cast <RoofType>()
                      .FirstOrDefault <RoofType>(a => null != a);

                Level lvl
                    = new FilteredElementCollector(doc)
                      .OfClass(typeof(Level))
                      .Cast <Level>()
                      .FirstOrDefault <Level>(a => null != a);

                double x = 1;

                XYZ origin = new XYZ(x, 0, 0);
                XYZ vx     = XYZ.BasisY;
                XYZ vy     = XYZ.BasisZ;

                SketchPlane sp = SketchPlane.Create(doc,
                                                                                                   //new Autodesk.Revit.DB.Plane( vx, vy, origin ) // 2016
                                                    Plane.CreateByOriginAndBasis(origin, vx, vy)); // 2017

                CurveArray ca = new CurveArray();

                XYZ[] pts = new XYZ[] {
                    new XYZ(x, 1, 0),
                    new XYZ(x, 1, 1),
                    new XYZ(x, 2, 1),
                    new XYZ(x, 2, 2),
                    new XYZ(x, 3, 2),
                    new XYZ(x, 3, 3),
                    new XYZ(x, 4, 3),
                    new XYZ(x, 4, 4)
                };

                int n = pts.Length;

                for (int i = 1; i < n; ++i)
                {
                    ca.Append(Line.CreateBound(
                                  pts[i - 1], pts[i]));
                }

                doc.Create.NewModelCurveArray(ca, sp);

                View v = doc.ActiveView;

                ReferencePlane rp
                    = doc.Create.NewReferencePlane2(
                          origin, origin + vx, origin + vy, v);

                rp.Name = "MyRoofPlane";

                ExtrusionRoof er
                    = doc.Create.NewExtrusionRoof(
                          ca, rp, lvl, fs, 0, 3);

                Debug.Print("Extrusion roof element id: "
                            + er.Id.ToString());

                tx.Commit();
            }
            return(Result.Succeeded);
        }
Exemplo n.º 9
0
 /// <summary>
 /// The construct of the ExtrusionRoofWrapper class.
 /// </summary>
 /// <param name="roof">The extrusion roof which will be edited in a PropertyGrid.</param>
 public ExtrusionRoofWrapper(ExtrusionRoof roof)
 {
     m_roof = roof;
 }
Exemplo n.º 10
0
        private void Stream( ArrayList data, ExtrusionRoof extrusionRoof )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( ExtrusionRoof ) ) );

              data.Add( new Snoop.Data.Enumerable( "Curtain grids", extrusionRoof.CurtainGrids ) );

              // TBD: how to display Profiles and other functions?
        }
Exemplo n.º 11
0
 /// <summary>
 /// The construct of the ExtrusionRoofWrapper class.
 /// </summary>
 /// <param name="roof">The extrusion roof which will be edited in a PropertyGrid.</param>
 public ExtrusionRoofWrapper(ExtrusionRoof roof)
 {
     m_roof = roof;
 }
Exemplo n.º 12
0
        public void InsertOpening(Document doc, FamilySymbol familySymbol)
        {
            Element host = doc.GetElement(HostId);

            if (host.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Walls)
            {
                Wall      wall      = host as Wall;
                Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();
                ElementId levelId   = host.LevelId;

                Face face = host.GetGeometryObjectFromReference(reference) as Face;
                IntersectionResult intResult = face.Project(LocationPoint);
                if (intResult == null)
                {
                    return;                    // important to prompt user if no face found
                }
                double distance = intResult.Distance;
                if (distance > 0.001)
                {
                    reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).First();;
                }

                FamilyInstance fi        = doc.Create.NewFamilyInstance(reference, LocationPoint, new XYZ(0, 0, 0), familySymbol);
                Parameter      parameter = fi.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM);
                if (parameter != null)
                {
                    parameter.Set(levelId);
                }

                if (OpeningType == OpeningType.Round)
                {
                    fi.LookupParameter("D").Set(_cloudOpening.Diameter);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                if (OpeningType == OpeningType.Rectangular)
                {
                    fi.LookupParameter("b").Set(_cloudOpening.Width);
                    fi.LookupParameter("h").Set(_cloudOpening.Height);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                fi.LookupParameter("Depth").Set(Depth);
            }


            if (host.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Floors)
            {
                Floor          floor     = host as Floor;
                Reference      reference = HostObjectUtils.GetTopFaces(floor).First();
                ElementId      levelId   = host.LevelId;
                FamilyInstance fi        = doc.Create.NewFamilyInstance(reference, LocationPoint, new XYZ(0, 0, 0), familySymbol);
                Parameter      parameter = fi.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM);
                if (parameter != null)
                {
                    parameter.Set(levelId);
                }

                if (OpeningType == OpeningType.Round)
                {
                    fi.LookupParameter("D").Set(_cloudOpening.Diameter);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                if (OpeningType == OpeningType.Rectangular)
                {
                    fi.LookupParameter("b").Set(_cloudOpening.Width);
                    fi.LookupParameter("h").Set(_cloudOpening.Height);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                fi.LookupParameter("Depth").Set(Depth);
            }


            if (host.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Ceilings)
            {
                Ceiling        ceiling   = host as Ceiling;
                Reference      reference = HostObjectUtils.GetTopFaces(ceiling).First();
                ElementId      levelId   = host.LevelId;
                FamilyInstance fi        = doc.Create.NewFamilyInstance(reference, LocationPoint, new XYZ(0, 0, 0), familySymbol);
                Parameter      parameter = fi.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM);
                if (parameter != null)
                {
                    parameter.Set(levelId);
                }

                if (OpeningType == OpeningType.Round)
                {
                    fi.LookupParameter("D").Set(_cloudOpening.Diameter);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                if (OpeningType == OpeningType.Rectangular)
                {
                    fi.LookupParameter("b").Set(_cloudOpening.Width);
                    fi.LookupParameter("h").Set(_cloudOpening.Height);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                fi.LookupParameter("Depth").Set(_cloudOpening.Depth);
            }

            if (host.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Roofs)
            {
                Reference        reference  = null;
                ExtrusionRoof    eRoof      = host as ExtrusionRoof;
                List <Reference> references = HostObjectUtils.GetTopFaces(eRoof).ToList();
                foreach (Reference r in references)
                {
                    Face face = host.GetGeometryObjectFromReference(r) as Face;
                    //bool test = face.IsInside(new UV(LocationPoint.X, LocationPoint.Y));
                    IntersectionResult intResult = face.Project(LocationPoint);
                    if (intResult == null)
                    {
                        continue;
                    }
                    double distance = intResult.Distance;
                    if (distance < 0.001)
                    {
                        reference = r;
                    }
                }
                if (reference == null)
                {
                    return;
                }

                ElementId      levelId   = host.LevelId;
                FamilyInstance fi        = doc.Create.NewFamilyInstance(reference, LocationPoint, new XYZ(0, 0, 0), familySymbol);
                Parameter      parameter = fi.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM);
                if (parameter != null)
                {
                    parameter.Set(levelId);
                }

                if (OpeningType == OpeningType.Round)
                {
                    fi.LookupParameter("D").Set(_cloudOpening.Diameter);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                if (OpeningType == OpeningType.Rectangular)
                {
                    fi.LookupParameter("b").Set(_cloudOpening.Width);
                    fi.LookupParameter("h").Set(_cloudOpening.Height);
                    fi.LookupParameter("Cut Offset").Set(_cloudOpening.Offset);
                    fi.get_Parameter(new Guid("f417eece-19f0-4253-9820-f876661146e3")).Set(GtbPairGuid);
                }
                fi.LookupParameter("Depth").Set(_cloudOpening.Depth);
            }
        }
Exemplo n.º 13
0
 protected GCRoofExtrusion(ExtrusionRoof elem)
     : base(elem)
 {
 }
Exemplo n.º 14
0
 protected AGCRoofBase(ExtrusionRoof elem)
     : base(elem)
 {
 }
Exemplo n.º 15
0
        /// <summary>
        /// Exports a curtain roof to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="hostElement">
        /// The host object element to be exported.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportExtrusionRoof(ExporterIFC exporterIFC, ExtrusionRoof hostElement, IFCProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGridSet grids = hostElement.CurtainGrids;
            if (grids == null || grids.Size == 0)
                return;

            ICollection<ElementId> allSubElements = new HashSet<ElementId>();
            foreach (CurtainGrid grid in grids)
            {
                foreach (ElementId panelId in grid.GetPanelIds())
                    allSubElements.Add(panelId);
                foreach (ElementId subElem in grid.GetMullionIds())
                    allSubElements.Add(subElem);
            }
            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }