Stream(ArrayList data, AreaVolumeSettings areaSettings)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(AreaVolumeSettings)));

            data.Add(new Snoop.Data.String("Room area boundary location", areaSettings.GetSpatialElementBoundaryLocation(SpatialElementType.Room).ToString()));
            data.Add(new Snoop.Data.Bool("Volume computation enable", areaSettings.ComputeVolumes));
        }
        public Dictionary <Room, List <string> > GetRoomInfo(Document document, UIDocument uidoc)
        {
            using (Transaction t = new Transaction(document, "Turn on volume calculation"))
            {
                t.Start();
                AreaVolumeSettings settings = AreaVolumeSettings.GetAreaVolumeSettings(document);
                settings.ComputeVolumes = true;
                t.Commit();
            }

            Dictionary <Room, List <string> > dimensions = new Dictionary <Room, List <string> >();
            List <string>            info      = new List <string>();
            RoomFilter               filter    = new RoomFilter();
            FilteredElementCollector collector = new FilteredElementCollector(document);

            collector.WherePasses(filter);

            FilteredElementIdIterator roomIdItr = collector.GetElementIdIterator();

            roomIdItr.Reset();
            while (roomIdItr.MoveNext())
            {
                ElementId roomId = roomIdItr.Current;
                Room      room   = document.GetElement(roomId) as Room;

                //Make sure room is valid
                if (room != null)
                {
                    //Wall wall = document.GetReference(room) as Wall;

                    //Fill out dictionary with room attributes
                    info.Add(room.Name);
                    info.Add(room.Volume.ToString());
                    info.Add(room.Area.ToString());
                    info.Add(room.Perimeter.ToString());
                    info.Add(room.UnboundedHeight.ToString());

                    dimensions.Add(room, info);
                }
            }

            return(dimensions);
        }
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false); // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Color color = e.ObjToSnoop as Color;

            if (color != null)
            {
                Stream(snoopCollector.Data(), color);
                return;
            }

            LayoutRule layoutRule = e.ObjToSnoop as LayoutRule;

            if (layoutRule != null)
            {
                Stream(snoopCollector.Data(), layoutRule);
                return;
            }

            FormatOptions formatOptions = e.ObjToSnoop as FormatOptions;

            if (formatOptions != null)
            {
                Stream(snoopCollector.Data(), formatOptions);
                return;
            }

            CurtainGrid curtainGrid = e.ObjToSnoop as CurtainGrid;

            if (curtainGrid != null)
            {
                Stream(snoopCollector.Data(), curtainGrid);
                return;
            }

            CurtainCell curtainCell = e.ObjToSnoop as CurtainCell;

            if (curtainCell != null)
            {
                Stream(snoopCollector.Data(), curtainCell);
                return;
            }

            RebarHostData rebarHostData = e.ObjToSnoop as RebarHostData;

            if (rebarHostData != null)
            {
                Stream(snoopCollector.Data(), rebarHostData);
                return;
            }

            Leader leader = e.ObjToSnoop as Leader;

            if (leader != null)
            {
                Stream(snoopCollector.Data(), leader);
                return;
            }

            AreaVolumeSettings areaSettings = e.ObjToSnoop as AreaVolumeSettings;

            if (areaSettings != null)
            {
                Stream(snoopCollector.Data(), areaSettings);
                return;
            }

            ViewSheetSetting viewSheetSetting = e.ObjToSnoop as ViewSheetSetting;

            if (viewSheetSetting != null)
            {
                Stream(snoopCollector.Data(), viewSheetSetting);
                return;
            }

            Autodesk.Revit.UI.Events.DialogBoxData dlgBoxData = e.ObjToSnoop as Autodesk.Revit.UI.Events.DialogBoxData;
            if (dlgBoxData != null)
            {
                Stream(snoopCollector.Data(), dlgBoxData);
                return;
            }

            Construction construct = e.ObjToSnoop as Construction;

            if (construct != null)
            {
                Stream(snoopCollector.Data(), construct);
                return;
            }

            FamilyElementVisibility famElemVisib = e.ObjToSnoop as FamilyElementVisibility;

            if (famElemVisib != null)
            {
                Stream(snoopCollector.Data(), famElemVisib);
                return;
            }

            FamilyManager famManager = e.ObjToSnoop as FamilyManager;

            if (famManager != null)
            {
                Stream(snoopCollector.Data(), famManager);
                return;
            }

            FamilyParameter famParam = e.ObjToSnoop as FamilyParameter;

            if (famParam != null)
            {
                Stream(snoopCollector.Data(), famParam);
                return;
            }

            FamilyType famType = e.ObjToSnoop as FamilyType;

            if (famType != null)
            {
                Stream(snoopCollector.Data(), famType);
                return;
            }

            MEPSpaceConstruction mepSpaceConstuct = e.ObjToSnoop as MEPSpaceConstruction;

            if (mepSpaceConstuct != null)
            {
                Stream(snoopCollector.Data(), mepSpaceConstuct);
                return;
            }

            BuildingSiteExportOptions bldSiteExpOptions = e.ObjToSnoop as BuildingSiteExportOptions;

            if (bldSiteExpOptions != null)
            {
                Stream(snoopCollector.Data(), bldSiteExpOptions);
                return;
            }

            DGNExportOptions dgnExpOptions = e.ObjToSnoop as DGNExportOptions;

            if (dgnExpOptions != null)
            {
                Stream(snoopCollector.Data(), dgnExpOptions);
                return;
            }

            DWFExportOptions dwfExpOptions = e.ObjToSnoop as DWFExportOptions;

            if (dwfExpOptions != null)
            {
                Stream(snoopCollector.Data(), dwfExpOptions);
                return;
            }

            DWGExportOptions dwgExpOptions = e.ObjToSnoop as DWGExportOptions;

            if (dwgExpOptions != null)
            {
                Stream(snoopCollector.Data(), dwgExpOptions);
                return;
            }

            DWGImportOptions dwgImpOptions = e.ObjToSnoop as DWGImportOptions;

            if (dwgImpOptions != null)
            {
                Stream(snoopCollector.Data(), dwgImpOptions);
                return;
            }

            FBXExportOptions fbxExpOptions = e.ObjToSnoop as FBXExportOptions;

            if (fbxExpOptions != null)
            {
                Stream(snoopCollector.Data(), fbxExpOptions);
                return;
            }

            TrussMemberInfo trussInfo = e.ObjToSnoop as TrussMemberInfo;

            if (trussInfo != null)
            {
                Stream(snoopCollector.Data(), trussInfo);
                return;
            }

            VertexIndexPair vertIndPair = e.ObjToSnoop as VertexIndexPair;

            if (vertIndPair != null)
            {
                Stream(snoopCollector.Data(), vertIndPair);
                return;
            }

            PointElementReference ptElemRef = e.ObjToSnoop as PointElementReference;

            if (ptElemRef != null)
            {
                Stream(snoopCollector.Data(), ptElemRef);
                return;
            }

            Autodesk.Revit.DB.Architecture.BoundarySegment boundSeg = e.ObjToSnoop as Autodesk.Revit.DB.Architecture.BoundarySegment;
            if (boundSeg != null)
            {
                Stream(snoopCollector.Data(), boundSeg);
                return;
            }

            PointLocationOnCurve ptLocOnCurve = e.ObjToSnoop as PointLocationOnCurve;

            if (ptLocOnCurve != null)
            {
                Stream(snoopCollector.Data(), ptLocOnCurve);
                return;
            }

            Entity entity = e.ObjToSnoop as Entity;

            if (entity != null)
            {
                Stream(snoopCollector.Data(), entity);
                return;
            }

            Field field = e.ObjToSnoop as Field;

            if (field != null)
            {
                Stream(snoopCollector.Data(), field);
                return;
            }

            ExtensibleStorageField storeagefield = e.ObjToSnoop as ExtensibleStorageField;

            if (storeagefield != null)
            {
                Stream(snoopCollector.Data(), storeagefield);
                return;
            }

            IList <Autodesk.Revit.DB.BoundarySegment> boundSegs = e.ObjToSnoop as
                                                                  IList <Autodesk.Revit.DB.BoundarySegment>;

            if (boundSegs != null)
            {
                Stream(snoopCollector.Data(), boundSegs);
                return;
            }

            if (e.ObjToSnoop is KeyValuePair <String, String> )
            {
                KeyValuePair <String, String> stringspair = (KeyValuePair <String, String>)e.ObjToSnoop;
                Stream(snoopCollector.Data(), stringspair);
                return;
            }

            Schema schema = e.ObjToSnoop as Schema;

            if (schema != null)
            {
                Stream(snoopCollector.Data(), schema);
                return;
            }

            ElementId elemId = e.ObjToSnoop as ElementId;

            if (elemId != null)
            {
                Stream(snoopCollector.Data(), elemId);
                return;
            }

            PlanViewRange plvr = e.ObjToSnoop as PlanViewRange;

            if (plvr != null)
            {
                Stream(snoopCollector.Data(), plvr);
                return;
            }
            //TF
            RebarConstraintsManager rbcm = e.ObjToSnoop as RebarConstraintsManager;

            if (rbcm != null)
            {
                Stream(snoopCollector.Data(), rbcm);
                return;
            }

            RebarConstrainedHandle rbch = e.ObjToSnoop as RebarConstrainedHandle;

            if (rbch != null)
            {
                Stream(snoopCollector.Data(), rbch);
                return;
            }

            RebarConstraint rbc = e.ObjToSnoop as RebarConstraint;

            if (rbc != null)
            {
                Stream(snoopCollector.Data(), rbc);
                return;
            }

            //TFEND

            if (Utils.IsSupportedType(e.ObjToSnoop) && e.ObjToSnoop != null)
            {
                Utils.StreamWithReflection(snoopCollector.Data(), e.ObjToSnoop.GetType(), e.ObjToSnoop);
            }
        }
Example #4
0
        public static Result ExecuteCalculations(ExternalCommandData commandData)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            List <string> roomNames     = new List <string>();
            List <string> areaType      = new List <string>();
            List <string> areaValue     = new List <string>();
            List <string> levelNames    = new List <string>();
            List <string> areaValueCalc = new List <string>();

            using (Transaction t = new Transaction(doc, "Turn on volume calculation"))
            {
                t.Start();
                AreaVolumeSettings settings = AreaVolumeSettings.GetAreaVolumeSettings(doc);
                settings.ComputeVolumes = true;
                t.Commit();
            }

            // setup spacial properties
            SpatialElementBoundaryOptions sebOptions = new SpatialElementBoundaryOptions();



            // get all rooms
            FilteredElementCollector room_collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType();
            IList <ElementId>        room_eids      = room_collector.ToElementIds() as IList <ElementId>;

            foreach (ElementId eid in room_eids)
            {
                Room room = doc.GetElement(eid) as Room;
                {
                    // grab room spacial calculations
                    sebOptions.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center;
                    SpatialElementGeometryCalculator centerCalc = new SpatialElementGeometryCalculator(doc, sebOptions);
                    SpatialElementGeometryResults    center     = centerCalc.CalculateSpatialElementGeometry(room);

                    sebOptions.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
                    SpatialElementGeometryCalculator finishCalc = new SpatialElementGeometryCalculator(doc, sebOptions);
                    SpatialElementGeometryResults    finish     = finishCalc.CalculateSpatialElementGeometry(room);

                    // get room properties
                    roomNames.Add(room.Name);
                    areaType.Add("Center");
                    levelNames.Add(room.Level.Name);
                    areaValue.Add(center.GetGeometry().SurfaceArea.ToString());

                    TaskDialog.Show("Revit", room.Name + room.Level.Name + center.GetGeometry().SurfaceArea.ToString());


                    roomNames.Add(room.Name);
                    areaType.Add("Finish");
                    levelNames.Add(room.Level.Name);
                    areaValue.Add(finish.GetGeometry().SurfaceArea.ToString());

                    TaskDialog.Show("Revit", room.Name + room.Level.Name + finish.GetGeometry().SurfaceArea.ToString());
                }
            }



            return(Result.Succeeded);
        }
      Stream(ArrayList data, AreaVolumeSettings areaSettings)
      {
          data.Add(new Snoop.Data.ClassSeparator(typeof(AreaVolumeSettings)));

          data.Add(new Snoop.Data.String("Room area boundary location", areaSettings.GetSpatialElementBoundaryLocation(SpatialElementType.Room).ToString()));
          data.Add(new Snoop.Data.Bool("Volume computation enable", areaSettings.ComputeVolumes));
      }
Example #6
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            List <string> materialsUsed = new List <string>();
            MaterialsVM   myVM          = new MaterialsVM();

            var doc  = commandData.Application.ActiveUIDocument.Document;
            var cats = new List <BuiltInCategory> {
                BuiltInCategory.OST_StructuralFoundation,
                BuiltInCategory.OST_StructuralFraming,
                BuiltInCategory.OST_StructuralColumns,
                BuiltInCategory.OST_Floors,
                BuiltInCategory.OST_EdgeSlab,
                BuiltInCategory.OST_Walls
            };


            //enable volume computations
            using (Transaction t = new Transaction(doc, "Turn on vol calc"))
            {
                t.Start();
                var settings = AreaVolumeSettings.GetAreaVolumeSettings(doc);
                settings.ComputeVolumes = true;
                t.Commit();
            }

            foreach (var cat in cats)
            {
                var catFilters = new List <ElementFilter> {
                    new ElementCategoryFilter(cat)
                };

                var filter = new LogicalOrFilter(catFilters);

                var structures = new FilteredElementCollector(doc)
                                 .WherePasses(filter)
                                 .ToElements();

                double vol     = 0;
                int    counter = 0;

                foreach (var item in structures)
                {
                    var mat = item.LookupParameter("Structural Material");
                    if (mat == null)
                    {
                        var itemType = doc.GetElement(item.GetTypeId());
                        if (itemType != null)
                        {
                            mat = itemType.LookupParameter("Structural Material");
                        }
                    }
                    var volParam = item.LookupParameter("Volume");

                    var    elemType = item.GetTypeId();
                    string name     = "";
                    var    elemTy   = doc.GetElement(elemType) as ElementType;
                    if (elemTy != null)
                    {
                        name = elemTy.FamilyName + ": " + elemTy.Name;
                    }

                    string matName = "";
                    if (volParam != null)
                    {
                        if (mat != null)
                        {
                            matName = mat.AsValueString();
                            if (!materialsUsed.Contains(matName))
                            {
                                materialsUsed.Add(matName);
                            }
                        }

                        var    test      = volParam.AsValueString();
                        double metricVol = volParam.AsDouble() * _cubicFtToM;
                        vol += metricVol;
                        counter++;

                        myVM.AddElement(name, metricVol, matName, doc, cat);
                    }
                }
            }

            var    userControl  = new UserControl1();
            Window carbonWindow = new Window()
            {
                Content     = userControl,
                DataContext = myVM
            };

            carbonWindow.ShowDialog();

            return(Result.Succeeded);
        }
Example #7
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            List <string> materialsUsed = new List <string>();
            MaterialsVM   myVM          = new MaterialsVM();

            var doc  = commandData.Application.ActiveUIDocument.Document;
            var cats = new List <BuiltInCategory> {
                BuiltInCategory.OST_StructuralFoundation,
                BuiltInCategory.OST_StructuralFraming,
                BuiltInCategory.OST_StructuralColumns,
                BuiltInCategory.OST_Floors,
                BuiltInCategory.OST_EdgeSlab,
                BuiltInCategory.OST_Walls,
                BuiltInCategory.OST_Ramps,
                BuiltInCategory.OST_Stairs,
                BuiltInCategory.OST_Windows,
                BuiltInCategory.OST_Doors
            };


            //enable volume computations
            using (Transaction t = new Transaction(doc, "Turn on vol calc"))
            {
                t.Start();
                var settings = AreaVolumeSettings.GetAreaVolumeSettings(doc);
                settings.ComputeVolumes = true;
                t.Commit();
            }

            foreach (var cat in cats)
            {
                var catFilters = new List <ElementFilter> {
                    new ElementCategoryFilter(cat)
                };

                var filter = new LogicalOrFilter(catFilters);

                var structures = new FilteredElementCollector(doc)
                                 .WherePasses(filter)
                                 .ToElements();

                double vol     = 0;
                int    counter = 0;

                foreach (var item in structures)
                {
                    var mat = item.LookupParameter("Structural Material");
                    if (mat == null)
                    {
                        var itemType = doc.GetElement(item.GetTypeId());
                        if (itemType != null)
                        {
                            mat = itemType.LookupParameter("Structural Material");
                        }
                    }
                    var volParam = item.LookupParameter("Volume");

                    var    elemType = item.GetTypeId();
                    string name     = "";
                    var    elemTy   = doc.GetElement(elemType) as ElementType;
                    if (elemTy != null)
                    {
                        name = elemTy.FamilyName + ": " + elemTy.Name;
                    }

                    string matName = "";
                    if (volParam != null)
                    {
                        if (mat != null)
                        {
                            matName = mat.AsValueString();
                            if (!materialsUsed.Contains(matName))
                            {
                                materialsUsed.Add(matName);
                            }
                        }

                        var    test      = volParam.AsValueString();
                        double metricVol = volParam.AsDouble() * _cubicFtToM;
                        vol += metricVol;
                        counter++;

                        myVM.AddElement(name, metricVol, matName, doc, cat);
                    }
                }
            }

            CarbonCalculator.ElementSet myset = new CarbonCalculator.ElementSet("Category", "Material", "Level", "Phase", "Design Option");

            Window          optionsWindow = new Window();
            ImportOptionsVM optionsVM     = new ImportOptionsVM(optionsWindow);

            optionsWindow.Content     = new CarbonCalculator.ImportOptions();
            optionsWindow.DataContext = optionsVM;
            optionsWindow.Width       = 300;
            optionsWindow.Height      = 250;
            optionsWindow.ShowDialog();

            int faceCounter = 0;

            foreach (var cat in cats)
            {
                var counter = 0;

                var catFilters = new List <ElementFilter> {
                    new ElementCategoryFilter(cat)
                };

                var revitCat = Category.GetCategory(doc, cat);

                var filter = new LogicalOrFilter(catFilters);

                var structures = new FilteredElementCollector(doc)
                                 .WherePasses(filter)
                                 .ToElements();

                List <Element> AllElem = new FilteredElementCollector(doc)
                                         .WhereElementIsViewIndependent()
                                         .WhereElementIsNotElementType()
                                         .Where(e => e.IsPhysicalElement())
                                         .ToList <Element>();

                double vol = 0;
                foreach (var item in structures)
                {
                    var mat = item.LookupParameter("Structural Material");
                    if (mat == null)
                    {
                        var itemType = doc.GetElement(item.GetTypeId());
                        if (itemType != null)
                        {
                            mat = itemType.LookupParameter("Structural Material");
                        }
                    }

                    var volParam = item.LookupParameter("Volume");

                    var    elemType = item.GetTypeId();
                    string name     = "";
                    var    elemTy   = doc.GetElement(elemType) as ElementType;
                    if (elemTy != null)
                    {
                        name = elemTy.FamilyName + ": " + elemTy.Name;
                    }

                    string lvlstr = "";
                    var    lvl    = item.LevelId;
                    Level  level  = doc.GetElement(lvl) as Level;
                    if (level != null)
                    {
                        lvlstr = level.Name;
                    }

                    string phaseName = "";
                    Autodesk.Revit.DB.Phase phaseCreated = doc.GetElement(item.CreatedPhaseId) as Phase;
                    if (phaseCreated == null)
                    {
                        phaseName = "";
                    }
                    else
                    {
                        phaseName = phaseCreated.Name;
                    }

                    string designOptionName = "";
                    Autodesk.Revit.DB.DesignOption designOption = null;
                    if (item.DesignOption != null)
                    {
                        designOption = doc.GetElement(item.DesignOption.Id) as DesignOption;
                    }
                    if (designOption == null)
                    {
                        designOptionName = "Main";
                    }
                    else
                    {
                        designOptionName = designOption.Name;
                    }

                    var mats = item.GetMaterialIds(false);
                    if (mats.Count > 1 && ((optionsVM.ExplodeFloors && cat == BuiltInCategory.OST_Floors) || (optionsVM.ExplodeWalls && cat == BuiltInCategory.OST_Walls)))
                    {
                        foreach (var material in mats)
                        {
                            var    materialName = (doc.GetElement(material) as Material).Name;
                            var    materialVol  = item.GetMaterialVolume(material);
                            var    materialArea = item.GetMaterialArea(material, false);
                            double metricVol    = materialVol * _cubicFtToM;
                            double metricArea   = materialArea * _squareFtToM;
                            myset.AddElement(new CarbonCalculator.Element(name + " " + materialName, metricVol, metricArea, "Revit" + counter, revitCat.Name, materialName, lvlstr, phaseName, designOptionName));
                            counter++;
                        }
                    }
                    else if (mats.Count == 1)
                    {
                        var    material     = mats.First();
                        var    materialName = (doc.GetElement(material) as Material).Name;
                        var    materialVol  = item.GetMaterialVolume(material);
                        var    materialArea = item.GetMaterialArea(material, false);
                        double metricVol    = materialVol * _cubicFtToM;
                        double metricArea   = materialArea * _squareFtToM;
                        myset.AddElement(new CarbonCalculator.Element(name, metricVol, metricArea, "Revit" + counter, revitCat.Name, materialName, lvlstr, phaseName, designOptionName));
                        counter++;
                    }
                    else if (mats.Count > 1)
                    {
                        var    material     = mats.First();
                        var    materialName = (doc.GetElement(material) as Material).Name;
                        double metricVol    = 0;
                        if (volParam != null)
                        {
                            metricVol = volParam.AsDouble() * _cubicFtToM;
                        }
                        var    materialArea = item.GetMaterialArea(material, false);
                        double metricArea   = materialArea * _squareFtToM;
                        myset.AddElement(new CarbonCalculator.Element(name, metricVol, metricArea, "Revit" + counter, revitCat.Name, "Mixed materials", lvlstr, phaseName, designOptionName));
                        counter++;
                    }

                    faceCounter += getGeometry(item);
                    //string matName = "";
                    //if (volParam != null)
                    //{
                    //    if (mat != null)
                    //    {
                    //        matName = mat.AsValueString();
                    //    }

                    //    double metricVol = volParam.AsDouble() * _cubicFtToM;

                    //    myset.AddElement(new CarbonCalculator.Element(name, metricVol, "Revit" + counter, revitCat.Name, matName, lvlstr, phaseName, designOptionName));
                    //}
                    //counter++;
                }
            }

            var    control      = new CarbonCalculator.UserControl1();
            Window carbonWindow = new Window()
            {
                Content     = control,
                DataContext = new CarbonCalculator.AppVM(myset)
            };


            carbonWindow.ShowDialog();

            return(Result.Succeeded);
        }
Example #8
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //RUN EXCEL
            Excel.Application xlapp    = new Excel.Application();
            object            misvalue = System.Reflection.Missing.Value;

            Excel.Workbook workbook = xlapp.Workbooks.Add();

            //UIDOC - DOCS- LIENS
            UIDocument uidoc  = commandData.Application.ActiveUIDocument;
            Document   doc    = uidoc.Document;
            Options    option = new Options();

            option.DetailLevel = ViewDetailLevel.Fine;

            // CHECK SURFACE CALCUL METHOD
            AreaVolumeSettings surfacefinition = AreaVolumeSettings.GetAreaVolumeSettings(doc);

            if (surfacefinition.GetSpatialElementBoundaryLocation(SpatialElementType.Room) != SpatialElementBoundaryLocation.Finish)
            {
                TaskDialog changeboundary = new TaskDialog("Attention à la définition de surface de vos pièces !");
                changeboundary.MainInstruction = "La surface des pièces n'est pas définies par rapport aux fini des murs. Vous pouvez modifier la méthode de calcul dans l'onglet 'Architecture-Pièces'.";
                changeboundary.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Continuer");
                changeboundary.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Annuler");
                if (changeboundary.Show() == TaskDialogResult.CommandLink2)
                {
                    return(Result.Cancelled);
                }
            }

            //PRISE EN COMPTE DES LIENS REVIT
            FilteredElementCollector rvtlinks = new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_RvtLinks);
            List <Document>          docs     = new List <Document>();

            docs.Add(doc);
            try
            {
                foreach (RevitLinkInstance rvtlink in rvtlinks)
                {
                    if (docs.Contains(rvtlink.GetLinkDocument()) == false)
                    {
                        docs.Add(rvtlink.GetLinkDocument());
                    }
                }
            }
            catch (Exception)
            { }


            // CHOIX ENTRE BUREAU ET LOGEMENT
            TaskDialog introduction = new TaskDialog("B&P - Plug-in Indicateurs");

            introduction.MainInstruction = "De quel type est le batîment de votre maquette ?";
            introduction.MainContent     = "Attention aux doublons des maquettes en lien avant d'utiliser ce plugin." + string.Format("{0} document(s) récupéré(s) dans la maquette.", docs.Count);
            introduction.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Maquette de Logement");
            introduction.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Maquette de Bureaux");
            introduction.CommonButtons = TaskDialogCommonButtons.Cancel;
            TaskDialogResult tintroresult = introduction.Show();

            //SI LOGEMENT
            if (tintroresult == TaskDialogResult.CommandLink1)
            {
                //TYPOAPPART
                (Dictionary <string, string> listappart, Dictionary <string, double> areaappart, Dictionary <string, double> autrepieces) = Typoappart.infoappart(docs);
                Dictionary <string, List <double> > typologie = Typoappart.Dictypo(listappart, areaappart);
                Exportexcel.Exporttypoappart(xlapp, workbook, listappart, areaappart, typologie, autrepieces);
            }
            //SI BUREAU
            else if (tintroresult == TaskDialogResult.CommandLink2)
            {
                //QUOTEPART
                (Dictionary <string, List <double> > dicolotsurface, Dictionary <ElementId, List <double> > dicolevelsurface, Dictionary <ElementId, Dictionary <string, double> > dicolotlevel) = quotepart.BureauLot(docs);
                Exportexcel.Exportbureaulot(docs, xlapp, workbook, dicolotsurface, dicolevelsurface, dicolotlevel);
            }
            //ANNULATION
            else if (tintroresult == TaskDialogResult.Cancel)
            {
                return(Result.Cancelled);
            }

            //PARKINGS
            (Dictionary <string, int> parkings, int sommeplace) = Parking.parkinglots(docs);
            Exportexcel.exportparking(xlapp, workbook, parkings, sommeplace);


            //GARDE CORPS
            (Dictionary <string, double> gardecorps, Dictionary <int, string> erreursgc) = Gardecorps.metregardecorps(docs);
            Exportexcel.exportgardecorps(xlapp, workbook, gardecorps, erreursgc);

            //FACADE VIDE POUR PLEIN
            TaskDialog factask = new TaskDialog("Calcul de façade");

            factask.MainInstruction = "Calculer la façade vide pour plein ?";
            factask.MainContent     = "Attention ! Modélisation adéquate exigée !";
            factask.CommonButtons   = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
            if (factask.Show() == TaskDialogResult.Yes)
            {
                //FACADE VIDE POUR PLEIN
                (double surfacefacade, int comptemur, double surfacepanneaux) = Facadevidepourplein.facadeopaque(docs);
                (Dictionary <ElementId, double> dicfenvitre, List <List <string> > nomtypefen) = Facadevidepourplein.surfacefenetrevitre(docs, option);
                double surfacefenetres = 0;
                foreach (ElementId wintypeid in dicfenvitre.Keys)
                {
                    surfacefenetres += dicfenvitre[wintypeid];
                }
                double facadevidepourplein = (surfacefenetres + surfacepanneaux) / surfacefacade;
                facadevidepourplein = Math.Round(facadevidepourplein, 2);
                Exportexcel.exportfacadevidepourplein(xlapp, workbook, surfacefacade, dicfenvitre, nomtypefen, surfacefenetres, surfacepanneaux, facadevidepourplein, comptemur);
            }


            //CHOIX SAUVEGARDE
            string     nommaquette       = System.IO.Path.GetFileNameWithoutExtension(doc.Title);
            TaskDialog demandesauvegarde = new TaskDialog("Sauvegarder ?");

            demandesauvegarde.MainInstruction = "Sauvegarder et ouvrir le fichier Excel ?";
            demandesauvegarde.MainContent     = "Nom du fichier:" + "Export-Quantité-" + nommaquette;
            demandesauvegarde.CommonButtons   = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
            TaskDialogResult tresult5 = demandesauvegarde.Show();

            if (tresult5 == TaskDialogResult.Yes)
            {
                System.Windows.Forms.FolderBrowserDialog liens = new System.Windows.Forms.FolderBrowserDialog();
                liens.Description = "INDIQUEZ LE DOSSIER DE SAUVEGARDE DES DONNEES";
                if (liens.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(Result.Cancelled);
                }
                string path = liens.SelectedPath + "/ " + "Export-Quantité-" + nommaquette;
                Exportexcel.OpenExcel(xlapp, workbook, path);
                return(Result.Succeeded);
            }
            else
            {
                return(Result.Failed);
            }
        }