Пример #1
0
        void getBasEquipments(Document doc)
        {
            FilteredElementCollector systems
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(MEPSystem));
            IOrderedEnumerable <MEPSystem> systemsSorted = from MEPSystem s in systems orderby Int32.Parse(s.Name) ascending select s;

            int i = 0;

            if (systemsSorted.Count() == 0)
            {
                throw new Exception("Не обнаружены системы в Revit-модели.");
            }
            foreach (MEPSystem system in systemsSorted)
            {
                string sysId = system.BaseEquipment.Id.ToString();

                if (!this.ARKBLocks.Any(element => element.id == sysId))
                {
                    ARKModule m = new ARKModule(sysId, i, system.BaseEquipment);
                    m.mark = GetMark(system.BaseEquipment);
                    ARKBLocks.Add(m);
                }
                findAndAddSystem(system);
            }
        }
Пример #2
0
        void DrawStatementCabeles(XYZ start, Document doc, ViewDrafting view, ARKModule ark)
        {
            FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "STATEMENTCABELS").FirstOrDefault();
            Transaction  trans      = new Transaction(doc);

            trans.Start("Помещен на рисунок");
            FamilyInstance next = doc.Create.NewFamilyInstance(new XYZ(start.X, start.Y - 0.2, 0), famToPlace, view);
            double         len  = 0;

            foreach (MEPSystem mep in ark.systems)
            {
                len += getNormalCount(Double.Parse(mep.LookupParameter("Длина").AsValueString()) / 1000);
            }
            foreach (MEPSystem mep in ark.alertSystems)
            {
                len += getNormalCount(Double.Parse(mep.LookupParameter("Длина").AsValueString()) / 1000);
            }
            next.LookupParameter("Внешняя длина").Set(len);
            SettingSections s = settings.getByIndex(settings.loadSettingByARK(ark.mark));

            next.LookupParameter("Внешняя марка").Set(s.GetStrForDrawing());
            string[] st = File.ReadAllLines("C://ProgramData//Autodesk//Revit//Addins//2019//Linear//intocabin.set");
            next.LookupParameter("Внутришкафная марка").Set(st[0] + "-" + st[2]);
            next.LookupParameter("Внутришкафная длина").Set(Double.Parse(st[1]));
            trans.Commit();
        }
Пример #3
0
        XYZ DrawRemain(XYZ start, Document doc, ViewDrafting view, int last, ARKModule ark)
        {
            XYZ returnPoint = start;

            if (last - ark.systems.Count > 3)//изменить для разрыва
            {
                Transaction trans = new Transaction(doc);
                trans.Start("Помещен на рисунок");
                FamilySymbol famToPlace  = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "GAP").FirstOrDefault();
                FamilySymbol emptyOutput = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "ARKRIGHEMPTY").FirstOrDefault();

                FamilyInstance              gap          = doc.Create.NewFamilyInstance(start, famToPlace, view);//разрыв
                double                      gapHeight    = gap.Symbol.LookupParameter("Внутренняя высота").AsDouble();
                FilteredElementCollector    collector    = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol));
                List <AnnotationSymbolType> l            = (from e in collector.ToElements() where e is AnnotationSymbolType select e as AnnotationSymbolType).ToList();
                double                      outputHeight = 1;
                foreach (AnnotationSymbolType at in l)
                {
                    if (at.FamilyName == "ARKRIGHEMPTY")
                    {
                        outputHeight = at.LookupParameter("Ширина").AsDouble();
                    }
                }

                start = new XYZ(start.X, start.Y - gapHeight * 10 - outputHeight * 10 + 0.08, 0);
                FamilyInstance next = doc.Create.NewFamilyInstance(start, emptyOutput, view);
                next.LookupParameter("номер шлейфа").Set(last - 4);
                next.LookupParameter("ark").Set(Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)));
                for (int i = last - 3; i <= last; ++i)
                {
                    double height = next.Symbol.LookupParameter("Ширина").AsDouble();
                    start = new XYZ(start.X, start.Y - height * 10, 0);
                    next  = doc.Create.NewFamilyInstance(start, emptyOutput, view);
                    next.LookupParameter("номер шлейфа").Set(i);
                    next.LookupParameter("ark").Set(Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)));
                    returnPoint = start;
                }
                trans.Commit();
            }
            else
            {
                FamilySymbol emptyOutput = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "ARKRIGHEMPTY").FirstOrDefault();
                start = new XYZ(start.X, start.Y - 0.08, 0);
                Transaction trans = new Transaction(doc);
                trans.Start("Помещен на рисунок");
                for (int i = ark.systems.Count + 1; i <= last; i++)
                {
                    FamilyInstance next = doc.Create.NewFamilyInstance(start, emptyOutput, view);
                    next.LookupParameter("номер шлейфа").Set(i);
                    next.LookupParameter("ark").Set(Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)));
                    double height = next.Symbol.LookupParameter("Ширина").AsDouble();
                    start       = new XYZ(start.X, start.Y - height * 10, 0);
                    returnPoint = start;
                }
                trans.Commit();
            }
            return(returnPoint);
        }
Пример #4
0
        void DrawShleifs(XYZ point, Document doc, ViewDrafting view)
        {
            //соответствие арк
            //settings.loadSettings();
            ARKModule      ark = null;
            XYZ            end = null;
            FamilyInstance f   = new FilteredElementCollector(doc, view.Id).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().Where(x => arkmoduleIds.Contains(x.Id)).FirstOrDefault();

            foreach (ARKModule module in ARKBLocks)
            {
                if (module.revitModule.Id == f.Id)
                {
                    ark = module;
                }
            }
            //добавление экземпляров на виды по точке
            double         len   = 0;
            int            index = 0;
            FamilyInstance next  = null;

            foreach (MEPSystem mep in ark.systems)
            {
                FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "ARKRIGHTOUTPUT").FirstOrDefault();
                Transaction  trans      = new Transaction(doc);
                trans.Start("Помещен на рисунок");
                next = doc.Create.NewFamilyInstance(new XYZ(point.X, point.Y - index * len * 10, 0), famToPlace, view);
                trans.Commit();
                trans.Start("добавление параметров");
                next.LookupParameter("ark").Set(Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)));
                next.LookupParameter("номер шлейфа").Set(Double.Parse(mep.Name));
                double rr = mep.LookupParameter("Длина").AsDouble();
                next.LookupParameter("Длина кабеля").Set(getNormalCount(Double.Parse(mep.LookupParameter("Длина").AsValueString()) / 1000));
                SettingSections s = settings.getByIndex(settings.loadSettingByARK(ark.mark));
                next.LookupParameter("Вид кабеля").Set(s.GetStrForDrawing());
                trans.Commit();
                DrawSensors(new XYZ(point.X + next.LookupParameter("Длина").AsDouble() * 10, point.Y - index * len * 10, 0), mep, Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)), view, doc);
                end = new XYZ(point.X + next.LookupParameter("Длина").AsDouble() * 10, point.Y - index * len * 10, 0);



                len = next.LookupParameter("Ширина").AsDouble();
                ++index;
            }
            if (ark.systems.Count <= ark.revitModule.Symbol.LookupParameter("Количество шлейфов справа").AsInteger())
            {
                end = DrawRemain(new XYZ(point.X, point.Y - (index * len * 10) + 0.08, 0), doc, view, ark.revitModule.Symbol.LookupParameter("Количество шлейфов справа").AsInteger(), ark);
            }
            else
            {
                throw new Exception("Ошибка! Количество шлейфов в выбранном семействе меньше, чем в Revit-модели!");
            }
            DrawStatementCabeles(end, doc, view, ark);
            mainTirePoints.Add(new XYZ(point.X, point.Y - index * len * 10, 0));
            mainTirePoints.Add(new XYZ(end.X, end.Y - 0.08, 0));
            geometry.AddLines(doc, view, geometry.ConnectLinesByPoints(mainTirePoints));
            mainTirePoints.Clear();
        }
Пример #5
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                comboBox1.Items.Clear();
                int       selectedind = listBox1.SelectedIndex;
                ARKModule ark         = blocks[selectedind];
                MEPSystem mep         = null;
                foreach (MEPSystem m in ark.systems)
                {
                    if (m.Name.Contains("1"))
                    {
                        mep = m;
                    }
                }
                double len = getL(mep, ark.systems.Count);
                len = getNormalCount(len);
                double I = 0;
                I = getI(mep);
                //label23.Text = len.ToString();
                // label24.Text = I.ToString();

                foreach (MEPSystem m in ark.systems)
                {
                    string name = m.Name + "-й шлейф";
                    double s    = getS(getI(mep), getL(m, ark.systems.Count));
                    comboBox1.Items.Add(name + ": " + s.ToString());
                }
                try
                {
                    int             set_index = settings.loadSettingByARK(listBox1.SelectedItem.ToString());
                    SettingSections set       = settings.getByIndex(set_index);
                    string[]        sections  = set.section.Split('x');
                    textBox4.Text = set.mark;
                    textBox6.Text = sections[0];
                    textBox7.Text = sections[1];
                    textBox3.Text = sections[2];
                    textBox8.Text = set.op;
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #6
0
        void DrawLines(Document doc)
        {
            foreach (ElementId vd in drawingviews)
            {
                string[]     s     = File.ReadAllLines("C://ProgramData//Autodesk//Revit//Addins//2019//Linear//intocabin.set");
                ARKModule    block = null;
                ViewDrafting view  = new FilteredElementCollector(doc).OfClass(typeof(ViewDrafting)).Cast <ViewDrafting>().Where(x => x.Id == vd).FirstOrDefault();

                FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "INTOCABIN").FirstOrDefault();


                FamilyInstance ark = new FilteredElementCollector(doc, vd).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().Where(x => arkmoduleIds.Contains(x.Id)).FirstOrDefault();
                foreach (ARKModule a in ARKBLocks)
                {
                    if (a.revitModule.Id == ark.Id)
                    {
                        block = a;
                    }
                }
                List <XYZ> points = new List <XYZ>();
                points.Add(new XYZ(ark.Symbol.LookupParameter("Ширина").AsDouble() * 10 / 2, ark.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2, 0));
                points.Add(new XYZ(ark.Symbol.LookupParameter("Ширина").AsDouble() * 10 / 2, ark.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2 + 0.5, 0));
                mainPoints.Add(points.Last()); ///добавление главной точки
                Transaction t = new Transaction(doc);
                t.Start("На вид");
                FamilyInstance ann = doc.Create.NewFamilyInstance(new XYZ(ark.Symbol.LookupParameter("Ширина").AsDouble() * 10 / 2, ark.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2 + 0.5, 0),
                                                                  famToPlace, view);
                ann.LookupParameter("Длина").Set(Int32.Parse(s[1]));
                ann.Symbol.LookupParameter("Сечение").Set(s[2]);
                ann.LookupParameter("Тип").Set(s[0]);
                t.Commit();
                points.Add(new XYZ(ark.Symbol.LookupParameter("Ширина").AsDouble() * 10 / 2 + 1, ark.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2 + 0.5, 0));
                geometry.AddLines(doc, view, geometry.ConnectLinesByPoints(points));
                XYZ nextp = DrawShleifsAlert(points[2], doc, view);
                DrawShleifs(nextp, doc, view);
                nextp = drawLeftShleifs(doc, view);
                mainPoints.Add(new XYZ(nextp.X, ark.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2 + 0.5, 0)); //добавление главной точки
                mainPoints.Add(nextp);                                                                               ///добавление главной точки
                if (block.alertSystems.Count > 0)
                {
                    List <Line> lines = geometry.ConnectLinesByPoints(mainPoints);
                    geometry.AddLines(doc, view, lines);
                }
                mainPoints.Clear();
                //DrawShleifs(points[2],doc,view);
            }
        }
Пример #7
0
        XYZ DrawShleifsAlert(XYZ point, Document doc, ViewDrafting view)
        {
            mainTirePoints.Add(new XYZ(point.X, point.Y + 0.08, 0));
            //соответствие арк
            settings.loadSettings();
            XYZ            pointToReturn = point;
            ARKModule      ark           = null;
            FamilyInstance f             = new FilteredElementCollector(doc, view.Id).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().Where(x => arkmoduleIds.Contains(x.Id)).FirstOrDefault();

            foreach (ARKModule module in ARKBLocks)
            {
                if (module.revitModule.Id == f.Id)
                {
                    ark = module;
                }
            }
            //добавление экземпляров на виды по точке
            double         len   = 0;
            int            index = 0;
            FamilyInstance next  = null;

            foreach (MEPSystem mep in ark.alertSystems)
            {
                FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => x.Name == "ARKRIGHTOUTPUTOP").FirstOrDefault();
                Transaction  trans      = new Transaction(doc);
                trans.Start("Помещен на рисунок");
                pointToReturn = new XYZ(point.X, point.Y - index * len * 10 - index * 0.2, 0);
                next          = doc.Create.NewFamilyInstance(pointToReturn, famToPlace, view);
                trans.Commit();
                trans.Start("добавление параметров");
                next.LookupParameter("ark").Set(Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)));
                next.LookupParameter("номер шлейфа").Set(Double.Parse((index + 1).ToString()) /*Double.Parse(mep.LookupParameter("Комментарии").AsString().Remove(0,1))/*+Double.Parse(ark.revitModule.Symbol.LookupParameter("Количество шлейфов справа").AsInteger().ToString())*/);//ввести новый параметр
                double countShleifs = Double.Parse(ark.revitModule.Symbol.LookupParameter("Количество шлейфов справа").AsInteger().ToString());
                next.LookupParameter("Количество шлейфов справа").Set(countShleifs);
                next.LookupParameter("Длина кабеля").Set(getNormalCount(Double.Parse(mep.LookupParameter("Длина").AsValueString()) / 1000));

                SettingSections s = settings.getByIndex(settings.loadSettingByARK(ark.mark));
                next.LookupParameter("type").Set(s.op);
                next.LookupParameter("Вид кабеля").Set(s.GetStrForDrawing());
                trans.Commit();
                DrawSensorsAlert(new XYZ(point.X + next.LookupParameter("Длина").AsDouble() * 10, point.Y - index * len * 10 - index * 0.2, 0), mep, Int32.Parse(ark.mark.Remove(ark.mark.IndexOf("ARK"), 3)), view, doc);
                len = next.LookupParameter("Ширина").AsDouble();
                ++index;
            }
            return(new XYZ(point.X, point.Y - index * len * 10 - index * 0.2, 0));
        }
Пример #8
0
        void getBasEquipments(Document doc)
        {
            FilteredElementCollector systems
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(MEPSystem));
            int i = 0;

            foreach (MEPSystem system in systems)
            {
                string sysId = system.BaseEquipment.Id.ToString();
                if (!this.ARKBLocks.Any(element => element.id == sysId))
                {
                    ARKModule m = new ARKModule(sysId, i, system.BaseEquipment);
                    ARKBLocks.Add(m);
                }

                findAndAddSystem(system);
            }
            setForm = new RevitAPIFramework.Form1(ARKBLocks, SaveEveryARKBlockFamily);
            setForm.Show();
        }
Пример #9
0
        private XYZ drawLeftShleifs(Document doc, ViewDrafting view)
        {
            XYZ            point = null;
            ARKModule      ark   = null;
            FamilyInstance f     = new FilteredElementCollector(doc, view.Id).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().Where(r => arkmoduleIds.Contains(r.Id)).FirstOrDefault();

            foreach (ARKModule module in ARKBLocks)
            {
                if (module.revitModule.Id == f.Id)
                {
                    ark = module;
                }
            }
            double         index  = (Double.Parse(ark.revitModule.Symbol.LookupParameter("Количество шлейфов справа").AsInteger().ToString()) + 1) * 2 - 1;
            int            arkNum = ark.revitModule.LookupParameter("ark-module").AsInteger();
            FamilyInstance next   = null;
            double         length = 0;
            double         x      = -ark.revitModule.Symbol.LookupParameter("Ширина").AsDouble() * 10 / 2;
            double         y      = ark.revitModule.Symbol.LookupParameter("Высота").AsDouble() * 10 / 2 - ark.revitModule.Symbol.LookupParameter("До шлейфа").AsDouble() * 10;

            point = new XYZ(x, y, 1);
            FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(r => r.Name == "SHLEIF").FirstOrDefault();

            foreach (MEPSystem s in ark.alertSystems)
            {
                Transaction t = new Transaction(doc);
                t.Start("Боковые шлейфы");
                next = doc.Create.NewFamilyInstance(point, famToPlace, view);
                next.LookupParameter("num-ark").Set(arkNum);
                next.LookupParameter("num-plus").Set(index);
                point  = new XYZ(point.X, point.Y - next.Symbol.LookupParameter("Высота").AsDouble() * 10, 0);
                length = next.Symbol.LookupParameter("Длина").AsDouble() * 10;
                index += 2;
                t.Commit();
            }
            return(new XYZ(point.X - length, point.Y, 0));
        }
Пример #10
0
 public TableCreator(ARKModule _module, XYZ _start)
 {
     module = _module;
     start  = _start;
     table  = new TableClass();
 }