コード例 #1
0
        public static List <LinkElementId> FindExteriorWallsByAnalyzer(Document doc, View3D view, Room room)
        {
            List <LinkElementId> exteriorElementIds = new List <LinkElementId>();

            using (Transaction trans = new Transaction(doc))
            {
                trans.Start("Analyze Building Envelope");
                try
                {
                    BuildingEnvelopeAnalyzerOptions options = new BuildingEnvelopeAnalyzerOptions();
                    options.AnalyzeEnclosedSpaceVolumes = false;
                    options.GridCellSize         = FindFloorHeight(doc, room, view);
                    options.OptimizeGridCellSize = false;
                    BuildingEnvelopeAnalyzer analyzer = BuildingEnvelopeAnalyzer.Create(doc, options);
                    if (null != analyzer)
                    {
                        IList <LinkElementId> linkIds = analyzer.GetBoundingElements();

                        if (linkIds.Count > 0)
                        {
                            exteriorElementIds.AddRange(linkIds);
                        }
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                    MessageBox.Show("Bounding elements cannot be defined by Revit API.\nPlease manually set exterior walls and check LEED_IsExteriorWall parameter.", "Building Envelope", MessageBoxButton.OK, MessageBoxImage.Warning);
                    trans.RollBack();
                }
            }
            return(exteriorElementIds);
        }
コード例 #2
0
        public List <Wall> GetOutsideWalls()
        {
            BuildingEnvelopeAnalyzerOptions options  = new BuildingEnvelopeAnalyzerOptions();
            BuildingEnvelopeAnalyzer        analyzer = BuildingEnvelopeAnalyzer.Create(activeDocument, options);
            List <LinkElementId>            linkIds  = analyzer.GetBoundingElements().ToList();
            List <Wall> exteriorWalls = new List <Wall>();

            if (null != analyzer)
            {
                if (linkIds.Count > 0)
                {
                    foreach (LinkElementId linkId in linkIds)
                    {
                        if (linkId.HostElementId != ElementId.InvalidElementId)
                        {
                            Wall hostWall = activeDocument.GetElement(linkId.HostElementId) as Wall;
                            if (null != hostWall)
                            {
                                exteriorWalls.Add(hostWall);
                            }
                        }
                        else if (linkId.LinkedElementId != ElementId.InvalidElementId)
                        {
                            RevitLinkInstance rvtInstance = activeDocument.GetElement(linkId.LinkInstanceId) as RevitLinkInstance;
                            if (null != rvtInstance)
                            {
                                Wall linkWall = rvtInstance.Document.GetElement(linkId.LinkedElementId) as Wall;
                                if (null != linkWall)
                                {
                                    exteriorWalls.Add(linkWall);
                                }
                            }
                        }
                    }
                }
            }
            return(exteriorWalls);
        }