コード例 #1
0
        //创建
        private void CreatePowerCircuit()
        {
            List <ElementId> selectionElementId = new List <ElementId>();
            ElementSet       elements           = new ElementSet();

            foreach (ElementId elementId in selection.GetElementIds())
            {
                elements.Insert(uiDocument.Document.GetElement(elementId));
            }

            foreach (Element e in elements)
            {
                selectionElementId.Add(e.Id);
            }

            try
            {
                // Creation
                ElectricalSystem es = ElectricalSystem.Create(uiDocument.Document, selectionElementId, ElectricalSystemType.PowerCircuit);

                // Select the newly created power system
                selection.GetElementIds().Clear();
                selection.GetElementIds().Add(es.Id);
            }
            catch (Exception)
            {
                ShowErrorMessage("FailedToCreateCircuit");
            }
        }
コード例 #2
0
        public void SelectCircuit(int index)
        {
            // Locate ElectricalSystemItem by index
            ElectricalSystemItem esi = m_electricalSystemItems[index] as ElectricalSystemItem;
            ElementId            ei  = esi.Id;

            // Locate expected electrical system
            m_selectedElectricalSystem = uiDocument.Document.GetElement(ei) as ElectricalSystem;
            // Select the electrical system
            SelectCurrentCircuit();
        }
コード例 #3
0
        private bool IsElementBelongsToCircuit(MEPModel mepModel, ElectricalSystem selectedElectricalSystem)
        {
            ElectricalSystemSet ess = mepModel.ElectricalSystems;

            if (null == ess || !ess.Contains(selectedElectricalSystem))
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        static private bool IsElementBelongsToCircuit(MEPModel mepModel,
                                                      ElectricalSystem selectedElectricalSystem)
        {
            ISet <ElectricalSystem> ess = mepModel.GetElectricalSystems();

            if (null == ess || !ess.Contains(selectedElectricalSystem))
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: danllarom/Revit_SetPathMode
 private void AllDevices_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < checkedListBox1.Items.Count; i++)
     {
         if (checkedListBox1.GetItemChecked(i) == true)
         {
             ElectricalSystem electricalcircuit = elem1[i] as ElectricalSystem;
             electricalcircuit.CircuitPathMode = ElectricalCircuitPathMode.AllDevices;
         }
     }
     this.Close();
 }
コード例 #6
0
        /// <summary>
        /// Get selected index from circuit selecting form and locate expected circuit
        /// </summary>
        /// <param name="index">Index of selected item in circuit selecting form</param>
        public void SelectCircuit(int index)
        {
            // Locate ElectricalSystemItem by index
            ElectricalSystemItem esi = m_electricalSystemItems[index] as ElectricalSystemItem;

            Autodesk.Revit.DB.ElementId ei = esi.Id;

            // Locate expected electrical system
            m_selectedElectricalSystem = m_revitDoc.Document.get_Element(ei) as ElectricalSystem;
            // Select the electrical system
            SelectCurrentCircuit();
        }
コード例 #7
0
 public Circuit(Boolean select, string panelName, string upperLevelPanel, string lowerLevelPanel, string circuitNumber, string circuitName, string upperLevelElem, string lowerLevelElem, string serviceType, ElectricalSystem elementcircuit)
 {
     //TODO: add service type
     Select          = select;
     PanelName       = panelName;
     UpperLevelPanel = upperLevelPanel;
     LowerLevelPanel = lowerLevelPanel;
     CircuitNumber   = circuitNumber;
     CircuitName     = circuitName;
     UpperLevelElem  = upperLevelElem;
     LowerLevelElem  = lowerLevelElem;
     ElementCircuit  = elementcircuit;
     ServiceType     = serviceType;
 }
コード例 #8
0
 public SystemInfoElec(ElectricalSystem system)
 {
     Name            = system.Name;
     ElecFixturesDic =
         new Dictionary <RoomInfoElec, List <FixtureE> >();
     ///Try to get the base panel.
     ///If can't find,prompt the user.
     try
     {
         BaseEquipment = new FixtureE(system.BaseEquipment);
     }
     catch
     {
         throw new Exception("The panel of "
                             + system.Name + " is not set.");
     }
     Wires = new List <Curve>();
 }
コード例 #9
0
    static void PopulateChildren( 
      MapParentToChildren mapParentToChildren, 
      Element parent )
    {
      Connector c2 = null;
      ElementId id = parent.Id;
      FamilyInstance fi = parent as FamilyInstance;
      ElectricalSystem eq = parent as ElectricalSystem;
      Debug.Assert( null != fi || null != eq, "expected element to be family instance or electrical system" );
      ConnectorSet connectors = (null == eq)
        ? fi.MEPModel.ConnectorManager.Connectors
        : eq.ConnectorManager.Connectors;
      foreach( Connector c in connectors )
      {
        Debug.Assert( c.Owner.Id.Equals( id ), "expected connector owner to be this element" );
        //if( c.IsConnected ) // only valid for PhysicalConn
        //MEPSystem mepSystem = c.MEPSystem; // null for electrical connector
        //if( null == mepSystem ) // || !mepSystem.Id.IntegerValue.Equals( m_system.Id.IntegerValue )
        //{
        //  continue;
        //}
        //c2 = GetConnectedConnector( c );

        ConnectorSet refs = c.AllRefs;
        Debug.Assert( 1 == refs.Size, "expected one single connected connector" );
        foreach( Connector tmp in refs )
        {
          c2 = tmp;
        }
        if( null != c2 )
        {
          Element e = c2.Owner;
          Debug.Assert( null != e, "expected valid connector owner" );
          Debug.Assert( e is FamilyInstance || e is ElectricalSystem, "expected electrical connector owner to be family instance or electrical equipment" );
          mapParentToChildren.Add( id, e );
        }
      }
    }
コード例 #10
0
ファイル: Utilits.cs プロジェクト: veabim/veabim
 //Метод для немедленного обновления (сразу при назначении коннектора)
 public static void UpdateConnectorsAll(MapConnectorsToCircuits dic, IList <Reference> lis)
 {
     foreach (Reference idConn in lis)
     {
         //создание точек локаций коннекторов
         double        dos = 100000000;
         double        dis = 0;
         double        d;
         XYZ           p             = new XYZ(-25, 20, 0);
         List <string> sort          = new List <string>();
         string        idCircuitsStr = "";
         //List<string> idCircuits = new List<string>();
         foreach (ElementId idCirc in dic[idConn.ElementId])
         {
             ElectricalSystem circ = _doc.GetElement(idCirc) as ElectricalSystem;
             //Проверка. Если элемента с этим ID не существует
             if (circ == null)
             {
                 continue;
             }
             var    pointsCirc = circ.GetCircuitPath();
             string s          = circ.Name;
             sort.Add(s);
             string idCircStr = idCirc.ToString() + "?";
             idCircuitsStr += idCircStr;
         }
         if (sort == null)
         {
             continue;
         }
         sort.Sort();
         string  namesCircuits = string.Join(" ", sort.ToArray());
         Element connector     = _doc.GetElement(idConn);
         connector.LookupParameter("Комментарии").Set(namesCircuits);
         connector.LookupParameter("ID_Circuits").Set(idCircuitsStr);
     }
 }
コード例 #11
0
        private void Stream( ArrayList data, ElectricalSystem elecSys )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( ElectricalSystem ) ) );

              data.Add( new Snoop.Data.Double( "Apparent current", elecSys.ApparentCurrent ) );
              data.Add( new Snoop.Data.Double( "Apparent current phase A", elecSys.ApparentCurrentPhaseA ) );
              data.Add( new Snoop.Data.Double( "Apparent current phase B", elecSys.ApparentCurrentPhaseB ) );
              data.Add( new Snoop.Data.Double( "Apparent current phase C", elecSys.ApparentCurrentPhaseC ) );
              data.Add( new Snoop.Data.Double( "Apparent load", elecSys.ApparentLoad ) );
              data.Add( new Snoop.Data.Double( "Apparent load phase A", elecSys.ApparentLoadPhaseA ) );
              data.Add( new Snoop.Data.Double( "Apparent load phase B", elecSys.ApparentLoadPhaseB ) );
              data.Add( new Snoop.Data.Double( "Apparent load phase C", elecSys.ApparentLoadPhaseC ) );
              data.Add( new Snoop.Data.Bool( "Balanced load", elecSys.BalancedLoad ) );
              data.Add( new Snoop.Data.String( "Circuit number", elecSys.CircuitNumber ) );
              data.Add( new Snoop.Data.Int( "Ground conductors number", elecSys.GroundConductorsNumber ) );
              data.Add( new Snoop.Data.Int( "Hot conductors number", elecSys.HotConductorsNumber ) );
              data.Add( new Snoop.Data.Int( "Neutral conductors number", elecSys.NeutralConductorsNumber ) );
              data.Add( new Snoop.Data.Double( "Length", elecSys.Length ) );
              data.Add( new Snoop.Data.Object( "Load classifications", elecSys.LoadClassifications ) );
              data.Add( new Snoop.Data.String( "Load name", elecSys.LoadName ) );
              data.Add( new Snoop.Data.String( "Panel name", elecSys.PanelName ) );
              data.Add( new Snoop.Data.Int( "Poles number", elecSys.PolesNumber ) );
              data.Add( new Snoop.Data.Int( "Runs number", elecSys.RunsNumber ) );
              data.Add( new Snoop.Data.Double( "Power factor", elecSys.PowerFactor ) );
              data.Add( new Snoop.Data.String( "Power factor state", elecSys.PowerFactorState.ToString() ) );
              data.Add( new Snoop.Data.Double( "Rating", elecSys.Rating ) );
              data.Add( new Snoop.Data.String( "System type", elecSys.SystemType.ToString() ) );
              data.Add( new Snoop.Data.Double( "True current", elecSys.TrueCurrent ) );
              data.Add( new Snoop.Data.Double( "True current phase A", elecSys.TrueCurrentPhaseA ) );
              data.Add( new Snoop.Data.Double( "True current phase B", elecSys.TrueCurrentPhaseB ) );
              data.Add( new Snoop.Data.Double( "True current phase C", elecSys.TrueCurrentPhaseC ) );
              data.Add( new Snoop.Data.Double( "True load", elecSys.TrueLoad ) );
              data.Add( new Snoop.Data.Double( "True load phase A", elecSys.TrueLoadPhaseA ) );
              data.Add( new Snoop.Data.Double( "True load phase B", elecSys.TrueLoadPhaseB ) );
              data.Add( new Snoop.Data.Double( "True load phase C", elecSys.TrueLoadPhaseC ) );
              data.Add( new Snoop.Data.Double( "Voltage", elecSys.Voltage ) );
              data.Add( new Snoop.Data.Double( "Voltage drop", elecSys.VoltageDrop ) );
              data.Add( new Snoop.Data.String( "Wire size string", elecSys.WireSizeString ) );
              data.Add( new Snoop.Data.Object( "Wire type", elecSys.WireType ) );
        }
コード例 #12
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            #region The basic from Revit datebase.
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.
            Application app = uiapp.Application;
            Document    doc = uidoc.Document;
            #endregion

            List <Room> roomSelected = new List <Room>();
            ///Step1-Confirm the range of calculation.
            ///
            ///Ask the user for range of rooms to calculate.
            ///This is in case multiple houses or group of
            ///houses are in the same rvt files while their
            ///electircal system are seperate.
            ///
            ///The result will be in roomSelected as a list.
            #region Code block of step-1
            ///Prepare the dialog to show later.
            TaskDialog       td = new TaskDialog("RoomSelection");
            TaskDialogResult tdR;
            string           roomNames;
            ///Start selection.If retry button is hit,
            ///do the loop again.
            do
            {
                ///Cleare the result if retry is hit.
                roomSelected.Clear();
                roomNames = "";

                ///1-ask user to choose all rooms or not.
                td.CommonButtons = TaskDialogCommonButtons.Yes
                                   | TaskDialogCommonButtons.No;
                td.MainInstruction = "Do you want to calculate " +
                                     "electrical route for all rooms?\n" +
                                     "If not,press no and select the rooms to " +
                                     "calculate in the model afterward.\n" +
                                     "是否为模型中所有房间计算电路路由?\n" +
                                     "如果不是,选择no并随后在模型中选择需要计算的房间";
                tdR = td.Show();

                ///2-Filter out the rooms selected.
                try
                {///If yes, than select all rooms in the project.
                    if (tdR == TaskDialogResult.Yes)
                    {
                        FilteredElementCollector colR =
                            new FilteredElementCollector(doc)
                            .WhereElementIsNotElementType()
                            .OfCategory(BuiltInCategory.OST_Rooms);
                        foreach (Element e in colR)
                        {
                            roomSelected.Add(e as Room);
                            roomNames += e.Name + "\n";
                        }
                    }
                    ///If no, prompt the user to select.
                    ///Using the SelFilterRoom to restrain
                    ///the type of selection to room.
                    else if (tdR == TaskDialogResult.No)
                    {
                        IList <Element> elems = uidoc.Selection.
                                                PickElementsByRectangle
                                                    (new SelFilterRoom(),
                                                    "Choose the room to calculate route.");
                        foreach (Element e in elems)
                        {
                            roomSelected.Add(e as Room);
                            roomNames += e.Name + "\n";
                        }
                    }
                    ///If window is closed,stop the command.
                    else
                    {
                        return(Result.Failed);
                    }
                }
                catch (Exception e)
                {
                    TaskDialog.Show("Error", "Something went wrong." +
                                    "Detail infomation:\n" +
                                    "命令出错,详细信息:\n" + e.Message);
                    return(Result.Failed);
                }

                ///3-Confirm selection with user.
                td.CommonButtons = TaskDialogCommonButtons.Yes
                                   | TaskDialogCommonButtons.Retry
                                   | TaskDialogCommonButtons.Cancel;
                td.MainInstruction = "Rooms selected 选中房间:\n" +
                                     roomNames + "continue?是否继续?";
                td.DefaultButton = TaskDialogResult.Cancel;
                tdR = td.Show();
                ///Choose result:
                ///Yes-Confirm the selection,break the loop.
                ///Cancel-Stop the command.
                ///Retry-Restart the selection process.
                if (tdR == TaskDialogResult.Yes)
                {
                    break;
                }
                if (tdR == TaskDialogResult.Cancel)
                {
                    return(Result.Failed);
                }
            } while (tdR == TaskDialogResult.Retry);
            #endregion

            List <RoomInfoElec> roomInfoList
                = new List <RoomInfoElec>();
            List <SystemInfoElec> systemInfoList
                = new List <SystemInfoElec>();
            ///Step2-Initialize the roominfos and systeminfos.
            ///
            ///RoomInfoElec is a custom built type to pre calculate
            ///and then store the geometry and node infomation
            ///of each room and contain function relative to
            ///electrical route calculation.
            ///
            ///SystemInfoElec is a cusstom built type to store
            ///the node and route infomation of an electrical circuit.
            ///
            ///This part initialize those info based on rooms selected.
            ///
            ///The result is stored in the above two list.
            #region Code block of step-2

            ///1-Ask the user for structural levels.
            ///
            ///This infomation is not able to acquire directly from
            ///the Room type.
            ///The program assume all room share same structural
            ///floor and ceiling level.
            ///
            double structCeilingH = 0;
            double structFloorH   = 0;
            ///Using a form to display all the reference levels
            ///for user to choose from.
            using (CmdAutoRouteEform input = new CmdAutoRouteEform())
            {
                ///Filter out all the levels.
                FilteredElementCollector levels =
                    new FilteredElementCollector(doc)
                    .WhereElementIsNotElementType()
                    .OfCategory(BuiltInCategory.OST_Levels);
                ///Acquire level names and height.
                string[] levelNames =
                    levels.Select(l => l.Name).ToArray();
                double[] levelH =
                    levels.Select(l => l as Level)
                    .Select(l => l.ProjectElevation)
                    .ToArray();
                ///Display the levels on the form.
                input.InputLevels(levelNames);
                DialogResult dr = input.ShowDialog();
                ///Result OK-Log the height choosen.
                ///Result Cancel or other-Cancel the command.
                if (dr == DialogResult.OK)
                {
                    structCeilingH = levelH
                                     [input.listCeilingLevel.SelectedIndex];
                    structFloorH = levelH
                                   [input.listFloorLevel.SelectedIndex];
                }
                else
                {
                    return(Result.Cancelled);
                }
            }

            ///2-Create roomInfo object for each room selected.
            foreach (Room r in roomSelected)
            {///The constructor of RoomInfoElec will do the job automaticly.
                roomInfoList.Add(new RoomInfoElec
                                     (r, structCeilingH, structFloorH));
            }

            ///3-Create systemInfo object for eacy electrical circuit.
            ///  Add the fixtures info to roomInfo and systemInfo object.
            try
            {
                ///Filter out all the electrical circuits.
                FilteredElementCollector col =
                    new FilteredElementCollector(doc)
                    .WhereElementIsNotElementType()
                    .OfCategory(BuiltInCategory.OST_ElectricalCircuit);
                ///Create systemInfo object for each circuit.
                foreach (Element elecCir in col)
                {
                    ///Transfer the result to electricalsystem type.
                    ElectricalSystem elecSys
                        = elecCir as ElectricalSystem;
                    ///The constructor of SystemInfoElec will do the
                    ///basic automaticly.
                    SystemInfoElec systemInfo
                        = new SystemInfoElec(elecSys);
                    ///Add each normal fixtures in this system.
                    foreach (Element f in elecSys.Elements)
                    {
                        ///If the fixture don't have room which it
                        ///belong to,abandon it.
                        FamilyInstance fixture = f as FamilyInstance;
                        if (fixture.Room == null)
                        {
                            continue;
                        }
                        ///Find the roomInfo object for the room.
                        var roomInfoE = roomInfoList
                                        .Where(r => r.Room.Id == fixture.Room.Id)
                                        .First();
                        if (roomInfoE == null)
                        {
                            continue;
                        }
                        ///Create the fixture object.
                        ///FixtureE is a custom built type that will
                        ///be used in the calculation later on.
                        FixtureE fE = new FixtureE(fixture);
                        ///The accessnode of a fixture is where it will
                        ///access the circuit.Refer to the object for details.
                        fE.SetAccessNode(roomInfoE);
                        ///Add this fixture to both roominfo and systeminfo.
                        roomInfoE.AddFixture(fE, systemInfo);
                        systemInfo.AddFixture(fE, roomInfoE);
                    }
                    ///Add electrical panel as another fixture.
                    Room         room  = systemInfo.BaseEquipment.Room;
                    RoomInfoElec rInfo = roomInfoList
                                         .Where(r => r.Room.Name == room.Name)
                                         .FirstOrDefault()
                                         as RoomInfoElec;
                    systemInfo.AddFixture
                        (systemInfo.BaseEquipment, rInfo);
                    rInfo.AddFixture
                        (systemInfo.BaseEquipment, systemInfo);

                    ///Finish adding fixture and enlist the object
                    systemInfoList.Add(systemInfo);
                }
            }
            catch (Exception e)
            {
                TaskDialog.Show("Error", e.Message);
                return(Result.Failed);
            }
            #endregion

            ///Step3-Calculate the place to cross the wall.
            ///
            /// In order to avoid some unnecessary calculation,
            /// this command calculate the room topology first
            /// and find the place for electrical wires to cross
            /// the wall.
            ///
            /// The crossing point at eachside of a wall will be
            /// added as a special fixtures to the system and room.
            ///
            /// And they will be connected in the systemGraph.
            /// While other fixtures will only be allowed to connect
            /// with the fixtures in the same room in the following
            /// systemGraph.
            ///
            #region Code block of step3
            ///1-Initialize the vertices and the roomgraph.
            List <Vertex> vRooms = new List <Vertex>();
            foreach (RoomInfoElec r in roomInfoList)
            {
                vRooms.Add(new Vertex(r));
            }
            Graph roomGraph = new Graph(vRooms);
            int   vNum      = roomGraph.VertexCount;

            ///2-Calculate the fixtures centroid of each room.
            foreach (RoomInfoElec r in roomInfoList)
            {
                r.CalculateFixCentroid();
            }
            ///Find the room where the panel are located.
            ///And change the centroid of this room to panel location.
            Room   panelRoom   = systemInfoList[0].BaseEquipment.Room;
            Vertex panelVertex = roomGraph.Vertices
                                 .Where(v => v.Object.ToString() == panelRoom.Name)
                                 .ToArray().First() as Vertex;
            RoomInfoElec panelRoomInfo = panelVertex.Object
                                         as RoomInfoElec;
            panelRoomInfo.AssignFixCentroid
                (systemInfoList[0].BaseEquipment.OriginNode);
            ///3-Initialize the edges for roomGraph.
            for (int i = 0; i < vNum; i++)
            {
                for (int j = i + 1; j < vNum; j++)
                {
                    ///Find the vertex and object first.
                    Vertex       v1 = roomGraph.Vertices.ElementAt(i);
                    Vertex       v2 = roomGraph.Vertices.ElementAt(j);
                    RoomInfoElec r1 = v1.Object as RoomInfoElec;
                    RoomInfoElec r2 = v2.Object as RoomInfoElec;
                    ///If this two room is adjacent and have a
                    ///path to cross the wall,create the edge in
                    ///the roomGraph.
                    if (r1.AdjacentPathTo
                            (r2, r2.StructCeilingLevel
                            , out PathExWall path, out double roughL))
                    {
                        Edge e = new Edge(v1, v2, path, roughL);
                        roomGraph.AddEdge(e);
                    }
                }
            }
            ///Using the DijkstraTree algorithm to calculate the
            ///crosswall path tree in which each room can have a
            ///shortest path to the panel.
            Edge[] mstRoomDij = roomGraph.DijkstraTree(panelVertex);
            #endregion

            ///Step4-Create systemGraph and add cross wall point.
            ///
            ///The systemGraph contains all the fixtures of one system
            ///as vertex in the graph.And the routes between fixtures
            ///are stored as edges in the graph.
            ///
            ///Later will use mininum span tree to decided which route
            ///to use and which to abandon.
            List <Graph>      sysGraphList   = new List <Graph>();
            List <PathExWall> crossWallPaths = new List <PathExWall>();
            #region Code block of step4
            ///1-Correct all the direction of crosspoint.
            ///Make them start from panelroom to the other room.
            foreach (Vertex v in vRooms)
            {
                ///Skip the root room.
                if (v == v.Parent)
                {
                    continue;
                }
                ///Find the path from this room to its parent.
                Edge       e = roomGraph.FindEdge(v, v.Parent);
                PathExWall p = e.Object as PathExWall;
                ///If direction is wront,reverse it.
                if (e.Begin != v.Parent)
                {
                    e.Reverse();
                    p.Reverse();
                }
                ///Acquire the path for further use.
                crossWallPaths.Add(p);
            }

            ///2-Add vertex for each system the graph.
            foreach (SystemInfoElec sys in systemInfoList)
            {
                ///sysGraph is the graph of fixtures for this system.
                Graph sysGraph = new Graph();
                ///sysRooms contains all the rooms in which there are
                ///fixtures of this system.
                List <RoomInfoElec> sysRooms
                    = sys.ElecFixturesDic.Keys.ToList();
                ///sysRoomsV are all the roomVertex that system
                ///will need to path through.
                ///It may not be all rooms but may also be
                ///more than sysRooms.(Non adjacent rooms need to
                ///use other room to connect)
                List <Vertex> sysRoomsV = roomGraph.UpTrace
                                              (vRooms.Where(v => sysRooms
                                                            .Contains(v.Object as RoomInfoElec)));

                ///First add all the normal fixture as vertex.
                foreach (FixtureE f in sys.ElecFixtures)
                {
                    sysGraph.AddVertex(new Vertex(f));
                }
                ///Second add the crossing paths.
                ///(Both vertex and edge)
                foreach (Vertex v in sysRoomsV)
                {
                    ///Skip the root room.
                    if (v.Parent == v)
                    {
                        continue;
                    }
                    ///Find the rooms.
                    ///toR is the one further to the root(panel).
                    RoomInfoElec toR = v.Object
                                       as RoomInfoElec;
                    RoomInfoElec fromR = v.Parent.Object
                                         as RoomInfoElec;
                    ///Find the edge that connect two vertices.
                    Edge       e = roomGraph.FindEdge(v, v.Parent);
                    PathExWall p = e.Object as PathExWall;
                    ///Add the crossing point in eachroom
                    ///as a fixture to roomInfo object.
                    fromR.AddFixture(p.CurrentBegin, sys);
                    toR.AddFixture(p.CurrentEnd, sys);
                    ///Add them also to the systemInfo.
                    sys.AddFixture(p.CurrentBegin, fromR);
                    sys.AddFixture(p.CurrentEnd, toR);
                    ///Add crossing point as vertex to systemGraph.
                    ///And the path connect them as edge.
                    Vertex v1   = new Vertex(p.CurrentBegin);
                    Vertex v2   = new Vertex(p.CurrentEnd);
                    Edge   enew = new Edge
                                      (v1, v2, p.CloneCurrent(), p.Cost);
                    sysGraph.AddVertex(v1);
                    sysGraph.AddVertex(v2);
                    sysGraph.AddEdge(enew);
                }
                ///Generate next crossing path for next system.
                ///Including the paths which this system didnt use.
                foreach (PathExWall p in crossWallPaths)
                {
                    p.MoveNext();
                }

                ///Add sysGraph to list.
                sysGraphList.Add(sysGraph);
            }
            #endregion

            ///Step5-Calculate the final route.
            ///
            ///Use the mininum span tree to calculate the
            ///final route combination.
            #region Code block of step5.
            ///1-Add all the route inside rooms to the graph.
            int sysIndex = 0;
            foreach (Graph sysGraph in sysGraphList)
            {
                foreach (RoomInfoElec r in roomInfoList)
                {
                    ///Get all the fixtures inside this room.
                    List <Vertex> fixs = sysGraph.Vertices
                                         .Where(v => (v.Object as FixtureE)
                                                .Room.Name == r.Room.Name)
                                         .ToList();
                    int fixsNum = fixs.Count();
                    ///Calculate path for each fixture pair.
                    ///And add it to the graph
                    for (int i = 0; i < fixsNum; i++)
                    {
                        for (int j = i + 1; j < fixsNum; j++)
                        {
                            PathE p = r.FindPath
                                          (fixs[i].Object as FixtureE,
                                          fixs[j].Object as FixtureE);
                            sysGraph.AddEdge
                                (new Edge(fixs[i], fixs[j],
                                          p, p.Cost));
                        }
                    }
                }
                ///2-Using KruskalMinTree to generate the sysPaths
                Edge[] sysPaths = sysGraph.KruskalMinTree();

                ///3-Store the path to systemInfo.
                ///Find the corresponding systemInfo object.
                SystemInfoElec eSys = systemInfoList[sysIndex];
                ///Select the lines in the paths and add them
                ///as wires to the systemInfo object.
                eSys.AddWires(sysPaths
                              .Select(e => e.Object as PathE)
                              .Select(p => p.Lines)
                              .SelectMany(c => c)
                              .ToList());
                ///Increment the index
                sysIndex++;
            }
            #endregion

            ///Step6-Create the line
            ///
            ///Open a transaction and create the line as modelcurve.
            ///Each system will have a seperate linestyle with
            ///different color to seperate.
            ///And all the modelcurves in one system will be grouped.
            #region Code block of step6
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Create Wires");
                ///1-Prepare new linestyle color.
                Categories cats    = doc.Settings.Categories;
                Category   lineCat = cats
                                     .get_Item(BuiltInCategory.OST_Lines);
                List <Color> colors = new List <Color>
                {
                    new Color(255, 0, 0),
                    new Color(0, 255, 0),
                    new Color(0, 0, 255),
                    new Color(150, 150, 0),
                    new Color(0, 150, 150),
                    new Color(150, 0, 150)
                };
                short counter = 1;
                foreach (SystemInfoElec eSys in systemInfoList)
                {
                    Category newLineStyleCat = null;
                    Element  newLineStyle    = null;
                    ///2-Create the new linestyle for this system.
                    ///If having naming conflict,result will be null.
                    ///Then redo the loop.
                    do
                    {
                        try
                        {
                            newLineStyleCat = cats.NewSubcategory
                                                  (lineCat, "ElectricalLine-" + counter);
                            doc.Regenerate();
                            newLineStyleCat.SetLineWeight
                                (7, GraphicsStyleType.Projection);
                            newLineStyleCat.LineColor = colors[counter - 1];
                            newLineStyle =
                                doc.GetElement(newLineStyleCat.Id);
                        }
                        catch
                        {
                            counter++;
                        }
                    } while (newLineStyleCat == null);

                    ///3-Create the model line and set linestyle.
                    XYZ x0 = new XYZ();
                    List <ElementId> modelC = new List <ElementId>();
                    ///If no wires is generated,skip.
                    if (eSys.Wires.Count == 0)
                    {
                        continue;
                    }
                    foreach (Curve c in eSys.Wires)
                    {
                        XYZ         x1 = c.GetEndPoint(0);
                        XYZ         x2 = c.GetEndPoint(1);
                        SketchPlane sp = SketchPlane.Create
                                             (doc, Plane.CreateByThreePoints(x1, x2, x0));
                        ModelCurve mc = doc.Create.NewModelCurve(c, sp);
                        mc.LineStyle = newLineStyle;
                        modelC.Add(mc.Id);
                    }
                    ///4-Group all the curves.
                    doc.Create.NewGroup(modelC);
                    counter++;
                }
                tx.Commit();
            }
            #endregion

            return(Result.Succeeded);
        }
コード例 #13
0
ファイル: CircuitOperationData.cs プロジェクト: AMEE/revit
        private static bool IsElementBelongsToCircuit(MEPModel mepModel,
            ElectricalSystem selectedElectricalSystem)
        {
            ElectricalSystemSet ess = mepModel.ElectricalSystems;
            if (null == ess || !ess.Contains(selectedElectricalSystem))
            {
                return false;
            }

            return true;
        }
コード例 #14
0
    public Result Execute(
      ExternalCommandData commandData,
      ref String message,
      ElementSet elements )
    {
      UIApplication app = commandData.Application;
      Document doc = app.ActiveUIDocument.Document;
      //
      // retrieve electrical equipment:
      //
      List<Element> equipment = Util.GetElectricalEquipment( doc );
      int n = equipment.Count;
      Debug.WriteLine( string.Format( 
        "Retrieved {0} electrical equipment instance{1}{2}",
        n, Util.PluralSuffix( n ), Util.DotOrColon( n ) ) );
      //
      // determine which equipment has parents;
      // the remaining ones are root nodes:
      //
      Dictionary<ElementId, ElementId> equipmentParents 
        = new Dictionary<ElementId, ElementId>();

      foreach( FamilyInstance fi in equipment )
      {
        foreach( Connector c in fi.MEPModel.ConnectorManager.Connectors )
        {
          ConnectorSet refs = c.AllRefs;
          foreach( Connector c2 in refs )
          {
            Debug.Assert( null != c2.Owner, 
              "expected valid connector owner" );

            Debug.Assert( c2.Owner is ElectricalSystem, 
              "expected panel element to be electrical system" );

            ElectricalSystem eq = c2.Owner as ElectricalSystem;
            foreach( Element e2 in eq.Elements )
            {
              Debug.Assert( e2 is FamilyInstance, 
                "expected electrical system element to be family instance" );

              if( !e2.Id.Equals( fi.Id ) )
              {
                if( equipment.Exists( 
                  delegate( Element e ) 
                  { return e.Id.Equals( e2.Id ); } ) )
                {
                  equipmentParents[e2.Id] = eq.Id;
                }
              }
            }
          }
        }
      }

      //n = equipment.RemoveAll( delegate( Element e ) { return subequipment.Exists( delegate( Element e2 ) { return e2.Id.Equals( e.Id ); } ); } );

      //
      // populate parent to children mapping:
      //
      ElementId nullId = ElementId.InvalidElementId;
      MapParentToChildren mapParentToChildren = new MapParentToChildren();

      foreach( FamilyInstance fi in equipment )
      {
        //ElementId parentId = equipmentParents.ContainsKey( fi.Id ) ? equipmentParents[fi.Id] : nullId;
        //mapParentToChildren.Add( parentId, fi );

        //
        // handle root nodes;
        // non-roots are handled below a children:
        //
        if( !equipmentParents.ContainsKey( fi.Id ) )
        {
          mapParentToChildren.Add( nullId, fi );
        }
        
        foreach( Connector c in fi.MEPModel.ConnectorManager.Connectors )
        {
          ConnectorSet refs = c.AllRefs;
          foreach( Connector c2 in refs )
          {
            Debug.Assert( null != c2.Owner, 
              "expected valid connector owner" );

            Debug.Assert( c2.Owner is ElectricalSystem, 
              "expected panel element to be electrical system" );

            ElectricalSystem eq = c2.Owner as ElectricalSystem;
            mapParentToChildren.Add( fi.Id, eq );
            foreach( Element e2 in eq.Elements )
            {
              Debug.Assert( e2 is FamilyInstance, 
                "expected electrical system element to be family instance" );

              if( !e2.Id.Equals( fi.Id ) )
              {
                mapParentToChildren.Add( eq.Id, e2 );
              }
            }
          }
        }
      }

      #region Test code
#if TEST_CODE
      //
      // retrieve electrical systems:
      //
      List<Element> systems = new List<Element>();
      doc.get_Elements( typeof( ElectricalSystem ), systems );
      n = systems.Count;
      Debug.WriteLine( string.Format( "Retrieved {0} electrical system{1}{2}",
        n, Util.PluralSuffix( n ), Util.DotOrColon( n ) ) );
コード例 #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="es"></param>
 public ElectricalSystemItem(ElectricalSystem es)
 {
     m_name = es.Name;
     m_id   = es.Id;
 }
コード例 #16
0
ファイル: CircuitOperationData.cs プロジェクト: AMEE/revit
        /// <summary>
        /// Get common circuits contain all selected elements
        /// </summary>
        private void CollectCircuitInfo()
        {
            //bool isElectricalSystem = false;

            bool bInitilzedElectricalSystemSet = false;

            //
            // Get common circuits of selected elements
            //
            ElectricalSystem tempElectricalSystem = null;
            foreach (Element element in m_selection.Elements)
            {
                FamilyInstance fi = element as FamilyInstance;
                MEPModel mepModel;
                ElectricalSystemSet ess;

                if (fi != null && (mepModel = fi.MEPModel) != null)
                {
                    //
                    // If the element is a family instance and its MEP model is not null,
                    // retrieve its circuits
                    // Then compare the circuits with circuits of other selected elements
                    // to get the common ones
                    //

                    // Get all electrical systems
                    ess = mepModel.ElectricalSystems;
                    if (null == ess)
                    {
                        m_hasCircuit = false;
                        m_hasPanel = false;
                        return;
                    }

                    // Remove systems which are not power circuits
                    foreach (ElectricalSystem es in ess)
                    {
                        if (es.SystemType != ElectricalSystemType.PowerCircuit)
                        {
                            ess.Erase(es);
                        }
                    }

                    if (ess.IsEmpty)
                    {
                        m_hasCircuit = false;
                        m_hasPanel = false;
                        return;
                    }

                    // If m_electricalSystemSet is not set before, set it
                    // otherwise compare the circuits with circuits of other selected elements
                    // to get the common ones
                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet = ess;
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }
                    else
                    {
                        foreach (ElectricalSystem es in m_electricalSystemSet)
                        {
                            if (!ess.Contains(es))
                            {
                                m_electricalSystemSet.Erase(es);
                            }
                        }

                        if (m_electricalSystemSet.IsEmpty)
                        {
                            m_hasCircuit = false;
                            m_hasPanel = false;
                            return;
                        }
                    }
                }
                else if ((tempElectricalSystem = element as ElectricalSystem) != null)
                {
                    //
                    // If the element is an electrical system, verify if it is a power circuit
                    // If not, compare with circuits of other selected elements
                    // to get the common ones
                    //
                    //verify if it is a power circuit
                    if (tempElectricalSystem.SystemType != ElectricalSystemType.PowerCircuit)
                    {
                        m_hasCircuit = false;
                        m_hasPanel = false;
                        return;
                    }

                    // If m_electricalSystemSet is not set before, set it
                    // otherwise compare with circuits of other selected elements
                    // to get the common ones
                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet.Insert(tempElectricalSystem);
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }

                    if (!m_electricalSystemSet.Contains(tempElectricalSystem))
                    {
                        m_hasCircuit = false;
                        m_hasPanel = false;
                        return;
                    }

                    m_electricalSystemSet.Clear();
                    m_electricalSystemSet.Insert(tempElectricalSystem);
                }
                else
                {
                    m_hasCircuit = false;
                    m_hasPanel = false;
                    return;
                }
            }

            // Verify if there is any common power circuit
            if (!m_electricalSystemSet.IsEmpty)
            {
                m_hasCircuit = true;
                if (m_electricalSystemSet.Size == 1)
                {
                    foreach (ElectricalSystem es in m_electricalSystemSet)
                    {
                        m_selectedElectricalSystem = es;
                        break;
                    }
                }

                foreach (ElectricalSystem es in m_electricalSystemSet)
                {
                    if (!String.IsNullOrEmpty(es.PanelName))
                    {
                        m_hasPanel = true;
                        break;
                    }
                }
            }
        }
コード例 #17
0
        public static async Task SeedDatabase(ApplicationDbContext context,
                                              UserManager <ApplicationUser> userManager)
        {
            if (!context.Users.Any())
            {
                var personsWithPasswords = new List <PersonWithPassword>
                {
                    new PersonWithPassword
                    (
                        new ApplicationUser
                    {
                        UserName = "******",
                        Email    = "*****@*****.**",
                        Address  = "45 Long Beach Blvd, Miami"
                    },
                        new Person
                    {
                        FirstName = "John",
                        LastName  = "Doe"
                    },
                        "NewPassword123$"
                    ),
                    new PersonWithPassword
                    (
                        new ApplicationUser
                    {
                        UserName = "******",
                        Email    = "*****@*****.**",
                        Address  = "15 Square Ave, London"
                    },
                        new Person
                    {
                        FirstName = "Michael",
                        LastName  = "Jordan"
                    },
                        "FreshPassword123$"
                    )
                };

                foreach (var personWithPassword in personsWithPasswords)
                {
                    var applicationUser = personWithPassword.AppUser;

                    IdentityResult result =
                        await userManager.CreateAsync(applicationUser, personWithPassword.Password);

                    if (result.Succeeded)
                    {
                        var person = personWithPassword.Person;

                        person.ApplicationUserId = applicationUser.Id;

                        context.Persons.Add(person);
                    }
                }

                context.SaveChanges();
            }

            if (!context.Manufacturers.Any())
            {
                var manufacturers = new List <Manufacturer>
                {
                    new Manufacturer()
                    {
                        Name = "Philips"
                    },
                    new Manufacturer()
                    {
                        Name = "Siemens"
                    },
                    new Manufacturer()
                    {
                        Name = "Samsung"
                    },
                    new Manufacturer()
                    {
                        Name = "Asus"
                    },
                    new Manufacturer()
                    {
                        Name = "IBM"
                    },
                    new Manufacturer()
                    {
                        Name = "Whirlpool"
                    },
                    new Manufacturer()
                    {
                        Name = "LG"
                    },
                    new Manufacturer()
                    {
                        Name = "Solar City"
                    },
                    new Manufacturer()
                    {
                        Name = "Tesla"
                    },
                    new Manufacturer()
                    {
                        Name = "Teledyne Energy Systems"
                    },
                };

                context.Manufacturers.AddRange(manufacturers);

                context.SaveChanges();
            }

            if (!context.ElectricalDeviceTypes.Any())
            {
                var electricalDeviceTypes = new List <ElectricalDeviceType>
                {
                    new ElectricalDeviceType()
                    {
                        TypeName = "LED Light"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Washing Machine"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Air conditioner"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Computer"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Refridgerator"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Electronic Microscope"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Water Pump"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Water Heater"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Energy Generator"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Solar panel"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Radioisotope Thermoelectric Generator"
                    },
                    new ElectricalDeviceType()
                    {
                        TypeName = "Battery Pack"
                    }
                };

                context.ElectricalDeviceTypes.AddRange(electricalDeviceTypes);

                context.SaveChanges();
            }

            if (!context.ElectricalDeviceModels.Any())
            {
                var philips   = context.Manufacturers.FirstOrDefault(m => m.Name == "Philips");
                var siemens   = context.Manufacturers.FirstOrDefault(m => m.Name == "Siemens");
                var samsung   = context.Manufacturers.FirstOrDefault(m => m.Name == "Samsung");
                var whirlpool = context.Manufacturers.FirstOrDefault(m => m.Name == "Whirlpool");
                var lg        = context.Manufacturers.FirstOrDefault(m => m.Name == "LG");
                var solarCity = context.Manufacturers.FirstOrDefault(m => m.Name == "Solar City");
                var tesla     = context.Manufacturers.FirstOrDefault(m => m.Name == "Tesla");
                var teledyne  = context.Manufacturers.FirstOrDefault(m => m.Name == "Teledyne Energy Systems");

                var electricalDeviceModels = new List <ElectricalDeviceModel>
                {
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Philips CH5 Air Conditioner",
                        MeasuringUnit          = "Degrees (C)",
                        MinValue               = 18.0d,
                        MaxValue               = 30.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 5.6d,
                        PowerAtLowestUnitLevel = 30.0d,
                        ModelIdentifier        = "KL54-PLPS",
                        Manufacturer           = philips,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Air conditioner")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Siemens LED Light FC83H",
                        MeasuringUnit          = "Lumens",
                        MinValue               = 30.0d,
                        MaxValue               = 90.0d,
                        Step                   = 5.0d,
                        PowerPerStep           = 0.6,
                        PowerAtLowestUnitLevel = 4.0d,
                        ModelIdentifier        = "9DE4-SMNS",
                        Manufacturer           = siemens,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "LED Light")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Samsung Fridge DL23M",
                        MeasuringUnit          = "Degrees (C)",
                        MinValue               = -15.0d,
                        MaxValue               = 6.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 7.0d,
                        PowerAtLowestUnitLevel = 35.0d,
                        ModelIdentifier        = "CV7J-SMSG",
                        Manufacturer           = samsung,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Refridgerator")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Whirlpool Water Pump DH4F",
                        MeasuringUnit          = "LitresPerMin",
                        MinValue               = 0.5d,
                        MaxValue               = 20.0d,
                        Step                   = 0.5d,
                        PowerPerStep           = 7.0d,
                        PowerAtLowestUnitLevel = 45.0d,
                        ModelIdentifier        = "JE3C-WHPL",
                        Manufacturer           = whirlpool,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Water Pump")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "LG Water Heater KD25",
                        MeasuringUnit          = "Degrees (C)",
                        MinValue               = 20.0d,
                        MaxValue               = 80.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 0.5d,
                        PowerAtLowestUnitLevel = 22.0d,
                        ModelIdentifier        = "90QW-LGLG",
                        Manufacturer           = lg,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Water Heater")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Solar City MX45 Panel",
                        MeasuringUnit          = "Watts",
                        MinValue               = 0.0d,
                        MaxValue               = 80.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 0.5d,
                        PowerAtLowestUnitLevel = 0.0d,
                        ModelIdentifier        = "34FD-SLCT",
                        Manufacturer           = solarCity,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Solar panel")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Teledyne HJ24 MMRTG",
                        MeasuringUnit          = "Degrees (C)",
                        MinValue               = 0.0d,
                        MaxValue               = 120.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 0.5d,
                        PowerAtLowestUnitLevel = 0.0d,
                        ModelIdentifier        = "3F4F-TLDN",
                        Manufacturer           = teledyne,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Radioisotope Thermoelectric Generator")
                    },
                    new ElectricalDeviceModel()
                    {
                        ModelName              = "Tesla 24CF Power Pack",
                        Capacity               = 50000,
                        MeasuringUnit          = "Degrees (C)",
                        MinValue               = 0.0d,
                        MaxValue               = 250.0d,
                        Step                   = 1.0d,
                        PowerPerStep           = 0.5d,
                        PowerAtLowestUnitLevel = 0.0d,
                        ModelIdentifier        = "90QW-TSLA",
                        Manufacturer           = tesla,
                        ElectricalDeviceType   =
                            context.ElectricalDeviceTypes.FirstOrDefault(edt => edt.TypeName == "Battery Pack")
                    }
                };

                context.ElectricalDeviceModels.AddRange(electricalDeviceModels);

                context.SaveChanges();

                if (!context.EnergyGenerators.Any())
                {
                    var energyGenerators = new List <EnergyGenerator>();

                    var teledyneRadioisotopeGeneratorModel =
                        context.ElectricalDeviceModels.FirstOrDefault(edm => edm.ModelName == "Teledyne HJ24 MMRTG");

                    var radioisotopeGenerator = new EnergyGenerator()
                    {
                        SerialNumber          = "VC23-DF42-OK49-3F4F-TLDN",
                        ElectricalDeviceModel = teledyneRadioisotopeGeneratorModel
                    };

                    energyGenerators.Add(radioisotopeGenerator);

                    var radioisotopeGeneratorSecond = new EnergyGenerator()
                    {
                        SerialNumber          = "LQ21-CA30-SQ1P-3F4F-TLDN",
                        ElectricalDeviceModel = teledyneRadioisotopeGeneratorModel
                    };

                    energyGenerators.Add(radioisotopeGeneratorSecond);

                    string[] setOfStrings = new string[]
                    {
                        "JFC9", "PO92", "CXO9", "AZ39", "PO9W", "QE31", "SXL4", "BA6G"
                    };

                    var solarCityPanelModel =
                        context.ElectricalDeviceModels.FirstOrDefault(edm => edm.ModelName == "Solar City MX45 Panel");

                    int setLength = setOfStrings.Length;

                    Random randomGenerator = new Random();

                    for (int i = 0; i < 20; i++)
                    {
                        StringBuilder sb = new StringBuilder();

                        for (int j = 0; j < 3; j++)
                        {
                            string randomString = setOfStrings[randomGenerator.Next(0, setLength)];
                            sb.AppendFormat("{0}-", randomString);
                        }

                        var energyGenerator = new EnergyGenerator()
                        {
                            SerialNumber          = sb.ToString(),
                            ElectricalDeviceModel = solarCityPanelModel
                        };

                        energyGenerators.Add(energyGenerator);
                    }

                    context.EnergyGenerators.AddRange(energyGenerators);

                    context.SaveChanges();
                }

                if (!context.BatteryPacks.Any())
                {
                    var battery = new BatteryPack()
                    {
                        SerialNumber          = "D3AP-W24C-QW2X-90QW-TSLA",
                        ElectricalDeviceModel =
                            context.ElectricalDeviceModels.FirstOrDefault(edm => edm.ModelName == "Tesla 24CF Power Pack")
                    };

                    context.BatteryPacks.Add(battery);

                    context.SaveChanges();
                }
            }

            if (!context.BaseUnits.Any())
            {
                context.BaseUnits.AddRange
                (
                    new BaseUnit {
                    Name = "Living Space"
                },
                    new BaseUnit {
                    Name = "Green House"
                }
                );
                context.SaveChanges();
            }

            if (!context.ElectricalSystemTypes.Any())
            {
                var electricalSystemTypes = new List <ElectricalSystemType>
                {
                    new ElectricalSystemType {
                        Name = "Air-Conditining System"
                    },
                    new ElectricalSystemType {
                        Name = "Lighting System"
                    },
                    new ElectricalSystemType {
                        Name = "Fridge System"
                    },
                    new ElectricalSystemType {
                        Name = "Water Pumping System"
                    },
                    new ElectricalSystemType {
                        Name = "Water Heating System"
                    }
                };

                context.ElectricalSystemTypes.AddRange(electricalSystemTypes);

                context.SaveChanges();
            }


            if (!context.ElectricalSystems.Any())
            {
                var livingSpaceBaseUnit = context.BaseUnits.FirstOrDefault(u => u.Name == "Living Space");

                var greenHouseBaseUnit = context.BaseUnits.FirstOrDefault(bu => bu.Name == "Green House");

                var airConditioningSystemType =
                    context.ElectricalSystemTypes.FirstOrDefault(est => est.Name == "Air-Conditining System");

                var ligthingSystemType =
                    context.ElectricalSystemTypes.FirstOrDefault(est => est.Name == "Lighting System");

                var fridgeSystemType =
                    context.ElectricalSystemTypes.FirstOrDefault(est => est.Name == "Fridge System");

                var waterPumpingSystemType =
                    context.ElectricalSystemTypes.FirstOrDefault(est => est.Name == "Water Pumping System");

                var waterHeatingSystemType =
                    context.ElectricalSystemTypes.FirstOrDefault(est => est.Name == "Water Heating System");

                var airConditioningLivingSpace = new ElectricalSystem()
                {
                    Name                 = "Air Conditioning System (Living Space)",
                    BaseUnit             = livingSpaceBaseUnit,
                    ElectricalSystemType = airConditioningSystemType
                };

                var airConditioningGreenHouse = new ElectricalSystem()
                {
                    Name                 = "Air Conditioning System (Green House)",
                    BaseUnit             = greenHouseBaseUnit,
                    ElectricalSystemType = airConditioningSystemType
                };

                var lightsSystemLivingSpace = new ElectricalSystem()
                {
                    Name                 = "LED Lights (Living Space)",
                    BaseUnit             = livingSpaceBaseUnit,
                    ElectricalSystemType = ligthingSystemType
                };

                var lightsSystemGreenHouse = new ElectricalSystem()
                {
                    Name                 = "LED Lights (Green House)",
                    BaseUnit             = greenHouseBaseUnit,
                    ElectricalSystemType = ligthingSystemType
                };

                var fridgeSystemLivingSpace = new ElectricalSystem()
                {
                    Name                 = "Fridge System (Living Space)",
                    BaseUnit             = livingSpaceBaseUnit,
                    ElectricalSystemType = fridgeSystemType
                };

                var fridgeSystemGreenHouse = new ElectricalSystem()
                {
                    Name                 = "Fridge System (Green House)",
                    BaseUnit             = greenHouseBaseUnit,
                    ElectricalSystemType = fridgeSystemType
                };

                var waterPumpSystemLivingSpace = new ElectricalSystem()
                {
                    Name                 = "Water Pumping System (Living Space)",
                    BaseUnit             = livingSpaceBaseUnit,
                    ElectricalSystemType = waterPumpingSystemType
                };

                var waterPumpSystemGreenHouse = new ElectricalSystem()
                {
                    Name                 = "Water Pumping System (Green House)",
                    BaseUnit             = greenHouseBaseUnit,
                    ElectricalSystemType = waterPumpingSystemType
                };

                var waterHeatingSystemLivingSpace = new ElectricalSystem()
                {
                    Name                 = "Water Heating System (Living Space)",
                    BaseUnit             = livingSpaceBaseUnit,
                    ElectricalSystemType = waterHeatingSystemType
                };

                var waterHeatingSystemGreenHouse = new ElectricalSystem()
                {
                    Name                 = "Water Heating System (Green House)",
                    BaseUnit             = greenHouseBaseUnit,
                    ElectricalSystemType = waterHeatingSystemType
                };

                var electricalSystems = new List <ElectricalSystem>
                {
                    airConditioningLivingSpace,
                    airConditioningGreenHouse,
                    lightsSystemLivingSpace,
                    lightsSystemGreenHouse,
                    fridgeSystemLivingSpace,
                    fridgeSystemGreenHouse,
                    waterPumpSystemLivingSpace,
                    waterPumpSystemGreenHouse,
                    waterHeatingSystemLivingSpace,
                    waterHeatingSystemGreenHouse
                };

                context.ElectricalSystems.AddRange(electricalSystems);

                context.SaveChanges();
            }

            if (!context.ElectricalDevices.Any())
            {
                var ledLightsLivingSpaceSystem =
                    context.ElectricalSystems.FirstOrDefault(es => es.Name == "LED Lights (Living Space)");

                var ledLightsGreenHouseSystem =
                    context.ElectricalSystems.FirstOrDefault(es => es.Name == "LED Lights (Living Space)");

                var philipsCH5AirConditioner =
                    context.ElectricalDeviceModels.FirstOrDefault(es => es.ModelName == "Philips CH5 Air Conditioner");

                var siemensLEDLightFC83H = context.ElectricalDeviceModels.FirstOrDefault(es => es.ModelName == "Siemens LED Light FC83H");

                var samsungFridgeDL23M = context.ElectricalDeviceModels.FirstOrDefault(es => es.ModelName == "Samsung Fridge DL23M");

                var whirlpoolWaterPumpDH4F = context.ElectricalDeviceModels.FirstOrDefault(es => es.ModelName == "Whirlpool Water Pump DH4F");

                var lgWaterHeaterKD25 = context.ElectricalDeviceModels.FirstOrDefault(es => es.ModelName == "LG Water Heater KD25");

                var electricalDevices = new List <ElectricalDevice>
                {
                    new ElectricalDevice()
                    {
                        SerialNumber          = "4HDE-BHRU-98CH-KL54-PLPS",
                        ElectricalDeviceModel = philipsCH5AirConditioner,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Air Conditioning System (Living Space)"),
                        MeasuringUnitCurrentLevel = 21.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "BNMV-RT65-AS9K-KL54-PLPS",
                        ElectricalDeviceModel = philipsCH5AirConditioner,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Air Conditioning System (Green House)"),
                        MeasuringUnitCurrentLevel = 21.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber              = "8XCD-GHJD-82WD-9DE4-SMNS",
                        ElectricalDeviceModel     = siemensLEDLightFC83H,
                        ElectricalSystem          = ledLightsLivingSpaceSystem,
                        MeasuringUnitCurrentLevel = 30.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber              = "KERL-PKS1-DF9A-9DE4-SMNS",
                        ElectricalDeviceModel     = siemensLEDLightFC83H,
                        ElectricalSystem          = ledLightsLivingSpaceSystem,
                        MeasuringUnitCurrentLevel = 30.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber              = "BCRE-MGHW-KSD3-9DE4-SMNS",
                        ElectricalDeviceModel     = siemensLEDLightFC83H,
                        ElectricalSystem          = ledLightsGreenHouseSystem,
                        MeasuringUnitCurrentLevel = 45.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber              = "PA8G-LM2A-DF9A-9DE4-SMNS",
                        ElectricalDeviceModel     = siemensLEDLightFC83H,
                        ElectricalSystem          = ledLightsGreenHouseSystem,
                        MeasuringUnitCurrentLevel = 45.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "PKLC-WERP-CVBH-CV7J-SMSG",
                        ElectricalDeviceModel = samsungFridgeDL23M,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Fridge System (Living Space)"),
                        MeasuringUnitCurrentLevel = 4.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "MVC8-KDKD-CD9K-CV7J-SMSG",
                        ElectricalDeviceModel = samsungFridgeDL23M,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Fridge System (Green House)"),
                        MeasuringUnitCurrentLevel = 4.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "FH3S-DE4C-CF5D-JE3C-WHPL",
                        ElectricalDeviceModel = whirlpoolWaterPumpDH4F,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Water Pumping System (Living Space)"),
                        MeasuringUnitCurrentLevel = 14.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "MVC8-KDKD-CD9K-JE3C-WHPL",
                        ElectricalDeviceModel = whirlpoolWaterPumpDH4F,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Water Pumping System (Green House)"),
                        MeasuringUnitCurrentLevel = 0.5d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "8XCD-GHJD-82WD-90QW-LGLG",
                        ElectricalDeviceModel = lgWaterHeaterKD25,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Water Heating System (Living Space)"),
                        MeasuringUnitCurrentLevel = 70.0d
                    },
                    new ElectricalDevice()
                    {
                        SerialNumber          = "KL2W-AS2E-WE3C-90QW-LGLG",
                        ElectricalDeviceModel = lgWaterHeaterKD25,
                        ElectricalSystem      =
                            context.ElectricalSystems.FirstOrDefault(es => es.Name == "Water Heating System (Green House)"),
                        MeasuringUnitCurrentLevel = 20.0d
                    }
                };

                context.ElectricalDevices.AddRange(electricalDevices);

                context.SaveChanges();
            }
        }
コード例 #18
0
ファイル: ElectricalSystemItem.cs プロジェクト: AMEE/revit
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="es"></param>
 public ElectricalSystemItem(ElectricalSystem es)
 {
     m_name = es.Name;
     m_id = es.Id;
 }
コード例 #19
0
        private void CollectCircuitInfo()
        {
            bool bInitilzedElectricalSystemSet = false;

            ElectricalSystem tempElectricalSystem = null;

            foreach (ElementId elementId in selection.GetElementIds())
            {
                Element        element = uiDocument.Document.GetElement(elementId);
                FamilyInstance fi      = element as FamilyInstance;

                MEPModel            mepModel;
                ElectricalSystemSet ess;

                if (fi != null && (mepModel = fi.MEPModel) != null)
                {
                    // Get all electrical systems
                    ess = mepModel.ElectricalSystems;
                    if (null == ess)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    // Remove systems which are not power circuits
                    foreach (ElectricalSystem es in ess)
                    {
                        if (es.SystemType != ElectricalSystemType.PowerCircuit)
                        {
                            ess.Erase(es);
                        }
                    }

                    if (ess.IsEmpty)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet         = ess;
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }
                    else
                    {
                        foreach (ElectricalSystem es in m_electricalSystemSet)
                        {
                            if (!ess.Contains(es))
                            {
                                m_electricalSystemSet.Erase(es);
                            }
                        }

                        if (m_electricalSystemSet.IsEmpty)
                        {
                            m_hasCircuit = false;
                            m_hasPanel   = false;
                            return;
                        }
                    }
                }

                else if ((tempElectricalSystem = element as ElectricalSystem) != null)
                {
                    if (tempElectricalSystem.SystemType != ElectricalSystemType.PowerCircuit)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet.Insert(tempElectricalSystem);
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }

                    if (!m_electricalSystemSet.Contains(tempElectricalSystem))
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    m_electricalSystemSet.Clear();
                    m_electricalSystemSet.Insert(tempElectricalSystem);
                }

                else
                {
                    m_hasCircuit = false;
                    m_hasPanel   = false;
                    return;
                }
            }

            if (!m_electricalSystemSet.IsEmpty)
            {
                m_hasCircuit = true;
                if (m_electricalSystemSet.Size == 1)
                {
                    foreach (ElectricalSystem es in m_electricalSystemSet)
                    {
                        m_selectedElectricalSystem = es;
                        break;
                    }
                }

                foreach (ElectricalSystem es in m_electricalSystemSet)
                {
                    if (!String.IsNullOrEmpty(es.PanelName))
                    {
                        m_hasPanel = true;
                        break;
                    }
                }
            }
        }
コード例 #20
0
ファイル: CircuitOperationData.cs プロジェクト: AMEE/revit
        /// <summary>
        /// Get selected index from circuit selecting form and locate expected circuit
        /// </summary>
        /// <param name="index">Index of selected item in circuit selecting form</param>
        public void SelectCircuit(int index)
        {
            // Locate ElectricalSystemItem by index
            ElectricalSystemItem esi = m_electricalSystemItems[index] as ElectricalSystemItem;
            Autodesk.Revit.DB.ElementId ei = esi.Id;

            // Locate expected electrical system
            m_selectedElectricalSystem = m_revitDoc.Document.get_Element(ei) as ElectricalSystem;
            // Select the electrical system
            SelectCurrentCircuit();
        }
 public void Add(ElectricalSystem electricalSystem)
 {
     this.electricalSystemRepository.Add(electricalSystem);
     this.electricalSystemRepository.SaveChanges();
 }
コード例 #22
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            #region Clear the existing system.
            TaskDialogResult r = TaskDialog.Show("Note",
                                                 "This will clear the existing " +
                                                 "electrical system.Continue?",
                                                 TaskDialogCommonButtons.Yes |
                                                 TaskDialogCommonButtons.No);
            if (r == TaskDialogResult.No)
            {
                return(Result.Failed);
            }
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Clear existing system.");
                FilteredElementCollector col =
                    new FilteredElementCollector(doc)
                    .WhereElementIsNotElementType()
                    .OfCategory(BuiltInCategory.OST_ElectricalCircuit);
                Stack <ElementId> sysId = new Stack <ElementId>();
                foreach (Element e in col)
                {
                    sysId.Push(e.Id);
                }
                while (sysId.Count > 0)
                {
                    doc.Delete(sysId.Pop());
                }
                tx.Commit();
            }
            #endregion

            #region Check the default settings.
            const string elecSettingName =
                "DefaultElectricalSettingExcuted";
            GlobalParameter SettingP = doc.GetElement(
                GlobalParametersManager.FindByName
                    (doc, elecSettingName)) as GlobalParameter;
            if (SettingP == null)
            {
                //Set the voltage and distribution to default
                using (Transaction tx = new Transaction(doc))
                {
                    tx.Start("Autoset electrical setting");
                    ElectricalSetting ElecSet = ElectricalSetting
                                                .GetElectricalSettings(doc);
                    VoltageType VtypeHome = ElecSet
                                            .AddVoltageType("Home", 220, 200, 250);
                    ElecSet.AddDistributionSysType
                        ("Lighting", ElectricalPhase.SinglePhase,
                        ElectricalPhaseConfiguration.Undefined,
                        2, null, VtypeHome);
                    ElecSet.AddDistributionSysType
                        ("Outlet", ElectricalPhase.SinglePhase,
                        ElectricalPhaseConfiguration.Undefined,
                        2, null, VtypeHome);
                    GlobalParameter.Create
                        (doc, elecSettingName, ParameterType.Number);
                    tx.Commit();
                }
            }
            #endregion

            #region Retrieve elements from database
            List <ElementId> LightIds  = new List <ElementId>();
            List <ElementId> OutletIds = new List <ElementId>();
            List <ElementId> HVACIds   = new List <ElementId>();

            FilteredElementCollector colLight
                = new FilteredElementCollector(doc)
                  .OfCategory(BuiltInCategory.OST_LightingFixtures)
                  .WhereElementIsNotElementType();
            FilteredElementCollector colOutlet
                = new FilteredElementCollector(doc)
                  .OfCategory(BuiltInCategory.OST_ElectricalFixtures)
                  .WhereElementIsNotElementType();
            FilteredElementCollector colHVAC
                = new FilteredElementCollector(doc)
                  .OfCategory(BuiltInCategory.OST_MechanicalEquipment)
                  .WhereElementIsNotElementType();

            foreach (Element e in colLight)
            {
                LightIds.Add(e.Id);
            }
            foreach (Element e in colOutlet)
            {
                OutletIds.Add(e.Id);
            }
            foreach (Element e in colHVAC)
            {
                if (HasElectricalConnector(e))
                {
                    HVACIds.Add(e.Id);
                }
            }

            #endregion Retrieve elements from databa

            //Locate the electrical main box.
            FamilyInstance ElecBox = null;
            do
            {
                try
                {
                    Selection sel = uidoc.Selection;
                    TaskDialog.Show("Choose", "Please " +
                                    "select one electrical box after " +
                                    "closing the dialog.\n" +
                                    "请在关闭窗口后选择一个配电箱。");
                    ElementId ElecBoxId = sel.PickObject
                                              (ObjectType.Element, new SelFilterElecEquip()
                                              , "Select the main box").ElementId;
                    ElecBox = doc.GetElement(ElecBoxId)
                              as FamilyInstance;
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("Error", "Something went wrong.\n"
                                    + ex.Message);
                    return(Result.Failed);
                }
            } while ((ElecBox.MEPModel as ElectricalEquipment)
                     .DistributionSystem == null);



            // Create the electrical system
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Create ElectricalSystem");
                ElectricalSystem LightingCircuit =
                    ElectricalSystem.Create(doc, LightIds,
                                            ElectricalSystemType.PowerCircuit);
                LightingCircuit.Name = "LightingCircuit";
                LightingCircuit.SelectPanel(ElecBox);
                ElectricalSystem OutlietCircuit =
                    ElectricalSystem.Create(doc, OutletIds,
                                            ElectricalSystemType.PowerCircuit);
                OutlietCircuit.Name = "OutletCircuit";
                OutlietCircuit.SelectPanel(ElecBox);
                ElectricalSystem HVACCircuit =
                    ElectricalSystem.Create(doc, HVACIds,
                                            ElectricalSystemType.PowerCircuit);
                HVACCircuit.Name = "HVACCircuit";
                HVACCircuit.SelectPanel(ElecBox);
                tx.Commit();
            }
            TaskDialog.Show("Result",
                            "Default systems have been created.\n" +
                            "Please do not change system name.\n" +
                            "已创建默认系统,请勿修改系统名,将影响后续计算\n" +
                            "可手动调整系统内末端.");

            return(Result.Succeeded);
        }
 public void HardDelete(ElectricalSystem electricalSystem)
 {
     this.electricalSystemRepository.HardDelete(electricalSystem);
     this.electricalSystemRepository.SaveChanges();
 }
 public void Update(ElectricalSystem electricalSystem)
 {
     this.electricalSystemRepository.Update(electricalSystem);
     this.electricalSystemRepository.SaveChanges();
 }
コード例 #25
0
ファイル: Utilits.cs プロジェクト: veabim/veabim
        /// <summary>
        /// Получения отсортированного списка цепей щита
        /// </summary>
        public static IEnumerable <ElectricalSystem> GetSortedCircuits(FamilyInstance board, out ElectricalSystem circBoard)
        {
            circBoard = null;
            ElectricalSystemSet      fullCircuits = board.MEPModel.ElectricalSystems; //Получение всех цепей щита
            IList <ElectricalSystem> sortCircuit  = new List <ElectricalSystem>();
            string boardName = board.Name;

            foreach (ElectricalSystem circ in fullCircuits)
            {
                string s = circ.PanelName;
                if (s == boardName)
                {
                    sortCircuit.Add(circ);
                }
                else
                {
                    circBoard = circ;
                }
            }
            return(sortCircuit.OrderBy(x => x.StartSlot));
        }
コード例 #26
0
        /// <summary>
        /// Get common circuits contain all selected elements
        /// </summary>
        private void CollectCircuitInfo()
        {
            //bool isElectricalSystem = false;

            bool bInitilzedElectricalSystemSet = false;

            //
            // Get common circuits of selected elements
            //
            ElectricalSystem tempElectricalSystem = null;

            foreach (Element element in m_selection.Elements)
            {
                FamilyInstance      fi = element as FamilyInstance;
                MEPModel            mepModel;
                ElectricalSystemSet ess;

                if (fi != null && (mepModel = fi.MEPModel) != null)
                {
                    //
                    // If the element is a family instance and its MEP model is not null,
                    // retrieve its circuits
                    // Then compare the circuits with circuits of other selected elements
                    // to get the common ones
                    //

                    // Get all electrical systems
                    ess = mepModel.ElectricalSystems;
                    if (null == ess)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    // Remove systems which are not power circuits
                    foreach (ElectricalSystem es in ess)
                    {
                        if (es.SystemType != ElectricalSystemType.PowerCircuit)
                        {
                            ess.Erase(es);
                        }
                    }

                    if (ess.IsEmpty)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    // If m_electricalSystemSet is not set before, set it
                    // otherwise compare the circuits with circuits of other selected elements
                    // to get the common ones
                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet         = ess;
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }
                    else
                    {
                        foreach (ElectricalSystem es in m_electricalSystemSet)
                        {
                            if (!ess.Contains(es))
                            {
                                m_electricalSystemSet.Erase(es);
                            }
                        }

                        if (m_electricalSystemSet.IsEmpty)
                        {
                            m_hasCircuit = false;
                            m_hasPanel   = false;
                            return;
                        }
                    }
                }
                else if ((tempElectricalSystem = element as ElectricalSystem) != null)
                {
                    //
                    // If the element is an electrical system, verify if it is a power circuit
                    // If not, compare with circuits of other selected elements
                    // to get the common ones
                    //
                    //verify if it is a power circuit
                    if (tempElectricalSystem.SystemType != ElectricalSystemType.PowerCircuit)
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    // If m_electricalSystemSet is not set before, set it
                    // otherwise compare with circuits of other selected elements
                    // to get the common ones
                    if (!bInitilzedElectricalSystemSet)
                    {
                        m_electricalSystemSet.Insert(tempElectricalSystem);
                        bInitilzedElectricalSystemSet = true;
                        continue;
                    }

                    if (!m_electricalSystemSet.Contains(tempElectricalSystem))
                    {
                        m_hasCircuit = false;
                        m_hasPanel   = false;
                        return;
                    }

                    m_electricalSystemSet.Clear();
                    m_electricalSystemSet.Insert(tempElectricalSystem);
                }
                else
                {
                    m_hasCircuit = false;
                    m_hasPanel   = false;
                    return;
                }
            }

            // Verify if there is any common power circuit
            if (!m_electricalSystemSet.IsEmpty)
            {
                m_hasCircuit = true;
                if (m_electricalSystemSet.Size == 1)
                {
                    foreach (ElectricalSystem es in m_electricalSystemSet)
                    {
                        m_selectedElectricalSystem = es;
                        break;
                    }
                }

                foreach (ElectricalSystem es in m_electricalSystemSet)
                {
                    if (!String.IsNullOrEmpty(es.PanelName))
                    {
                        m_hasPanel = true;
                        break;
                    }
                }
            }
        }