Beispiel #1
0
        private static TracedSpace GetServedSpaceForOpenDuctEnd(Document m_document, MEPCurve ductInst, int equipId)
        {
            TracedSpace ts = null;
            string      servedSpaceName = null;

            foreach (Connector dCon in ductInst.ConnectorManager.Connectors)
            {
                foreach (Connector rCon in dCon.AllRefs)
                {
                    if (rCon.ConnectorType == ConnectorType.Logical)
                    {
                        Space spc = m_document.GetSpaceAtPoint(dCon.Origin);
                        if (spc != null)
                        {
                            Parameter nameParam   = Util.GetParameter(spc, "Name");
                            Parameter numberParam = Util.GetParameter(spc, "Number");

                            string nameParamValue   = nameParam.AsString();
                            string numberParamValue = numberParam.AsString();
                            servedSpaceName = string.Format("{0} {1}", nameParamValue, numberParamValue);
                            ts = new TracedSpace(equipId, servedSpaceName, spc.Id.IntegerValue);
                        }
                        else
                        {
                            ts = new TracedSpace(equipId, "OpenDuctNotInSpace", null);
                        }
                    }
                }
            }
            return(ts);
        }
Beispiel #2
0
        private static TracedSpace GetServedSpaceForFI(FamilyInstance famInst, int equipId)
        {
            TracedSpace ts = null;
            string      servedSpaceName = null;

            //  try to get space name
            if (famInst.Space != null)
            {
                Space     spc         = famInst.Space;
                Parameter nameParam   = Util.GetParameter(spc, "Name");
                Parameter numberParam = Util.GetParameter(spc, "Number");

                string nameParamValue   = nameParam.AsString();
                string numberParamValue = numberParam.AsString();

                if (!string.IsNullOrWhiteSpace(nameParamValue))
                {
                    servedSpaceName = string.Format("{0} {1}", nameParamValue, numberParamValue);
                }
                else
                {
                    servedSpaceName = "UnnamedRoom";
                }
                ts = new TracedSpace(equipId, servedSpaceName, spc.Id.IntegerValue);
            }
            else
            {
                ts = new TracedSpace(equipId, "ClosedDuctNotInSpace", null);
            }

            return(ts);
        }
Beispiel #3
0
        public static List <TracedSpace> GetDownstreamRoomNames(FamilyInstance vavFamilyInstance, Document m_document, bool includeUnterminated)
        {
            List <TracedSpace> tracedSpaces         = new List <TracedSpace>();
            Element            terminalEquipElement = (Element)vavFamilyInstance;

            //string notTerminatedInRoomString = "ClosedDuctNotInSpace";

            //List<string> servedRoomNames = new List<string>();

            //  get connectors
            Connector[] familyInstanceConnectors = Util.GetConnectorsFromFamilyInstance(terminalEquipElement);

            List <Connector> downstreamConnectors = GetDownstreamConnectors(familyInstanceConnectors);

            if (downstreamConnectors.Count == 0)
            {
                return(tracedSpaces);
            }


            foreach (Connector terminalEquipConnector in downstreamConnectors)   // most terminal equipment would have just one downstream connector
            {
                //  get system for this connector
                MEPSystem connectorMEPSystem = null;
                connectorMEPSystem = GetOrCreateMEPSystemOnConnector(m_document, terminalEquipConnector);

                List <ElementId> elementIds = new List <ElementId>();
                elementIds.Add(terminalEquipElement.Id);

                MechanicalSystem connectorMechSystem = connectorMEPSystem as MechanicalSystem;

                ElementSet terminalElements = connectorMEPSystem.Elements;  // terminal element = elements at the end of the end of the branches; can return duct or family instances

                //Create a string of all Room Names & Numbers
                //Here we gather all elements connected to the system
                foreach (Element terminalElement in terminalElements)
                {
                    //  terminalElements contains the original equipment element.  need to ignore that when iterating because we just want the termination points
                    if (terminalElement.Id == vavFamilyInstance.Id)
                    {
                        continue;
                    }

                    FamilyInstance famInst        = terminalElement as FamilyInstance;
                    MEPCurve       ductInst       = terminalElement as Duct;
                    MEPCurve       flexDuctInst   = terminalElement as FlexDuct;
                    MEPCurve       ductEndSegment = ductInst ?? flexDuctInst;

                    //For each air terminal and equipment, identify the space it belongs to and add that as a parameter
                    //to the air terminal.  That way, the information is stored in case we want to unload the link.

                    if (famInst != null && famInst.Category.Id == m_document.Settings.Categories.get_Item(BuiltInCategory.OST_DuctFitting).Id)
                    {
                        continue;
                    }

                    TracedSpace tracedSpace = null;

                    if (famInst != null)
                    {
                        tracedSpace = GetServedSpaceForFI(famInst, terminalEquipElement.Id.IntegerValue);
                        tracedSpaces.Add(tracedSpace);
                    }
                    else if (ductEndSegment != null)
                    {
                        if (includeUnterminated)
                        {
                            tracedSpace = GetServedSpaceForOpenDuctEnd(m_document, ductEndSegment, terminalEquipElement.Id.IntegerValue);
                            tracedSpaces.Add(tracedSpace);
                        }
                    }
                }
            }

            return(tracedSpaces);
        }