예제 #1
0
        //Macro Command
        //Retrieves the Circuits in the Project, Current and does some Overcurrent calcs
        public void D_GetElectricalCircuits()
        {
            //Document doc = this.ActiveUIDocument.Document;
            Document doc = this.Document;

            List <Element> circuits = KPHelperClass.GetElectricalCircuits(doc);
            string         str      = "";

            foreach (Element e in circuits)
            {
                double amps           = KPHelperClass.GetParameterValueFromName(e, "Apparent Current");
                string panel          = KPHelperClass.GetStringParameterValueFromName(e, "Panel");
                string number         = KPHelperClass.GetStringParameterValueFromName(e, "Circuit Number");
                double amps125percent = amps * 1.25;

                str += "Circuit: " + panel + "-" + number
                       + " Connected Load ="
                       + amps.ToString("0.00")
                       + " -> " + "Load @ 125%: "
                       + amps125percent.ToString("0.00")
                       + System.Environment.NewLine;

                //TODO: check what rating needs to be
                double ratingProtection = CheckRatingProtection(amps125percent);

                //TODO: set rating value, double amps
            }

            TaskDialog.Show("Circuits", str);
        }
예제 #2
0
        //Macro Command
        //Update Conduit Feeder Parameters that already have Feeder Designators added
        public void F_UpdateAllProjectConduitAndFittingParamsFromExcel()
        {
            Document doc = this.Document;

            List <Element> conduits        = KPHelperClass.GetConduits(doc);
            List <Element> conduitFittings = KPHelperClass.GetConduitFittings(doc);

            List <Element> combinedElements = new List <Element>();

            foreach (Element cf in conduitFittings)
            {
                conduits.Add(cf);
                combinedElements = conduits;
            }

            if (combinedElements != null)
            {
                UpdateParameterValuesForElements(combinedElements, false);
            }
        }
예제 #3
0
        //Helper method
        private void UpdateParameterValuesForElements(List <Element> combinedElements, bool isConduitRun)
        {
            Document doc = this.Document;

            string feederDesignatorParameterName = "";
            Dictionary <string, List <Tuple <string, string> > > dictXlFeederData = new Dictionary <string, List <Tuple <string, string> > >();

            dictXlFeederData = ReadDataFromExcelAndReturn();

            List <Tuple <string, string> > dictItem = dictXlFeederData[FEEDER_PARAMETER_DESIGNATOR_IN_REVIT_AND_EXCEL];

            foreach (Tuple <string, string> valueItem in dictItem)
            {
                feederDesignatorParameterName = valueItem.Item1;
            }


            TaskDialog.Show("data", dictXlFeederData.Count.ToString()
                            + "-Rows of Excel Feeder data read. "
                            + "\n" + "\n" + "Attempting to apply this data to "
                            + combinedElements.Count.ToString()
                            + " Elements");

            Transaction trans = new Transaction(doc);

            trans.Start("Updated Conduit Run Parameters");


            //string str = "";
            int feederDesignatorParameterCount = 0;
            int updatedElements = 0;
            int totalElements   = 0;
            //get feeder designator of selected conduit to be applied to conduit run
            //first element should be the selected element
            string feederDesignatorParameterValue = KPHelperClass.GetStringParameterValueFromName(combinedElements[0], feederDesignatorParameterName);

            foreach (Element e in combinedElements)
            {
                totalElements++;

                //use each elements feeder designator value if its not a conduit run
                if (isConduitRun == false)
                {
                    feederDesignatorParameterValue = KPHelperClass.GetStringParameterValueFromName(e, feederDesignatorParameterName);
                }

                if (feederDesignatorParameterValue != null && dictXlFeederData.ContainsKey(feederDesignatorParameterValue))
                {
                    //set the feeder designator value based on selected conduit
                    Autodesk.Revit.DB.Parameter p1 = KPHelperClass.GetParameterFromName(e, feederDesignatorParameterName);
                    if (p1 != null)
                    {
                        p1.Set(feederDesignatorParameterValue);
                    }

                    var value = dictXlFeederData[feederDesignatorParameterValue];

                    foreach (Tuple <string, string> t in value)
                    {
                        Autodesk.Revit.DB.Parameter p2 = KPHelperClass.GetParameterFromName(e, t.Item1);

                        if (p2 != null)
                        {
                            p2.Set(t.Item2);
                        }
                    }
                    updatedElements++;
                }
                else
                {
                    feederDesignatorParameterCount++;
                }
            }

            trans.Commit();

            TaskDialog.Show("Updated Parameters", "Out of " + totalElements.ToString() + " Elements: "
                            + "\n"
                            + "\n"
                            + feederDesignatorParameterCount.ToString()
                            + ": Element(s) did not have a Feeder Designator or did not match the Feeder Designator in the Excel Data"
                            + "\n"
                            + "\n"
                            + updatedElements.ToString()
                            + ": Element(s) were updated successfully");
        }