Пример #1
0
        /// <summary>
        /// 获得指定设备的所有连接键
        /// </summary>
        /// <param name="revitDoc">Revit Document</param>
        /// <param name="instId">实例ID</param>
        public static List <RevitConnector> GetRevitConnectors(Document revitDoc, ElementId instId)
        {
            FamilyInstance          oInst     = revitDoc.GetElement(instId) as FamilyInstance;
            Family                  family    = oInst.Symbol.Family;
            Document                familyDoc = revitDoc.EditFamily(family);
            List <ConnectorElement> elems     = GetConnectorElement(familyDoc);
            Transform               transfrom = GetTransform(revitDoc, oInst);

            if (transfrom == null)
            {
                return(null);
            }
            List <RevitConnector> rcList = new List <RevitConnector>();

            foreach (Element elem in elems)
            {
                ConnectorElement ce   = elem as ConnectorElement;
                Parameter        para = ce.get_Parameter(BuiltInParameter.RBS_CONNECTOR_DESCRIPTION);
                if (para != null)
                {
                    RevitConnector rc = new RevitConnector();
                    rc.Description = para.AsString();
                    rc.Direction   = transfrom.OfPoint(ce.CoordinateSystem.BasisZ);
                    rc.LocalPoint  = transfrom.OfPoint(ce.Origin);
                    rc.Connector   = GetConnector(oInst, rc.LocalPoint);
                    rcList.Add(rc);
                }
            }
            return(rcList);
        }
Пример #2
0
        /// <summary>
        /// create the connectors on the extrusions
        /// </summary>
        private void CreateConnectors()
        {
            List <PlanarFace> m_planarFaces = null;
            Parameter         param         = null;

            #region Create the Supply Air duct connector

            // get the planar faces of extrusion1
            m_planarFaces = GetPlanarFaces(extrusions[1]);

            // create the Supply Air duct connector
            //DuctConnector connSupplyAir = f.NewDuctConnector(m_planarFaces[0].Reference,
            //    DuctSystemType.SupplyAir);
            ConnectorElement connSupplyAir = ConnectorElement.CreateDuctConnector(m_document, DuctSystemType.SupplyAir, ConnectorProfileType.Rectangular, m_planarFaces[0].Reference);
            param = connSupplyAir.get_Parameter(BuiltInParameter.CONNECTOR_HEIGHT);
            param.Set(connectorDimensions[0, 0]);
            param = connSupplyAir.get_Parameter(BuiltInParameter.CONNECTOR_WIDTH);
            param.Set(connectorDimensions[0, 1]);
            param = connSupplyAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_DIRECTION_PARAM);
            param.Set(2);
            param = connSupplyAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_CONFIGURATION_PARAM);
            param.Set(1);
            param = connSupplyAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_PARAM);
            param.Set(flow);

            #endregion

            #region Create the Return Air duct connector

            // get the planar faces of extrusion2
            m_planarFaces = GetPlanarFaces(extrusions[2]);

            // create the Return Air duct connector
            //DuctConnector connReturnAir = f.NewDuctConnector(m_planarFaces[0].Reference,
            //    DuctSystemType.ReturnAir);
            ConnectorElement connReturnAir = ConnectorElement.CreateDuctConnector(m_document, DuctSystemType.ReturnAir, ConnectorProfileType.Rectangular, m_planarFaces[0].Reference);
            param = connReturnAir.get_Parameter(BuiltInParameter.CONNECTOR_HEIGHT);
            param.Set(connectorDimensions[1, 0]);
            param = connReturnAir.get_Parameter(BuiltInParameter.CONNECTOR_WIDTH);
            param.Set(connectorDimensions[1, 1]);
            param = connReturnAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_DIRECTION_PARAM);
            param.Set(1);
            param =
                connReturnAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_CONFIGURATION_PARAM);
            param.Set(1);
            param = connReturnAir.get_Parameter(BuiltInParameter.RBS_DUCT_FLOW_PARAM);
            param.Set(flow);

            #endregion

            #region Create the Supply Hydronic pipe connector

            // get the planar faces of extrusion3
            m_planarFaces = GetPlanarFaces(extrusions[3]);

            // create the Hydronic Supply pipe connector
            //PipeConnector connSupplyHydronic = f.NewPipeConnector(m_planarFaces[0].Reference,
            //    PipeSystemType.SupplyHydronic);
            ConnectorElement connSupplyHydronic = ConnectorElement.CreatePipeConnector(m_document, PipeSystemType.SupplyHydronic, m_planarFaces[0].Reference);
            param = connSupplyHydronic.get_Parameter(BuiltInParameter.CONNECTOR_RADIUS);
            param.Set(arcRadius);
            param =
                connSupplyHydronic.get_Parameter(BuiltInParameter.RBS_PIPE_FLOW_DIRECTION_PARAM);
            param.Set(2);

            #endregion

            #region Create the Return Hydronic pipe connector

            // get the planar faces of extrusion4
            m_planarFaces = GetPlanarFaces(extrusions[4]);

            // create the Hydronic Return pipe connector
            //PipeConnector connReturnHydronic = f.NewPipeConnector(m_planarFaces[0].Reference,
            //    PipeSystemType.ReturnHydronic);
            ConnectorElement connReturnHydronic = ConnectorElement.CreatePipeConnector(m_document, PipeSystemType.ReturnHydronic, m_planarFaces[0].Reference);
            param = connReturnHydronic.get_Parameter(BuiltInParameter.CONNECTOR_RADIUS);
            param.Set(arcRadius);
            param =
                connReturnHydronic.get_Parameter(BuiltInParameter.RBS_PIPE_FLOW_DIRECTION_PARAM);
            param.Set(1);

            #endregion
        }