Пример #1
0
        public static ViewDrafting CreateViewDrafting(Document doc, string name)
        {
            ViewFamilyType vd = new FilteredElementCollector(doc)
                                .OfClass(typeof(ViewFamilyType))
                                .Cast <ViewFamilyType>()
                                .FirstOrDefault(q => q.ViewFamily == ViewFamily.Drafting);

            ViewDrafting draftView;

            using (Transaction t = new Transaction(doc, "CreateViewDrafting"))
            {
                t.Start();
                draftView      = ViewDrafting.Create(doc, vd.Id);
                draftView.Name = name;
                t.Commit();
            }
            if (draftView != null)
            {
                return(draftView);
            }
            else
            {
                throw (new Exception("Не удалось вставить DWG файл"));
            }
        }
Пример #2
0
 public Autodesk.Revit.UI.Result Execute(
     ExternalCommandData commandData,
     ref string message,
     ElementSet elements)
 {
     try
     {
         Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document;
         Transaction transaction        = new Transaction(doc, "CreateDraftingView");
         transaction.Start();
         ViewDrafting drafting = doc.Create.NewViewDrafting();
         if (null == drafting)
         {
             message = "Can't create the ViewDrafting.";
             return(Autodesk.Revit.UI.Result.Failed);
         }
         transaction.Commit();
         TaskDialog.Show("Revit", "Create view drafting succeeded.");
         return(Autodesk.Revit.UI.Result.Succeeded);
     }
     catch (Exception e)
     {
         message = e.Message;
         return(Autodesk.Revit.UI.Result.Failed);
     }
 }
Пример #3
0
        private static bool DuplicateReferenceCallouts(View fromView, View toView)
        {
            bool result = false;

            try
            {
                Document fromDoc = fromView.Document;
                Document toDoc   = toView.Document;

                CopyPasteOptions copyPasteOptions = new CopyPasteOptions();
                copyPasteOptions.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());

                ICollection <ElementId> referenceCalloutIds = fromView.GetReferenceCallouts();
                if (referenceCalloutIds.Count > 0)
                {
                    foreach (ElementId eId in referenceCalloutIds)
                    {
                        XYZ  firstPoint  = null;
                        XYZ  secondPoint = null;
                        bool cornerFound = GetCalloutCornerPoints(fromDoc, eId, out firstPoint, out secondPoint);

                        Element callout = fromDoc.GetElement(eId);
                        if (null != callout)
                        {
                            using (Transaction trans = new Transaction(toDoc, "Duplicate Reference Callout"))
                            {
                                try
                                {
                                    trans.Start();

                                    toDoc.Regenerate();
                                    FilteredElementCollector collector = new FilteredElementCollector(toDoc);
                                    List <ViewDrafting>      views     = collector.OfClass(typeof(ViewDrafting)).ToElements().Cast <ViewDrafting>().ToList();
                                    var viewFound = from view in views where view.Name == callout.Name select view;
                                    if (viewFound.Count() > 0)
                                    {
                                        ViewDrafting referenceView = viewFound.First();
                                        ViewSection.CreateReferenceCallout(toDoc, toView.Id, referenceView.Id, firstPoint, secondPoint);
                                    }

                                    trans.Commit();
                                }
                                catch (Exception ex)
                                {
                                    string message = ex.Message;
                                    trans.RollBack();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                //MessageBox.Show("Failed to duplicate reference callouts.\n"+ex.Message, "Duplicate Reference Callouts", MessageBoxButton.OK, MessageBoxImage.Warning);
                errorMessage.AppendLine(toView.Name + ": errors in duplicating reference callouts");
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <param name="viewDrafting"></param>
        /// <returns></returns>
        private static Revit.Element CloneElement(Autodesk.Revit.UI.UIApplication app, ViewDrafting viewDrafting)
        {
            ViewDrafting viewDraftingClone = app.ActiveUIDocument.Document.Create.NewViewDrafting();

            Utils.ParamUtil.SetParameters(viewDraftingClone.Parameters, viewDrafting.Parameters);
            return(viewDraftingClone);
        }
Пример #5
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            ViewDrafting vd       = null;
            string       viewName = ((Value.String)args[0]).Item;

            if (this.Elements.Any())
            {
                if (!dynUtils.TryGetElement(this.Elements[0], out vd))
                {
                    vd = dynRevitSettings.Doc.Document.Create.NewViewDrafting();
                    this.Elements[0] = vd.Id;
                }
            }
            else
            {
                vd = dynRevitSettings.Doc.Document.Create.NewViewDrafting();
                this.Elements.Add(vd.Id);
            }

            //rename the view
            if (!vd.Name.Equals(viewName))
            {
                vd.Name = ViewBase.CreateUniqueViewName(viewName);
            }

            return(Value.NewContainer(vd));
        }
Пример #6
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();
        }
Пример #7
0
        private static ViewDrafting DuplicateDraftingViews(PreviewMap previewMap)
        {
            ViewDrafting viewDrafting = null;

            try
            {
                Document fromDoc = previewMap.SourceModelInfo.Doc;
                Document toDoc   = previewMap.RecipientModelInfo.Doc;

                ViewDrafting            sourceView          = previewMap.SourceViewProperties.ViewDraftingObj;
                ICollection <ElementId> referenceCalloutIds = sourceView.GetReferenceCallouts();

                CopyPasteOptions options = new CopyPasteOptions();
                options.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());

                ICollection <ElementId> copiedIds = null;
                using (Transaction transaction = new Transaction(toDoc, "Duplicate Draftingviews"))
                {
                    transaction.Start();
                    try
                    {
                        List <ElementId> viewIds = new List <ElementId>();
                        viewIds.Add(sourceView.Id);

                        //view-specific item
                        copiedIds = ElementTransformUtils.CopyElements(fromDoc, viewIds, toDoc, Transform.Identity, options);

                        FailureHandlingOptions failureOptions = transaction.GetFailureHandlingOptions();
                        failureOptions.SetFailuresPreprocessor(new HidePasteDuplicateTypesPreprocessor());
                        transaction.Commit(failureOptions);
                    }
                    catch (Exception ex)
                    {
                        string message = ex.Message;
                        transaction.RollBack();
                    }
                }

                if (null != copiedIds)
                {
                    ElementId    viewId     = copiedIds.First();
                    ViewDrafting copiedView = toDoc.GetElement(viewId) as ViewDrafting;
                    if (null != copiedView)
                    {
                        int numOfCopied = DuplicateDetailingAcrossViews(sourceView, copiedView);
                    }
                    if (referenceCalloutIds.Count > 0)
                    {
                        bool placedCallout = DuplicateReferenceCallouts(sourceView, copiedView);
                    }
                    viewDrafting = copiedView;
                }
            }
            catch (Exception ex)
            {
                errorMessage.AppendLine(previewMap.SourceViewProperties.ViewName + ": errors in duplicating drafting views.\n" + ex.Message);
                //MessageBox.Show("Failed to duplicate drafintg views.\n" + ex.Message, "Duplicate DraftingViews", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(viewDrafting);
        }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <param name="viewDrafting"></param>
        /// <returns></returns>
        private static Revit.Element CloneElement(Autodesk.Revit.UI.UIApplication app, ViewDrafting viewDrafting)
        {
            //ViewDrafting viewDraftingClone = app.ActiveUIDocument.Document.Create.NewViewDrafting(); // 2015, jeremy: 'Autodesk.Revit.Creation.Document.NewViewDrafting()' is obsolete: 'This method is obsolete in Revit 2015.  Use ViewDrafting.Create() instead.'
            ViewDrafting viewDraftingClone = ViewDrafting.Create(app.ActiveUIDocument.Document, viewDrafting.GetTypeId()); // 2016, jeremy

            Utils.ParamUtil.SetParameters(viewDraftingClone.Parameters, viewDrafting.Parameters);
            return(viewDraftingClone);
        }
Пример #9
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);
        }
Пример #10
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();
        }
Пример #11
0
        XYZ drawMoreAlert(Document doc, ViewDrafting view, string type, int count, double shleif, int ark, XYZ start, string txt)
        {
            XYZ lineStart = drawOneAlert(doc, view, type, 1, shleif, ark, start, txt);
            XYZ lineEnd   = new XYZ(lineStart.X + 0.5, lineStart.Y, 0);

            geometry.AddDottedLine(lineStart, lineEnd, doc, view);
            //geometry.AddLines(doc, view, geometry.ConnectLinesByPoints(new List<XYZ> { lineStart, lineEnd }));
            return(lineStart = drawOneAlert(doc, view, type, count, shleif, ark, lineEnd, txt));
        }
Пример #12
0
        public static ViewDrafting viewDraftingCreate(Document doc, string viewName)
        {
            FilteredElementCollector collector      = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType));
            ViewFamilyType           viewFamilyType = collector.Cast <ViewFamilyType>().First(vft => vft.ViewFamily == ViewFamily.Drafting);
            ViewDrafting             view           = ViewDrafting.Create(doc, viewFamilyType.Id);

            view.ViewName = viewName;

            return(view);
        }
Пример #13
0
 public void AddLines(Document doc, ViewDrafting view, List <Line> lines)
 {
     foreach (Line l in lines)
     {
         Transaction trans = new Transaction(doc);
         trans.Start("Отрисовка линии: ");
         doc.Create.NewDetailCurve(view, l);
         trans.Commit();
     }
 }
Пример #14
0
        View CreateDrafting(Document doc)
        {
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.OfClass(typeof(ViewFamilyType));
            ViewFamilyType viewFamilyType = collector.Cast <ViewFamilyType>().First(vft => vft.ViewFamily == ViewFamily.Drafting);
            ViewDrafting   drafting       = ViewDrafting.Create(doc, viewFamilyType.Id);

            return(drafting as View);
        }
Пример #15
0
        XYZ drawTwo(Document doc, ViewDrafting view, bool type, double shleif, int ark, XYZ start)
        {
            XYZ lineStart = drawOne(doc, view, type, 1, shleif, ark, start);
            XYZ lineEnd   = new XYZ(lineStart.X + 0.5, lineStart.Y, 0);

            geometry.AddLines(doc, view, geometry.ConnectLinesByPoints(new List <XYZ> {
                lineStart, lineEnd
            }));
            return(lineStart = drawOne(doc, view, type, 2, shleif, ark, lineEnd));
        }
Пример #16
0
        void DrawSensors(XYZ point, MEPSystem mep, int ark, ViewDrafting view, Document doc)
        {
            int Dim  = 0;
            int Hand = 0;

            foreach (Element e in mep.Elements)
            {
                if (e.Name.Contains("дым"))
                {
                    ++Dim;
                }
                if (e.Name.Contains("ИПР"))
                {
                    ++Hand;
                }
            }
            if (Dim > 0)
            {
                if (Dim == 1)
                {
                    point = drawOne(doc, view, true, 1, Double.Parse(mep.Name), ark, point);
                }
                if (Dim == 2)
                {
                    point = drawTwo(doc, view, true, Double.Parse(mep.Name), ark, point);
                }
                if (Dim > 2)
                {
                    point = drawMore(doc, view, true, Dim, Double.Parse(mep.Name), ark, point);
                }
            }
            if (Hand > 0)
            {
                if (Dim > 0)
                {
                    geometry.AddLines(doc, view, geometry.ConnectLinesByPoints(new List <XYZ> {
                        point, new XYZ(point.X + 0.5, point.Y, 0)
                    }));
                    point = new XYZ(point.X + 0.5, point.Y, 0);
                }
                //нарисовать соединение
                if (Hand == 1)
                {
                    point = drawOne(doc, view, false, 1, Double.Parse(mep.Name), ark, point);
                }
                if (Hand == 2)
                {
                    point = drawTwo(doc, view, false, Double.Parse(mep.Name), ark, point);
                }
                if (Hand > 2)
                {
                    point = drawMore(doc, view, false, Hand, Double.Parse(mep.Name), ark, point);
                }
            }
        }
Пример #17
0
        private static void refreshProjBrowser(Document curDoc)
        {
            //create temp drafting view
            ViewDrafting tmpView = null;

            tmpView      = ViewDrafting.Create(curDoc, mCollectors.getDraftingViewFamilyTypeID(curDoc));
            tmpView.Name = "zzz_temp";

            //delete view
            curDoc.Delete(tmpView.Id);
        }
Пример #18
0
 void DrawAll(Document doc)
 {
     foreach (ARKModule b in ARKBLocks)
     {
         ViewFamilyType vt    = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast <ViewFamilyType>().FirstOrDefault(vft => vft.ViewFamily == ViewFamily.Drafting);
         ElementId      id    = vt.Id;
         Transaction    trans = new Transaction(doc);
         trans.Start("Lab");
         ViewDrafting vd = ViewDrafting.Create(doc, id);
         trans.Commit();
     }
 }
Пример #19
0
        private ViewDrafting CreateNewDraftingView()
        {
            var drfViews = new FilteredElementCollector(CurrentDocument)
                           .OfClass(typeof(ViewFamilyType));

            var dvId = drfViews
                       .Cast <ViewFamilyType>()
                       .FirstOrDefault(v => v.ViewFamily == ViewFamily.Drafting).Id;

            var newView = ViewDrafting.Create(CurrentDocument, dvId);

            return(newView);
        }
Пример #20
0
        void DrawAll(Document doc)
        {
            foreach (string s in staticFamilies)
            {
                try
                {
                    string file_path = File.ReadAllText("C://ProgramData//Autodesk//Revit//Addins//2019//Linear//settings.set");
                    file_path += "\\static\\" + s;
                    loader.LoadFamilyIntoProject(file_path, doc);
                }
                catch { throw new Exception("Ошибка загрузки семейств чертежных примитивов из папки static."); }
            }
            FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol));

            foreach (ARKModule b in ARKBLocks)
            {
                try
                {
                    FamilySymbol   famToPlace = null;
                    ViewFamilyType vt         = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast <ViewFamilyType>().FirstOrDefault(vft => vft.ViewFamily == ViewFamily.Drafting);
                    ElementId      id         = vt.Id;
                    Transaction    trans      = new Transaction(doc);
                    trans.Start("Отрисовка");
                    ViewDrafting vd = ViewDrafting.Create(doc, id);
                    b.setVD(vd);
                    ElementId viewId = vd.Id;
                    drawingviews.Add(viewId);
                    famToPlace    = collector.Cast <FamilySymbol>().Where(x => x.Name == b.filename).First();
                    b.revitSymbol = famToPlace;
                    b.revitModule = doc.Create.NewFamilyInstance(new XYZ(0, 0, 0), famToPlace, vd);
                    arkmoduleIds.Add(b.revitModule.Id);
                    trans.Commit();
                }
                catch { throw new Exception("Ошибка добавления АРК-модулей на чертежные листы."); }
            }

            SetArkIndexes(doc);

            DrawLines(doc);

            foreach (ARKModule b in ARKBLocks)
            {
                try
                {
                    b.createTable(doc, new XYZ(10, 3, 0));
                }
                catch { throw new Exception("Ошибка создания таблицы элементов."); }
            }
        }
		public static void CreateOnViewDrafting(ViewDrafting view, ElementId linkId)
		{
			Document doc = view.Document;

			ImportInstance instance = doc.GetElement(linkId) as ImportInstance;
			GeometryElement geometryElement = instance.get_Geometry(new Options());
			foreach (GeometryObject go in geometryElement)
			{
				GeometryInstance ginstance = go as GeometryInstance;
				if (null != ginstance)
				{
					CreatePrimitives(view, ginstance.SymbolGeometry);
				}
			}
		}
Пример #22
0
        protected override Result Work()
        {
            // create new drafting view
            _draftingView = CreateNewDraftingView();

            // get data from excel and each of the cells
            //GetExcelData

            // get columns & row sizes

            // modify drafting view to add columns and rows



            return(Result.Succeeded);
        }
Пример #23
0
        XYZ drawOne(Document doc, ViewDrafting view, bool type, int count, double shleif, int ark, XYZ start)
        {
            FamilySymbol famToPlace = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().Where(x => type? x.Name == "BTH":x.Name == "BTM").FirstOrDefault();
            Transaction  trans      = new Transaction(doc);

            trans.Start("Помещен на рисунок");
            FamilyInstance sensor = doc.Create.NewFamilyInstance(start, famToPlace, view);

            trans.Commit();
            trans.Start("Помещен на рисунок");
            sensor.LookupParameter("ark").Set(ark);
            sensor.LookupParameter("нпп").Set(count);
            sensor.LookupParameter("шлейф").Set((Int32)shleif);
            trans.Commit();
            return(new XYZ(start.X + sensor.Symbol.LookupParameter("Ширина").AsDouble() * 10, start.Y, 0));
        }
Пример #24
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            ViewDrafting vd       = null;
            string       viewName = ((Value.String)args[0]).Item;

            if (!string.IsNullOrEmpty(viewName))
            {
                //if we've already found the view
                //and it's the same one, get out
                if (vd != null && vd.Name == viewName)
                {
                    return(Value.NewContainer(vd));
                }

                FilteredElementCollector fec = new FilteredElementCollector(dynRevitSettings.Doc.Document);
                fec.OfClass(typeof(ViewDrafting));

                IList <Element> els = fec.ToElements();

                var vds = from v in els
                          where ((ViewDrafting)v).Name == viewName
                          select v;

                if (vds.Count() == 0)
                {
                    try
                    {
                        //create the view
                        vd = dynRevitSettings.Doc.Document.Create.NewViewDrafting();
                        if (vd != null)
                        {
                            vd.Name = viewName;
                        }
                    }
                    catch
                    {
                        DynamoLogger.Instance.Log(string.Format("Could not create view: {0}", viewName));
                    }
                }
                else
                {
                    vd = vds.First() as ViewDrafting;
                }
            }

            return(Value.NewContainer(vd));
        }
Пример #25
0
        public double createFasadeDetail(
            Document doc,
            double y,
            FamilySymbol symbol,
            ViewDrafting view,
            string position,
            string name,
            double h)
        {
            var detail = doc.Create.NewFamilyInstance(new XYZ(0, y, 0), symbol, view);

            detail.LookupParameter("Панель - Имя шкафа").Set(shelfName);
            detail.LookupParameter("AG_Spc_Позиция").Set(position);
            detail.LookupParameter("AG_Spc_Наименование").Set(name);
            y -= h / 304.8;
            return(y);
        }
Пример #26
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));
        }
Пример #27
0
        public Result Execute(ExternalCommandData commandData,
                              ref string messege,
                              ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            try
            {
                var filePath = string.Empty;
                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Filter           = "dwg files (*.dwg)|*.dwg";
                    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        filePath = openFileDialog.FileName;

                        using (TransactionGroup tg = new TransactionGroup(uidoc.Document, "DraftingViewByDWGFile"))
                        {
                            tg.Start();

                            ViewDrafting view   = ViewCreator.CreateViewDrafting(uidoc.Document, System.IO.Path.GetFileName(filePath));
                            ElementId    linkId = DWGLink.Insert(view, filePath);
                            CreateGeometryObject.CreateOnViewDrafting(view as ViewDrafting, linkId);
                            DWGLink.Delete(uidoc.Document, linkId);

                            uidoc.ActiveView = view;

                            tg.Assimilate();
                        }
                    }
                }
                return(Result.Succeeded);
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return(Result.Cancelled);
            }
            catch (Exception ex)
            {
                messege = ex.Message;
                return(Result.Failed);
            }
        }
Пример #28
0
        IList <Element> GetViewsToDelete(Document doc)
        {
            using (Transaction trans = new Transaction(doc))
            {
                // Collect all Views except ViewTemplates
                // Add one drafting view to project before deleting
                // all views because Revit will shut down when last view
                // is deleted from project.

                // Create a new Drafting view
                ViewFamilyType viewFamilyType = new FilteredElementCollector(doc)
                                                .OfClass(typeof(ViewFamilyType))
                                                .Cast <ViewFamilyType>().First(vft => vft.ViewFamily == ViewFamily.Drafting);

                trans.Start("Delete All Views/Sheets");
                ViewDrafting view = ViewDrafting.Create(doc, viewFamilyType.Id);
                view.ViewName = "TempDraftingView";

                doc.Regenerate();

                // Collect all Views except newly created one
                List <ElementId> exclude = new List <ElementId>();
                exclude.Add(view.Id);

                ExclusionFilter filter = new ExclusionFilter(exclude);
                IList <Element> views  = new FilteredElementCollector(doc)
                                         .OfClass(typeof(View))
                                         .WhereElementIsNotElementType()
                                         .WherePasses(filter)
                                         .ToElements();

                // Remove all ViewTemplates from views to be deleted
                for (var i = 0; i < views.Count; i++)
                {
                    View v = views[i] as View;
                    if (v.IsTemplate)
                    {
                        views.RemoveAt(i);
                    }
                }
                trans.Commit();
                return(views);
            }
        }
Пример #29
0
        public void AddDottedLine(XYZ start, XYZ end, Document doc, ViewDrafting vd)
        {
            Element style = null;
            ICollection <Element> elements = new FilteredElementCollector(doc).OfClass(typeof(GraphicsStyle)).ToElements();

            foreach (Element element in elements)
            {
                if (element.Name == "<Снесено>")
                {
                    style = element;
                }
            }
            using (Transaction t = new Transaction(doc))
            {
                t.Start("Преобразование линий");
                DetailCurve l = doc.Create.NewDetailCurve(vd, Line.CreateBound(start, end));
                l.LineStyle = style;
                t.Commit();
            }
        }
Пример #30
0
        public Autodesk.Revit.UI.Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            try
            {
                Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document;
                Transaction transaction        = new Transaction(doc, "CreateDraftingView");
                transaction.Start();

                ViewFamilyType           viewFamilyType = null;
                FilteredElementCollector collector      = new FilteredElementCollector(doc);
                var viewFamilyTypes = collector.OfClass(typeof(ViewFamilyType)).ToElements();
                foreach (Element e in viewFamilyTypes)
                {
                    ViewFamilyType v = e as ViewFamilyType;
                    if (v.ViewFamily == ViewFamily.Drafting)
                    {
                        viewFamilyType = v;
                        break;
                    }
                }
                ViewDrafting drafting = ViewDrafting.Create(doc, viewFamilyType.Id);
                if (null == drafting)
                {
                    message = "Can't create the ViewDrafting.";
                    return(Autodesk.Revit.UI.Result.Failed);
                }


                transaction.Commit();
                TaskDialog.Show("Revit", "Create view drafting succeeded.");
                return(Autodesk.Revit.UI.Result.Succeeded);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Autodesk.Revit.UI.Result.Failed);
            }
        }
Пример #31
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="app"></param>
    /// <param name="viewDrafting"></param>
    /// <returns></returns>
    private static Revit.Element CloneElement( Autodesk.Revit.UI.UIApplication app, ViewDrafting viewDrafting )
    {
      //ViewDrafting viewDraftingClone = app.ActiveUIDocument.Document.Create.NewViewDrafting(); // 2015, jeremy: 'Autodesk.Revit.Creation.Document.NewViewDrafting()' is obsolete: 'This method is obsolete in Revit 2015.  Use ViewDrafting.Create() instead.'
      ViewDrafting viewDraftingClone = ViewDrafting.Create( app.ActiveUIDocument.Document, viewDrafting.GetTypeId()); // 2016, jeremy

      Utils.ParamUtil.SetParameters( viewDraftingClone.Parameters, viewDrafting.Parameters );
      return viewDraftingClone;
    }
Пример #32
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="app"></param>
 /// <param name="viewDrafting"></param>
 /// <returns></returns>
 private static Revit.Element CloneElement( Autodesk.Revit.UI.UIApplication app, ViewDrafting viewDrafting )
 {
     ViewDrafting viewDraftingClone = app.ActiveUIDocument.Document.Create.NewViewDrafting();
       Utils.ParamUtil.SetParameters( viewDraftingClone.Parameters, viewDrafting.Parameters );
       return viewDraftingClone;
 }
Пример #33
0
        private void Stream( ArrayList data, ViewDrafting view )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( ViewDrafting ) ) );
              Utils.StreamWithReflection( data, typeof( ViewDrafting ), view );

              // nothing at this level yet
        }