Esempio n. 1
0
        public void Execute()
        {
            //初始化属性
            string targetDirectory = Config.OutPutRoot;

            this.maxTriangleCount_ = int.Parse("100000");
            this.isDisplayName_    = int.Parse("0");
            this.maxPropertyCount_ = int.Parse("100000");
            this.writer_           = new ObjWriter(this, targetDirectory);
            this.Document          = new NavDocument();
            this.PropDocument      = new NavModelNodePropDocument();
            DocumentModels models = this.doc_.Models;

            //遍历所有Model
            foreach (Model model in models)
            {
                ModelItem rootItem = model.RootItem;
                bool      isHidden = rootItem.IsHidden;
                //如果没有隐藏的话
                if (!isHidden)
                {
                    NavModelNode navModelNode = new NavModelNode();
                    this.Document.RootNodes.Add(navModelNode);
                    //访问模型项目
                    this.VisitModelItem(model, rootItem, navModelNode);
                }
            }
            this.WriteModel();
            this.writer_.WriteMtl();
            //this.writer_.WriteDB_Property(this.PropDocument, 2);
            //this.writer_.WriteDb_Tree();
            this.writer_ = null;
        }
        public ActionResult Upload(string id)
        {
            DocumentModels model = new DocumentModels();

            model.NIP = id;
            return(View(model));
        }
Esempio n. 3
0
 public bool CheckExistingDocument(DocumentModels model)
 {
     if (db.Documents.Where(doc => doc.DocumentNo.Equals(model.DocumentNo)).Count() == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
        // implement execute method
        public override int Execute(params string[] parameters)
        {
            // current document
            Document doc = Application.ActiveDocument;
            // model items collection-1
            ModelItemCollection itemCollection = new ModelItemCollection();
            // get current selected items
            ModelItemCollection selectionItems = doc.CurrentSelection.SelectedItems;
            // get appended models
            DocumentModels models = doc.Models;

            // display message
            //string message = "";

            // each model
            foreach (Model model in models)
            {
                // collect all items from the mode1
                // add to model item collection-1
                itemCollection.AddRange(ItemsFromRoot(model));
            }

            // model item collection-2
            ModelItemCollection itemsToColor = new ModelItemCollection();

            // each item from model item collection-1
            foreach (ModelItem item1 in itemCollection)
            {
                // get item1 bounding box
                BoundingBox3D box1 = item1.BoundingBox(true);

                // each item from the current selected items
                foreach (ModelItem item2 in selectionItems)
                {
                    // get item2 bounding box
                    BoundingBox3D box2 = item2.BoundingBox(true);
                    // check intersection of box1 vs box2
                    if (box1.Intersects(box2))
                    {
                        //message += item1.DisplayName + "Intersects " + item2.DisplayName + "\n";
                        // item add to model item collection-2
                        itemsToColor.Add(item1);
                    }
                }
            }
            // change the color of model item collection-2 items
            doc.Models.OverridePermanentColor(itemsToColor, Color.Green);
            //wf.MessageBox.Show(message);
            return(0);
        }
Esempio n. 5
0
        /// <summary>
        /// Return all model items from all models in document
        /// https://forums.autodesk.com/t5/navisworks-api/getting-parameters-of-rootitem-and-subitems/m-p/9463861
        /// </summary>
        static ModelItemCollection FindEveryItem()
        {
            Document doc = Application.ActiveDocument;

            ModelItemCollection allItems = new ModelItemCollection();
            DocumentModels      models   = doc.Models;

            foreach (Model model in models)
            {
                ModelItem rootItem = model.RootItem;
                allItems.AddRange(rootItem.DescendantsAndSelf);
            }
            return(allItems);
        }
Esempio n. 6
0
        // GET: Document
        public ActionResult Index()
        {
            IEnumerable <document> listDocuments      = service.GetMany();
            List <DocumentModels>  listDocumentModels = new List <DocumentModels>();


            foreach (document d in listDocuments)
            {
                DocumentModels dm = new DocumentModels();
                dm.Id   = d.id;
                dm.Name = d.name;
                dm.numberDownloading = d.numberDownloading;
                dm.path = d.path;
                listDocumentModels.Add(dm);
            }
            return(View(listDocumentModels));
        }
Esempio n. 7
0
        public void Execute(Document doc)
        {
            DateTime dt = DateTime.Now;

            DocumentModels models = doc.Models;

            int nModels = models.Count;

            foreach (Model model in models)
            {
                ModelItem rootItem = model.RootItem;
                //Examine( rootItem.DescendantsAndSelf );
            }

            TimeSpan ts = DateTime.Now - dt;
            double   ms = ts.TotalMilliseconds;
        }
Esempio n. 8
0
        //int n = 0;//TEST
        public override int Execute(params string[] parameters)
        {
            //n = 0;//TEST

            Win.MessageBoxResult result = Win.MessageBox.Show("Начать выгрузку FBX по слоям?", "Выгрузка FBX", Win.MessageBoxButton.YesNo);

            if (result == Win.MessageBoxResult.Yes)
            {
                try
                {
                    PluginRecord FBXPluginrecord = Application.Plugins.
                                                   FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks");
                    if (FBXPluginrecord != null)
                    {
                        if (!FBXPluginrecord.IsLoaded)
                        {
                            FBXPluginrecord.LoadPlugin();
                        }

                        NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor;

                        Document doc = Application.ActiveDocument;

                        string fbxPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        string docPath = doc.FileName;
                        if (!String.IsNullOrEmpty(docPath))
                        {
                            fbxPath = Path.GetDirectoryName(docPath);
                        }

                        DocumentModels docModels = doc.Models;
                        ModelItemEnumerableCollection rootItems = docModels.RootItems;
                        ExportByLayers(rootItems, fbxPath, docModels, FBXplugin);

                        Win.MessageBox.Show("Готово", "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information);
                    }
                }
                catch (Exception ex)
                {
                    CommonException(ex, "Ошибка при экспорте в FBX по слоям");
                }
            }

            return(0);
        }
Esempio n. 9
0
        public ActionResult Create(DocumentModels dm)
        {
            try
            {
                document d = new document();
                d.name = dm.Name;
                d.numberDownloading = dm.numberDownloading;
                d.path = dm.path;

                service.Add(d);
                service.Commit();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult AddDocument(CreateDocumentViewModel cdvm, HttpPostedFileBase upload)
        {
            int id = -1;

            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    UserStore <ApplicationUser>   us = new UserStore <ApplicationUser>(db);
                    UserManager <ApplicationUser> um = new UserManager <ApplicationUser>(us);

                    var document = new DocumentModels
                    {
                        Name        = upload.FileName,
                        TimeStamp   = DateTime.Now,
                        ContentType = upload.ContentType,
                    };
                    using (var reader = new System.IO.BinaryReader(upload.InputStream))
                    {
                        document.Contents = reader.ReadBytes(upload.ContentLength);
                    }
                    switch (cdvm.DocumentType)
                    {
                    case CreateDocumentType.Course:
                        db.Courses.FirstOrDefault(c => c.Id == cdvm.Id).Documents.Add(document);
                        db.SaveChanges();
                        return(RedirectToAction("DocumentCourseList", new { id = cdvm.Id }));

                    case CreateDocumentType.Module:
                        db.Modules.FirstOrDefault(c => c.Id == cdvm.Id).Documents.Add(document);
                        db.SaveChanges();
                        return(RedirectToAction("DocumentModuleList", new { id = cdvm.Id }));

                    case CreateDocumentType.Activity:
                        db.Activities.FirstOrDefault(c => c.Id == cdvm.Id).Documents.Add(document);
                        db.SaveChanges();
                        return(RedirectToAction("DocumentActivityList", new { id = cdvm.Id }));
                    }
                }
            }

            return(RedirectToAction("Course", "Teacher", new { id = id }));
        }
Esempio n. 11
0
        public void Add(DocumentModels model)
        {
            try
            {
                //string dateTimeDayNow = DateTime.Now.ToString("ddMMyyyyHHmmss");
                //string dateDayNow = DateTime.Now.ToString("ddMMyyyy");

                if (model.PDF != null)
                {
                    var pathFilePdf = Path.Combine(pathUploads, "Document");
                    var imageName   = Path.GetFileNameWithoutExtension(model.PDF.FileName) + ".webp";

                    db = new BMotionDBEntities();
                    Document docEntity = new Document();
                    docEntity.DocumentNo   = model.DocumentNo;
                    docEntity.NIP          = model.NIP;
                    docEntity.Quota        = model.Quota;
                    docEntity.DocumentFile = imageName;
                    docEntity.ExpDate      = Convert.ToDateTime(model.ExpDate);
                    docEntity.IsVerify     = "Y";
                    docEntity.CreatedDate  = DateTime.Now;
                    docEntity.CreatedBy    = SessionManager.NIP();
                    db.Documents.Add(docEntity);
                    db.SaveChanges();

                    if (!Directory.Exists(pathFilePdf))
                    {
                        System.IO.Directory.CreateDirectory(pathFilePdf);
                    }

                    using (var fileStream = new System.IO.FileStream(pathFilePdf + "\\" + imageName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        model.PDF.InputStream.CopyTo(fileStream);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 12
0
        public override int Execute(params string[] parameters)
        {
            // get document from application
            Document document = Application.ActiveDocument;
            // info message - current file path with appended files
            string message = "Current File : " + document.CurrentFileName +
                             "\nAppend File : ";
            // get appended models from current document
            DocumentModels models = document.Models;

            // each model
            foreach (Model model in models)
            {
                // get filepath with index
                message += "\n         " + (models.IndexOf(model) + 1).ToString() + ". " + model.FileName;
            }
            // display message
            wf.MessageBox.Show(message);
            // int return
            return(0);
        }
        public ActionResult Upload(DocumentModels model)
        {
            try
            {
                if (DocumentLogic.getInstance().CheckExistingDocument(model))
                {
                    DocumentLogic.getInstance().Add(model);
                    TempData["Success"] = "Success saving Data for " + model.NIP;
                }
                else
                {
                    TempData["Error"] = "Document " + model.DocumentNo + " is exist";
                }
            }
            catch (Exception e)
            {
                TempData["Error"] = "Error saving Data for " + model.NIP;
                Logging.Log.getInstance().CreateLogError(e);
            }

            return(RedirectToAction("Detail", "Users", new { id = model.NIP }));
        }
Esempio n. 14
0
        public List <DocumentModels> getAllDocumentByUser(string id)
        {
            DocumentModels        doc    = new DocumentModels();
            List <DocumentModels> dcList = new List <DocumentModels>();
            var list = db.sp_DocumentListByUser(id).ToList();

            foreach (var item in list)
            {
                var docPath = GetDocumentPathByDocNo(item.DocumentNo);
                doc              = new DocumentModels();
                doc.No           = item.No;
                doc.NIP          = id;
                doc.CreatedDate  = item.CreatedDate.Value.ToString("MM/dd/yyyy");
                doc.DocumentNo   = item.DocumentNo;
                doc.ExpDate      = item.ExpDate.Value.ToString("MM/dd/yyyy");
                doc.Quota        = item.Quota;
                doc.IsVerify     = item.Status;
                doc.DocumentFile = item.DocumentName;
                doc.PathDocument = docPath;
                dcList.Add(doc);
            }
            return(dcList);
        }
Esempio n. 15
0
        //using Tuple to return values
        public (double gridXMin, double gridXMax, double gridYMin, double gridYMax) GridCoord()
        {
            Document           document      = Autodesk.Navisworks.Api.Application.ActiveDocument;
            DocumentClash      documentClash = document.GetClash();
            DocumentClashTests allTests      = documentClash.TestsData;
            DocumentModels     docModel      = document.Models;

            DocumentGrids docGrids   = document.Grids;
            GridSystem    docGridSys = docGrids.ActiveSystem;

            List <double> gridXCoord = new List <double>();
            List <double> gridYCoord = new List <double>();

            try
            {
                //get objects in project
                foreach (Model model in docModel)
                {
                    ModelItem root = model.RootItem as ModelItem;

                    string   dn      = root.DisplayName.ToString();
                    string[] disName = dn.Split('_', '-', '.', ' ');

                    //determine source file type by searching model file properties
                    foreach (PropertyCategory oPC in root.PropertyCategories)
                    {
                        if (oPC.DisplayName.ToString() == "Item")
                        {
                            foreach (DataProperty oDP in oPC.Properties)
                            {
                                if (oDP.DisplayName.ToString() == "Source File Name")
                                {
                                    string   val     = oDP.Value.ToDisplayString();
                                    string[] valName = val.Split('.');

                                    //source file is RVT (Revit)
                                    if (valName.Last() == "rvt")
                                    {
                                        foreach (ModelItem item in root.Children)
                                        {
                                            ModelItem subLayer2 = item as ModelItem;

                                            foreach (ModelItem subLaye3 in subLayer2.Children)
                                            {
                                                ModelItem subLayer4 = subLaye3 as ModelItem;

                                                foreach (ModelItem subLayer5 in subLayer4.Children)
                                                {
                                                    ModelItem subLayer6 = subLayer5 as ModelItem;

                                                    foreach (ModelItem subLayer7 in subLayer6.Children)
                                                    {
                                                        ModelItem subLayer8 = subLayer7 as ModelItem;

                                                        foreach (ModelItem subLayer9 in subLayer8.Children)
                                                        {
                                                            //Get object center position (X,Y,Z) by setting a 3D bounding box
                                                            ModelItem subLayer10 = subLayer9 as ModelItem;

                                                            if (subLayer10 != null)
                                                            {
                                                                BoundingBox3D bbox = subLayer10.BoundingBox();

                                                                //find closest grid intersection to object center position using API
                                                                GridIntersection gridCross = docGridSys.ClosestIntersection(bbox.Center);

                                                                //Get closest grid intersection X,Y coord
                                                                gridXCoord.Add(gridCross.Position.X);
                                                                gridYCoord.Add(gridCross.Position.Y);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //if source file is DWG format (AutoCAD)
                                    else if (valName.Last() == "dwg")
                                    {
                                        foreach (ModelItem item in root.Children)
                                        {
                                            ModelItem subLayer2 = item as ModelItem;

                                            foreach (ModelItem subLayer3 in subLayer2.Children)
                                            {
                                                if (subLayer3 != null)
                                                {
                                                    //Get object center position (X,Y,Z) by setting a 3D bounding box
                                                    BoundingBox3D bbox = subLayer3.BoundingBox();

                                                    //find closest grid intersection to object center position using API
                                                    GridIntersection gridCross = docGridSys.ClosestIntersection(bbox.Center);

                                                    //Get closest grid intersection X,Y coord
                                                    gridXCoord.Add(gridCross.Position.X);
                                                    gridYCoord.Add(gridCross.Position.Y);
                                                }
                                            }
                                        }
                                    }
                                    //if file in selection tree is an NWD file
                                    else if (disName.Last() == "nwd")
                                    {
                                        foreach (ModelItem item in root.Children)
                                        {
                                            ModelItem disfile = item as ModelItem;

                                            string   disNwd     = disfile.DisplayName.ToString();
                                            string[] disNameNwd = disNwd.Split('_', '-', '.');

                                            foreach (PropertyCategory oPCnwd in disfile.PropertyCategories)
                                            {
                                                if (oPCnwd.DisplayName.ToString() == "Item")
                                                {
                                                    foreach (DataProperty oDPnwd in oPCnwd.Properties)
                                                    {
                                                        if (oDPnwd.DisplayName.ToString() == "Source File Name")
                                                        {
                                                            string   valNwd     = oDPnwd.Value.ToDisplayString();
                                                            string[] valNameNwd = valNwd.Split('.');

                                                            if (valNameNwd.Last() == "rvt")
                                                            {
                                                                foreach (ModelItem itemNwd in disfile.Children)
                                                                {
                                                                    ModelItem subLayer2Nwd = itemNwd as ModelItem;

                                                                    foreach (ModelItem subLayer3Nwd in subLayer2Nwd.Children)
                                                                    {
                                                                        ModelItem subLayer4Nwd = subLayer3Nwd as ModelItem;

                                                                        foreach (ModelItem subLayer5Nwd in subLayer4Nwd.Children)
                                                                        {
                                                                            ModelItem subLayer6Nwd = subLayer5Nwd as ModelItem;

                                                                            foreach (ModelItem subLayer7Nwd in subLayer6Nwd.Children)
                                                                            {
                                                                                ModelItem subLayer8Nwd = subLayer7Nwd as ModelItem;

                                                                                foreach (ModelItem subLayer9Nwd in subLayer8Nwd.Children)
                                                                                {
                                                                                    if (subLayer9Nwd != null)
                                                                                    {
                                                                                        //Get object center position (X,Y,Z) by setting a 3D bounding box
                                                                                        BoundingBox3D bbox = subLayer9Nwd.BoundingBox();

                                                                                        //find closest grid intersection to object center position using API
                                                                                        GridIntersection gridCross = docGridSys.ClosestIntersection(bbox.Center);

                                                                                        gridXCoord.Add(gridCross.Position.X);
                                                                                        gridYCoord.Add(gridCross.Position.Y);
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                            //Source file is DWG format (AutoCAD)
                                                            else if (valNameNwd.Last() == "dwg")
                                                            {
                                                                foreach (ModelItem itemNwd in disfile.Children)
                                                                {
                                                                    ModelItem subLayer2Nwd = itemNwd as ModelItem;

                                                                    foreach (ModelItem subLayer3Nwd in subLayer2Nwd.Children)
                                                                    {
                                                                        if (subLayer3Nwd != null)
                                                                        {
                                                                            //Get object center position (X,Y,Z) by setting a 3D bounding box
                                                                            BoundingBox3D bbox = subLayer3Nwd.BoundingBox();

                                                                            //find closest grid intersection to object center position using API
                                                                            GridIntersection gridCross = docGridSys.ClosestIntersection(bbox.Center);

                                                                            //Get closest grid intersection X,Y coord
                                                                            gridXCoord.Add(gridCross.Position.X);
                                                                            gridYCoord.Add(gridCross.Position.Y);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //store max & min values to return for scatter plot data
                double gridXMin = gridXCoord.Min();
                double gridXMax = gridXCoord.Max();
                double gridYMin = gridYCoord.Min();
                double gridYMax = gridYCoord.Max();

                return(gridXMin, gridXMax, gridYMin, gridYMax);
            }

            catch (Exception exception)
            {
                MessageBox.Show("Error in Grid Coordinates Analysis!");
                exception.Message.ToString();
            }

            return(0, 0, 0, 0);
        }
Esempio n. 16
0
        public override int Execute(params string[] parameters)
        {
            Win.MessageBoxResult result = Win.MessageBox.Show("Перед экспортом FBX, нужно скрыть те элементы модели, которые не нужно экспортировать. "
                                                              + "А так же нужно настроить параметры экспорта в FBX на экспорт в формате ASCII"
                                                              + "\n\nНачать выгрузку FBX?", "Выгрузка FBX", Win.MessageBoxButton.YesNo);

            if (result == Win.MessageBoxResult.Yes)
            {
                try
                {
                    //ComApi.InwOpState3 oState = ComApiBridge.ComApiBridge.State;

                    PluginRecord FBXPluginrecord = Application.Plugins.
                                                   FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks");
                    if (FBXPluginrecord != null)
                    {
                        if (!FBXPluginrecord.IsLoaded)
                        {
                            FBXPluginrecord.LoadPlugin();
                        }

                        NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor;

                        Document doc = Application.ActiveDocument;

                        string fbxPath        = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        string docPath        = doc.FileName;
                        string defFBXFileName = "";
                        if (!String.IsNullOrEmpty(docPath))
                        {
                            fbxPath        = Path.GetDirectoryName(docPath);
                            defFBXFileName = Path.GetFileNameWithoutExtension(docPath) + ".fbx";
                        }

                        //Указание пользователем имени файла для fbx
                        WinForms.SaveFileDialog sFD = new WinForms.SaveFileDialog();
                        sFD.InitialDirectory = fbxPath;
                        sFD.Filter           = "fbx files (*.fbx)|*.fbx";
                        sFD.FilterIndex      = 1;
                        sFD.RestoreDirectory = true;
                        if (!String.IsNullOrWhiteSpace(defFBXFileName))
                        {
                            sFD.FileName = defFBXFileName;
                        }
                        sFD.Title = "Укажите файл для записи fbx";

                        if (sFD.ShowDialog() == WinForms.DialogResult.OK)
                        {
                            //Выполнить экспорт в FBX
                            if (0 == FBXplugin.Execute(sFD.FileName))
                            {
                                if (IsASCIIFBXFile(sFD.FileName))
                                {
                                    DocumentModels docModels = doc.Models;
                                    ModelItemEnumerableCollection rootItems = docModels.RootItems;

                                    string editedFBXFileName = Common.Utils
                                                               .GetNonExistentFileName(Path.GetDirectoryName(sFD.FileName),
                                                                                       Path.GetFileNameWithoutExtension(sFD.FileName) + "_Edited", "fbx");

                                    fBXCurrObjLine = null;
                                    using (StreamWriter sw = new StreamWriter(editedFBXFileName))
                                    {
                                        using (StreamReader sr = new StreamReader(sFD.FileName))
                                        {
                                            OverwriteFBX(rootItems, sw, sr, false);

                                            //Дописать FBX до конца
                                            sw.Write(sr.ReadToEnd());
                                        }
                                    }

                                    Win.MessageBox.Show("Готово", "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information);
                                }
                                else
                                {
                                    //FBX не ASCII
                                    throw new Exception("FBX не в формате ASCII");
                                }
                            }
                            else
                            {
                                //Ошибки при экспорте
                                throw new Exception("Возникли ошибки при экспорте FBX");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CommonException(ex, "Ошибка при экспорте в FBX");
                }
            }

            return(0);
        }
Esempio n. 17
0
        public override int Execute(params string[] parameters)
        {
            //Obtain user Input for Focus Zone (calls UserInput Form)
            UserInput UIReturn = new UserInput();

            UIReturn.ShowDialog();

            string fz = UIReturn.Returnfz;
            Dictionary <string, string> modDiscipline = UIReturn.Returnpd;

            if (fz == "" || modDiscipline == null)
            {
                //MessageBox.Show("Cancelled Operation");
                return(0);
            }

            Document           document      = Autodesk.Navisworks.Api.Application.ActiveDocument;
            DocumentClash      documentClash = document.GetClash();
            DocumentClashTests allTests      = documentClash.TestsData;
            DocumentModels     docModel      = document.Models;

            List <string> discipline = new List <string>();
            List <int>    objTot     = new List <int>();
            List <string> tradeAll   = new List <string>();
            List <string> focusZone  = new List <string>();
            List <string> testDate   = new List <string>();
            List <string> fileName   = new List <string>();

            Dictionary <string, int> objCnt = new Dictionary <string, int>();

            foreach (string disValue in modDiscipline.Values)
            {
                objCnt.Add(disValue, 0);
                //Add discipline to list by object
                tradeAll.Add(disValue);
            }

            objCnt.Add("Misc", 0);
            tradeAll.Add("Misc");

            try
            {
                string date = "";

                if (allTests.Tests.Count != 0)
                {
                    //Record last date of clash test run
                    ClashTest test = allTests.Tests[0] as ClashTest;

                    if (test.LastRun == null)
                    {
                        date = "No Test Runs";
                    }
                    else
                    {
                        date = test.LastRun.Value.ToShortDateString();
                    }
                }
                else
                {
                    date = "No Test Runs";
                }

                //Record file name
                string file = document.CurrentFileName.ToString();

                if (file == "")
                {
                    file = "File not yet saved.";
                }

                if (docModel.Count != 0)
                {
                    //Count total objects in project
                    foreach (Model model in docModel)
                    {
                        ModelItem root = model.RootItem as ModelItem;

                        foreach (ModelItem item in root.Children)
                        {
                            List <ModelItem> dList = item.DescendantsAndSelf.ToList();

                            foreach (ModelItem subItem in dList)
                            {
                                if (subItem.IsComposite == true || subItem.ClassDisplayName == "Block")
                                {
                                    List <ModelItem> aList = subItem.Ancestors.ToList();

                                    string tradeName = Discipline_Search(aList, modDiscipline);

                                    if (objCnt.ContainsKey(tradeName))
                                    {
                                        objCnt[tradeName] += 1;
                                    }
                                    else
                                    {
                                        objCnt["Misc"] += 1;
                                    }
                                }
                                else if (subItem.IsLayer == true)
                                {
                                    foreach (ModelItem obj in subItem.Children)
                                    {
                                        if (obj.IsInsert == false && obj.IsComposite == false && obj.IsCollection == false && obj.ClassDisplayName != "Block")
                                        {
                                            List <ModelItem> aList = subItem.Ancestors.ToList();

                                            string tradeName = Discipline_Search(aList, modDiscipline);

                                            if (objCnt.ContainsKey(tradeName))
                                            {
                                                objCnt[tradeName] += 1;
                                            }
                                            else
                                            {
                                                objCnt["Misc"] += 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No models currently appended in project." + "\n"
                                    + "Load models first.");
                    return(0);
                }

                //Create Discipline list from each clash by discipline involvement
                foreach (string name in tradeAll)
                {
                    if (!discipline.Contains(name))
                    {
                        discipline.Add(name);
                    }
                }

                //Record user inputted focus zone to total rows
                int fzIdx = 0;
                while (fzIdx < discipline.Count)
                {
                    focusZone.Add(fz);
                    fzIdx++;
                }

                //Record last Test run date to match #rows
                int idxDate = 0;
                while (idxDate < discipline.Count)
                {
                    testDate.Add(date);
                    idxDate++;
                }

                //Record file name to match # of rows
                int idxFile = 0;
                while (idxFile < discipline.Count)
                {
                    fileName.Add(file);
                    idxFile++;
                }

                //Add total trade object counts to objTot List in order of discipline List
                foreach (string name in discipline)
                {
                    if (objCnt.ContainsKey(name))
                    {
                        objTot.Add(objCnt[name]);
                    }
                }

                //Launch or access Excel via COM Interop:
                Excel.Application xlApp = new Excel.Application();
                Excel.Workbook    xlWorkbook;

                if (xlApp == null)
                {
                    MessageBox.Show("Excel is not properly installed!");
                }

                //Create New Workbook & Worksheets
                xlWorkbook = xlApp.Workbooks.Add(Missing.Value);
                Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
                xlWorksheet.Name = "Total Objects by Trade";

                //Label Column Headers - Total Objects Worksheet
                xlWorksheet.Cells[1, 1] = "Date";
                xlWorksheet.Cells[1, 2] = "Discipline";
                xlWorksheet.Cells[1, 3] = "Total Objects";
                xlWorksheet.Cells[1, 4] = "Focus Zone";
                xlWorksheet.Cells[1, 5] = "File";

                int counterDate = 2;
                foreach (string day in testDate)
                {
                    string cellName = "A" + counterDate.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = day;
                    counterDate++;
                }

                int counterDis = 2;
                foreach (string valueDis in discipline)
                {
                    string cellName = "B" + counterDis.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueDis;
                    counterDis++;
                }

                int counterObj = 2;
                foreach (int valueObj in objTot)
                {
                    string cellName = "C" + counterObj.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueObj;
                    counterObj++;
                }

                int counterFz = 2;
                foreach (string valueFz in focusZone)
                {
                    string cellName = "D" + counterFz.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueFz;
                    counterFz++;
                }

                int fileNameCount = 2;
                foreach (string fName in fileName)
                {
                    string cellName = "E" + fileNameCount.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = fName;
                    fileNameCount++;
                }

                //Locate Excel file save location
                string modDate = "";

                if (allTests.Tests.Count != 0)
                {
                    string[] clashDate = testDate[0].Split('/');

                    if (clashDate[0].Length == 1)
                    {
                        clashDate[0] = "0" + clashDate[0];
                    }

                    if (clashDate[1].Length == 1)
                    {
                        clashDate[1] = "0" + clashDate[1];
                    }
                    modDate = clashDate[2] + clashDate[0] + clashDate[1];
                }
                else
                {
                    modDate = "YYYYMMDD";
                }

                SaveFileDialog saveClashData = new SaveFileDialog();

                saveClashData.Title    = "Save to...";
                saveClashData.Filter   = "Excel Workbook | *.xlsx|Excel 97-2003 Workbook | *.xls";
                saveClashData.FileName = modDate + "-Total_Objects_Data-" + focusZone[0].ToString();

                if (saveClashData.ShowDialog() == DialogResult.OK)
                {
                    string path = saveClashData.FileName;
                    xlWorkbook.SaveCopyAs(path);
                    xlWorkbook.Saved = true;
                    xlWorkbook.Close(true, Missing.Value, Missing.Value);
                    xlApp.Quit();
                }

                xlApp.Visible = false;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error! Original Message: " + exception.Message);
            }

            return(0);
        }
Esempio n. 18
0
        public override int Execute(params string[] ps)
        {
            Document doc             = Application.ActiveDocument;
            string   currentFilename = doc.CurrentFileName;
            string   filename        = doc.FileName;
            string   title           = doc.Title;

            Units            units          = doc.Units;
            DocumentModels   models         = doc.Models;
            DocumentInfoPart info           = doc.DocumentInfo;
            string           currentSheetId = info.Value.CurrentSheetId; // "little_house_2021.rvt"
            DocumentDatabase db             = doc.Database;
            bool             ignoreHidden   = true;
            BoundingBox3D    bb             = doc.GetBoundingBox(ignoreHidden);
            Point3D          min            = bb.Min;
            Point3D          max            = bb.Max;
            int nModels = models.Count;

            Debug.Print("{0}: sheet {1}, bounding box {2}, {3} model{4}{5}",
                        title, currentSheetId, Util.BoundingBoxString(bb),
                        nModels, Util.PluralSuffix(nModels), Util.DotOrColon(nModels));

            // First attempt, based on Navisworks-Geometry-Primitives,
            // using walkNode oState.CurrentPartition:

            //WalkPartition wp = new WalkPartition();
            //wp.Execute();

            List <string> Categories = new List <string>();

            foreach (Model model in models)
            {
                ModelItem rootItem = model.RootItem;
                ModelItemEnumerableCollection mis = rootItem.DescendantsAndSelf;
                Debug.Print("  {0}: {1} model items", model.FileName, mis.Count());
                List <ModelItem> migeos = new List <ModelItem>();
                foreach (ModelItem mi in mis)
                {
                    Debug.Print(
                        "    '{0}' '{1}' '{2}' has geo {3}",
                        mi.DisplayName, mi.ClassDisplayName,
                        mi.ClassName, mi.HasGeometry);

                    if (mi.HasGeometry)
                    {
                        migeos.Add(mi);
                    }
                }
                Debug.Print("  {0} model items have geometry:", migeos.Count());
                foreach (ModelItem mi in migeos)
                {
                    Debug.Print(
                        "    '{0}' '{1}' '{2}' {3} bb {4}",
                        mi.DisplayName, mi.ClassDisplayName,
                        mi.ClassName, mi.HasGeometry,
                        Util.BoundingBoxString(mi.BoundingBox()));

                    if ("Floor" == mi.DisplayName)
                    {
                        RvtProperties.DumpProperties(mi);
                        RvtProperties props = new RvtProperties(mi);
                        int           id    = props.ElementId;
                    }
                }
            }
            return(0);
        }
Esempio n. 19
0
        public override int Execute(params string[] parameters)
        {
            Win.MessageBoxResult result = Win.MessageBoxResult.Yes;
            if (ManualUse)
            {
                result = Win.MessageBox.Show("Перед экспортом FBX, нужно скрыть те элементы модели, которые не нужно экспортировать. "
                                             + "А так же нужно настроить параметры экспорта в FBX на экспорт ЛИБО В ФОРМАТЕ ASCII, ЛИБО В ДВОИЧНОМ ФОРМАТЕ ВЕРСИИ НЕ НОВЕЕ 2018. "
                                             + "Рекомендуется так же отключить экспорт источников света и камер. "
                                             + "\n\nНачать выгрузку FBX?", "Выгрузка FBX", Win.MessageBoxButton.YesNo);
            }



            if (result == Win.MessageBoxResult.Yes)
            {
                try
                {
                    PluginRecord FBXPluginrecord = Application.Plugins.
                                                   FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks");
                    if (FBXPluginrecord != null)
                    {
                        if (!FBXPluginrecord.IsLoaded)
                        {
                            FBXPluginrecord.LoadPlugin();
                        }

                        NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor;

                        Document doc = Application.ActiveDocument;

                        string fbxPath        = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        string docPath        = doc.FileName;
                        string defFBXFileName = "";
                        if (!String.IsNullOrEmpty(docPath))
                        {
                            fbxPath        = Path.GetDirectoryName(docPath);
                            defFBXFileName = Path.GetFileNameWithoutExtension(docPath) + ".fbx";
                        }

                        //Указание пользователем имени файла для fbx
                        string fbxFullFileName = null;
                        if (ManualUse)
                        {
                            WinForms.SaveFileDialog sFD = new WinForms.SaveFileDialog();
                            sFD.InitialDirectory = fbxPath;
                            sFD.Filter           = "fbx files (*.fbx)|*.fbx";
                            sFD.FilterIndex      = 1;
                            sFD.RestoreDirectory = true;
                            if (!String.IsNullOrWhiteSpace(defFBXFileName))
                            {
                                sFD.FileName = defFBXFileName;
                            }
                            sFD.Title = "Укажите файл для записи fbx";
                            if (sFD.ShowDialog() == WinForms.DialogResult.OK)
                            {
                                fbxFullFileName = sFD.FileName;
                            }
                        }
                        else
                        {
                            fbxFullFileName = FBXSavePath;
                            FileAttributes attr = File.GetAttributes(fbxFullFileName);
                            if (attr.HasFlag(FileAttributes.Directory))
                            {
                                //добавить имя файла
                                fbxFullFileName = Path.Combine(fbxFullFileName, FBXFileName);
                            }
                        }


                        if (!String.IsNullOrEmpty(fbxFullFileName))
                        {
                            string notEditedDirectory = Path.Combine(Path.GetDirectoryName(fbxFullFileName), "NotEdited");
                            if (!Directory.Exists(notEditedDirectory))
                            {
                                Directory.CreateDirectory(notEditedDirectory);
                            }
                            string notEditedFileName = Path.Combine(notEditedDirectory,
                                                                    Path.GetFileName(fbxFullFileName));

                            if (ManualUse)
                            {
                                BusyIndicatorHelper.ShowBusyIndicator();
                                BusyIndicatorHelper.SetMessage("Стандартный экспорт FBX");
                            }


                            if (FBXplugin.Execute(notEditedFileName) == 0)//Выполнить экспорт в FBX
                            {
                                if (ManualUse)
                                {
                                    BusyIndicatorHelper.SetMessage("Редактирование FBX");
                                }

                                bool isASCII = IsASCIIFBXFile(notEditedFileName);
                                if (isASCII || GetBinaryVersionNum(notEditedFileName) <= 7500)
                                {
                                    //Прочитать модель, составить очередь имен для подстановки в FBX
                                    Queue <FBX.NameReplacement> replacements = new Queue <FBX.NameReplacement>();
                                    DocumentModels docModels = doc.Models;
                                    ModelItemEnumerableCollection rootItems = docModels.RootItems;
                                    //if (rootItems.Count() > 1)
                                    //{
                                    //    //Если в Navis несколько корневых узлов (как в nwf),
                                    //    //то один узел в самом начале FBX должен быть пропущен
                                    //    //Там появится узел Environment
                                    //    replacements.Enqueue(new FBX.NameReplacement());
                                    //}
                                    ComApi.InwOpState3 oState = ComApiBridge.ComApiBridge.State;
                                    NameReplacementQueue(rootItems, replacements, oState);
                                    if (rootItems.Count() == 1)
                                    {
                                        //Обозначить, что первый узел имеет ненадежное имя.
                                        //В FBX оно всегда - Environment, а в Navis - имя открытого файла
                                        //replacements.Peek().OldNameTrustable = false;

                                        //Если корневой узел один, то убрать его из списка. Его не будет в FBX
                                        replacements.Dequeue();
                                    }

                                    //Первый узел в списке замены должен обязательно иметь верное имя
                                    //(в начале списка могут быть с пустым значением, которые отключены в Navis)
                                    while (!replacements.Peek().OldNameTrustable)
                                    {
                                        replacements.Dequeue();
                                    }


                                    //Отредактировать FBX
                                    FBX.ModelNamesEditor fbxEditor = null;
                                    if (IsASCIIFBXFile(notEditedFileName))
                                    {
                                        fbxEditor = new FBX.ASCIIModelNamesEditor(notEditedFileName, replacements);
                                    }
                                    else /*if (GetBinaryVersionNum(sFD.FileName) <= 7500)*/
                                    {
                                        fbxEditor = new FBX.BinaryModelNamesEditor(notEditedFileName, replacements);
                                    }
                                    fbxEditor.FbxFileNameEdited = fbxFullFileName;
                                    fbxEditor.EditModelNames();



                                    if (ManualUse)
                                    {
                                        BusyIndicatorHelper.CloseBusyIndicator();
                                        Win.MessageBox.Show("Файл FBX с отредактированными именами моделей - " + fbxEditor.FbxFileNameEdited,
                                                            "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information);
                                    }
                                }
                                else
                                {
                                    throw new Exception("Неподдерживаемый формат FBX");
                                }
                            }
                            else
                            {
                                throw new Exception("При экспорте FBX из NavisWorks произошли ошибки");
                            }


                            if (ManualUse)
                            {
                                //на всякий случай
                                BusyIndicatorHelper.CloseBusyIndicator();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CommonException(ex, "Ошибка при экспорте в FBX из Navis");
                }
            }

            return(0);
        }
Esempio n. 20
0
        public ActionResult Index()
        {
            DocumentModels model = new DocumentModels();

            return(View(model));
        }
Esempio n. 21
0
        /// <summary>
        /// Нужно пройти по дереву до уровня слоев и затем выполнять выгрузку
        /// Слои раскладывать по папкам в соответствии с названиями файлов и вложенностью файлов
        /// </summary>
        /// <param name="items"></param>
        private void ExportByLayers(ModelItemEnumerableCollection items, string fbxPath, DocumentModels docModels, NativeExportPluginAdaptor FBXplugin)
        {
            //if (n < 20)//TEST
            //{
            int n = 0;

            foreach (ModelItem item in items)
            {
                //Скрывать все кроме текущего элемента
                docModels.SetHidden(items, true);
                docModels.SetHidden(new List <ModelItem> {
                    item
                }, false);
                //item.is

                //Нужно проверить, что у объекта нет свойства путь к источнику
                DataProperty sourceProp = item.PropertyCategories.FindPropertyByName("LcOaNode", "LcOaPartitionSourceFilename");


                if (sourceProp == null)
                {
                    //Выполнять выгрузку
                    if (!Directory.Exists(fbxPath))
                    {
                        Directory.CreateDirectory(fbxPath);
                    }

                    string name = item.DisplayName;
                    if (String.IsNullOrEmpty(name))//Если у объекта нет имени, то подставить цифру
                    {
                        name = n.ToString();
                        n++;
                    }

                    name = name + ".fbx";
                    name = Common.Utils.GetSafeFilename(name);

                    string fileName = Path.Combine(fbxPath, name);
                    if (!File.Exists(fileName))
                    {
                        FBXplugin.Execute(fileName);
                    }

                    //n++;//TEST
                }
                else
                {
                    //Дополнить путь выгрузки новой папкой
                    string name = item.DisplayName;
                    name = Common.Utils.GetSafeFilename(name);
                    name = Path.GetFileNameWithoutExtension(name);
                    string fbxPathToChildren = Path.Combine(fbxPath, name);
                    //Рекурсивный вызов
                    ExportByLayers(item.Children, fbxPathToChildren, docModels, FBXplugin);
                }
            }
            //}
        }
        public override int Execute(params string[] parameters)
        {
            //Obtain user Input for Focus Zone (calls UserInput Form)
            UserInput UIReturn = new UserInput();

            UIReturn.ShowDialog();

            string fz = UIReturn.Returnfz;
            Dictionary <string, string> trade = UIReturn.Returnpd;

            if (fz == "" || trade == null)
            {
                //MessageBox.Show("Cancelled Operation");
                return(0);
            }

            //Initialize Objects
            List <string> testName       = new List <string>();
            List <int>    resultNew      = new List <int>();
            List <int>    resultActive   = new List <int>();
            List <int>    resultReviewed = new List <int>();
            List <int>    resultApproved = new List <int>();
            List <int>    resultResolved = new List <int>();
            List <string> testDate       = new List <string>();
            List <string> fileName       = new List <string>();
            List <string> sumTestDate    = new List <string>();

            List <string> tradeStatus      = new List <string>();
            List <string> tradeClash       = new List <string>();
            List <string> tradeDiscipline1 = new List <string>();
            List <string> tradeDiscipline2 = new List <string>();
            List <string> tradeDate        = new List <string>();
            List <string> tradeFile        = new List <string>();
            List <string> tradeAll         = new List <string>();
            List <string> clashAssignTo    = new List <string>();
            List <string> clashApprovedBy  = new List <string>();
            List <string> clashApproveTime = new List <string>();
            List <string> clashDescription = new List <string>();
            List <string> discipline       = new List <string>();
            List <string> indiTest         = new List <string>();
            List <double> indiCoordX       = new List <double>();
            List <double> indiCoordY       = new List <double>();
            List <double> indiCoordZ       = new List <double>();
            List <string> focusZone        = new List <string>();
            List <string> level            = new List <string>();
            List <double> lvlElev          = new List <double>();
            List <string> clashLevel       = new List <string>();
            List <double> gridXMinCoord    = new List <double>();
            List <double> gridXMaxCoord    = new List <double>();
            List <double> gridYMinCoord    = new List <double>();
            List <double> gridYMaxCoord    = new List <double>();

            string tradeName1 = "";
            string tradeName2 = "";

            int countNew      = 0;
            int countActive   = 0;
            int countReviewed = 0;
            int countApproved = 0;
            int countResolved = 0;

            try
            {
                Document           document      = Autodesk.Navisworks.Api.Application.ActiveDocument;
                DocumentClash      documentClash = document.GetClash();
                DocumentClashTests allTests      = documentClash.TestsData;
                DocumentModels     docModel      = document.Models;

                DocumentGrids docGrids   = document.Grids;
                GridSystem    docGridSys = docGrids.ActiveSystem;

                foreach (GridLevel lvl in docGridSys.Levels)
                {
                    level.Add(lvl.DisplayName);
                    lvlElev.Add(lvl.Elevation);
                }

                //-----------------------------------------------------------------------------------------//
                //Check if Clash Test have even been created
                //If no clash tests created, exit program
                int check = allTests.Tests.Count;
                if (check == 0)
                {
                    MessageBox.Show("No clash tests currently exist!");
                    return(0);
                }
                //-----------------------------------------------------------------------------------------//

                //-----------------------------------------------------------------------------------------//
                //Begin storing clash data by created tests
                foreach (ClashTest test in allTests.Tests)
                {
                    testName.Add(test.DisplayName);

                    //Reset Clash Status counts per test in Clash Detective Summary.  Matches Results tab in Clash Detective (ungrouped clashes)
                    countNew      = 0;
                    countActive   = 0;
                    countReviewed = 0;
                    countApproved = 0;
                    countResolved = 0;

                    if (test.LastRun == null)
                    {
                        sumTestDate.Add("No Test Runs");
                    }
                    else
                    {
                        sumTestDate.Add(test.LastRun.Value.ToShortDateString());
                    }

                    //Count number of instances per Clash Status
                    //(based on how user grouped clashes)
                    foreach (SavedItem issue in test.Children)
                    {
                        ClashResultGroup group = issue as ClashResultGroup;

                        //Check if clash groups exist.  If null, clash result is not grouped
                        if (null != group)
                        {
                            foreach (SavedItem subissue in group.Children)
                            {
                                ClashResult item = subissue as ClashResult;

                                //Checking if Item1 is null (due to resolved) and need to use Selection-A
                                if (item.Item1 != null)
                                {
                                    List <ModelItem> lItem1 = item.Item1.Ancestors.ToList();

                                    tradeName1 = ClashDiscipline_Search(lItem1, trade);
                                }
                                else
                                {
                                    ModelItemCollection oSelA  = test.SelectionA.Selection.GetSelectedItems();
                                    List <ModelItem>    lItemA = new List <ModelItem>();

                                    if (oSelA.First.HasModel == true)
                                    {
                                        lItemA.Add(oSelA.First);
                                    }
                                    else
                                    {
                                        lItemA = oSelA.First.Ancestors.ToList();
                                    }

                                    tradeName1 = ClashDiscipline_Search(lItemA, trade);
                                }

                                //Checking if Item2 is null (due to resolved) and need to use Selection-B
                                if (item.Item2 != null)
                                {
                                    List <ModelItem> lItem2 = item.Item2.Ancestors.ToList();

                                    tradeName2 = ClashDiscipline_Search(lItem2, trade);
                                }
                                else
                                {
                                    ModelItemCollection oSelB  = test.SelectionB.Selection.GetSelectedItems();
                                    List <ModelItem>    lItemB = new List <ModelItem>();
                                    //MessageBox.Show(oSelB.First.DisplayName);

                                    if (oSelB.First.HasModel == true)
                                    {
                                        lItemB.Add(oSelB.First);
                                    }
                                    else
                                    {
                                        lItemB = oSelB.First.Ancestors.ToList();
                                    }

                                    tradeName2 = ClashDiscipline_Search(lItemB, trade);
                                }

                                //Prompt User when no Discipline match found
                                //User may be missing a discipline/trade in initial input
                                if (tradeName1 == "" || tradeName2 == "")
                                {
                                    MessageBox.Show("Discipline Missing.  Check Project Disciplines Input File (.txt)." + "\n"
                                                    + "Clash Test: " + test.DisplayName + "\n"
                                                    + "Clash Name: " + item.DisplayName + "\n"
                                                    + "Discipline 1: " + tradeName1 + "\n"
                                                    + "Discipline 2: " + tradeName2);

                                    return(0);
                                }

                                //Store Individual Clash Data
                                testDate.Add(test.LastRun.Value.ToShortDateString());
                                indiTest.Add(test.DisplayName);
                                focusZone.Add(fz);
                                tradeDiscipline1.Add(tradeName1);
                                tradeDiscipline2.Add(tradeName2);
                                tradeClash.Add(item.DisplayName.ToString());
                                tradeStatus.Add(item.Status.ToString());
                                indiCoordX.Add(item.Center.X);
                                indiCoordY.Add(item.Center.Y);
                                indiCoordZ.Add(item.Center.Z);
                                fileName.Add(document.CurrentFileName.ToString());
                                clashAssignTo.Add(item.AssignedTo);
                                clashApprovedBy.Add(item.ApprovedBy);
                                clashApproveTime.Add(item.ApprovedTime.ToString());
                                clashDescription.Add(item.Description);

                                if (test.LastRun == null)
                                {
                                    testDate.Add("Test Not Run");
                                }
                                else
                                {
                                    tradeDate.Add(test.LastRun.Value.ToShortDateString());
                                }

                                tradeFile.Add(document.CurrentFileName.ToString());

                                //for Clash Summary
                                if (null != item && item.Status.ToString() == "New")
                                {
                                    countNew = countNew + 1;
                                }
                                else if (null != item && item.Status.ToString() == "Active")
                                {
                                    countActive = countActive + 1;
                                }
                                else if (null != item && item.Status.ToString() == "Reviewed")
                                {
                                    countReviewed = countReviewed + 1;
                                }
                                else if (null != item && item.Status.ToString() == "Approved")
                                {
                                    countApproved = countApproved + 1;
                                }
                                else
                                {
                                    countResolved = countResolved + 1;
                                }
                            }
                        }
                        else
                        {
                            ClashResult rawItem = issue as ClashResult;

                            //Checking if Item1 is null (due to resolved) and need to use Selection-A
                            if (rawItem.Item1 != null)
                            {
                                List <ModelItem> lItem1 = rawItem.Item1.Ancestors.ToList();

                                tradeName1 = ClashDiscipline_Search(lItem1, trade);
                            }
                            else
                            {
                                ModelItemCollection oSelA  = test.SelectionA.Selection.GetSelectedItems();
                                List <ModelItem>    lItemA = new List <ModelItem>();

                                if (oSelA.First.HasModel == true)
                                {
                                    lItemA.Add(oSelA.First);
                                }
                                else
                                {
                                    lItemA = oSelA.First.Ancestors.ToList();
                                }

                                tradeName1 = ClashDiscipline_Search(lItemA, trade);
                            }

                            //Checking if Item1 is null (due to resolved) and need to use Selection-B
                            if (rawItem.Item2 != null)
                            {
                                List <ModelItem> lItem2 = rawItem.Item2.Ancestors.ToList();

                                tradeName2 = ClashDiscipline_Search(lItem2, trade);
                            }
                            else
                            {
                                ModelItemCollection oSelB  = test.SelectionB.Selection.GetSelectedItems();
                                List <ModelItem>    lItemB = new List <ModelItem>();

                                if (oSelB.First.HasModel == true)
                                {
                                    lItemB.Add(oSelB.First);
                                }
                                else
                                {
                                    lItemB = oSelB.First.Ancestors.ToList();
                                }

                                tradeName2 = ClashDiscipline_Search(lItemB, trade);
                            }

                            if (tradeName1 == "" || tradeName2 == "")
                            {
                                MessageBox.Show("Discipline Missing.  Check Project Disciplines Input File (.txt)." + "\n"
                                                + "Clash Test: " + test.DisplayName + "\n"
                                                + "Clash Name: " + rawItem.DisplayName + "\n"
                                                + "Discipline 1: " + tradeName1 + "\n"
                                                + "Discipline 2: " + tradeName2);

                                return(0);
                            }

                            //write to second sheet by discipline involvement
                            testDate.Add(test.LastRun.Value.ToShortDateString());
                            indiTest.Add(test.DisplayName);
                            focusZone.Add(fz);
                            tradeDiscipline1.Add(tradeName1);
                            tradeDiscipline2.Add(tradeName2);
                            tradeClash.Add(rawItem.DisplayName.ToString());
                            tradeStatus.Add(rawItem.Status.ToString());
                            tradeFile.Add(document.CurrentFileName.ToString());
                            indiCoordX.Add(rawItem.Center.X);
                            indiCoordY.Add(rawItem.Center.Y);
                            indiCoordZ.Add(rawItem.Center.Z);
                            fileName.Add(document.CurrentFileName.ToString());
                            clashAssignTo.Add(rawItem.AssignedTo);
                            clashApprovedBy.Add(rawItem.ApprovedBy);
                            clashApproveTime.Add(rawItem.ApprovedTime.ToString());
                            clashDescription.Add(rawItem.Description);

                            if (test.LastRun == null)
                            {
                                testDate.Add("Test Not Run");
                            }
                            else
                            {
                                tradeDate.Add(test.LastRun.Value.ToShortDateString());
                            }

                            if (rawItem.Status.ToString() == "New")
                            {
                                countNew = countNew + 1;
                            }
                            else if (rawItem.Status.ToString() == "Active")
                            {
                                countActive = countActive + 1;
                            }
                            else if (rawItem.Status.ToString() == "Reviewed")
                            {
                                countReviewed = countReviewed + 1;
                            }
                            else if (rawItem.Status.ToString() == "Approved")
                            {
                                countApproved = countApproved + 1;
                            }
                            else
                            {
                                countResolved = countResolved + 1;
                            }
                        }
                    }

                    //inputs values into Clash Status List by Test
                    resultNew.Add(countNew);
                    resultActive.Add(countActive);
                    resultReviewed.Add(countReviewed);
                    resultApproved.Add(countApproved);
                    resultResolved.Add(countResolved);
                }

                //-----------------------------------------------------------------------------------------//
                //call grid intersection function to return min and max grid coordinate values
                GridIntersectCoord gridValueReturn = new GridIntersectCoord();

                var gridCoordValues = gridValueReturn.GridCoord();

                double gridXMin = gridCoordValues.gridXMin;
                double gridXMax = gridCoordValues.gridXMax;
                double gridYMin = gridCoordValues.gridYMin;
                double gridYMax = gridCoordValues.gridYMax;

                foreach (string clash in tradeClash)
                {
                    gridXMinCoord.Add(gridXMin);
                    gridXMaxCoord.Add(gridXMax);
                    gridYMinCoord.Add(gridYMin);
                    gridYMaxCoord.Add(gridYMax);
                }
                //-----------------------------------------------------------------------------------------//

                //-----------------------------------------------------------------------------------------//
                //Record level clashes occur for Clash Level
                int clashIdx = 0; int cnt1 = 0;

                while (clashIdx < indiCoordZ.Count)
                {
                    int  lvlIdx    = 0;
                    bool lvlAssign = false;

                    while (lvlIdx < level.Count && lvlAssign == false)
                    {
                        if (indiCoordZ[clashIdx] >= lvlElev[lvlIdx] && indiCoordZ[clashIdx] < lvlElev[lvlIdx + 1])
                        {
                            clashLevel.Add(level[lvlIdx]);
                            lvlAssign = true;
                            cnt1++;
                        }
                        else if (lvlIdx == level.Count - 1 && indiCoordZ[clashIdx] >= lvlElev[lvlIdx])
                        {
                            clashLevel.Add(level[lvlIdx]);
                            lvlAssign = true;
                            cnt1++;
                        }
                        else if (lvlIdx == 0 && indiCoordZ[clashIdx] < lvlElev[lvlIdx])
                        {
                            clashLevel.Add("UNDERGROUND");
                            lvlAssign = true;
                            cnt1++;
                        }
                        lvlIdx++;
                    }
                    clashIdx++;
                }
                //-----------------------------------------------------------------------------------------//

                //-----------------------------------------------------------------------------------------//
                //Totals current Open(New + Active), Closed(Resolved + Approved), Field Coordinate(Reviewed)
                int totOpen     = resultNew.Aggregate((a, b) => a + b) + resultActive.Aggregate((a, b) => a + b);
                int totClosed   = resultResolved.Aggregate((a, b) => a + b) + resultApproved.Aggregate((a, b) => a + b);
                int totReviewed = resultReviewed.Aggregate((a, b) => a + b);
                int totNew      = resultNew.Aggregate((a, b) => a + b);
                int totActive   = resultActive.Aggregate((a, b) => a + b);
                int totApproved = resultApproved.Aggregate((a, b) => a + b);
                int totResolved = resultResolved.Aggregate((a, b) => a + b);
                //-----------------------------------------------------------------------------------------//

                //-----------------------------------------------------------------------------------------//
                //Launch or access Excel via COM Interop:
                Excel.Application xlApp = new Excel.Application();
                Excel.Workbook    xlWorkbook;

                if (xlApp == null)
                {
                    MessageBox.Show("Excel is not properly installed!");
                }

                //Create New Workbook & Worksheets
                xlWorkbook = xlApp.Workbooks.Add(Missing.Value);
                Excel.Worksheet xlWorksheet       = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
                Excel.Worksheet xlWorksheet_trade = (Excel.Worksheet)xlWorkbook.Worksheets.Add();
                xlWorksheet.Name       = "Clash Detective Summary";
                xlWorksheet_trade.Name = "Individual Clashes";

                //Label Column Headers - Summary Worksheet
                xlWorksheet.Cells[1, 1]  = "Test Date";
                xlWorksheet.Cells[1, 2]  = "Test Name";
                xlWorksheet.Cells[1, 3]  = "New";
                xlWorksheet.Cells[1, 4]  = "Active";
                xlWorksheet.Cells[1, 5]  = "Reviewed";
                xlWorksheet.Cells[1, 6]  = "Approved";
                xlWorksheet.Cells[1, 7]  = "Resolved";
                xlWorksheet.Cells[1, 9]  = "Total New";
                xlWorksheet.Cells[1, 10] = "Total Active";
                xlWorksheet.Cells[1, 11] = "Total Reviewed";
                xlWorksheet.Cells[1, 12] = "Total Approved";
                xlWorksheet.Cells[1, 13] = "Total Resolved";
                xlWorksheet.Cells[1, 15] = "Total Open (New + Active)";
                xlWorksheet.Cells[1, 16] = "Total Closed (Approved + Resolved)";
                xlWorksheet.Cells[1, 17] = "Total Deferred to Field Coordination (Reviewed)";

                //Label Column Headers - Worksheet By Trade Involvement
                xlWorksheet_trade.Cells[1, 1]        = "Date";
                xlWorksheet_trade.Cells[1, 2]        = "Focus Zone";
                xlWorksheet_trade.Cells[1, 3]        = "Test Name";
                xlWorksheet_trade.Cells[1, 4]        = "Discipline 1";
                xlWorksheet_trade.Cells[1, 5]        = "Discipline 2";
                xlWorksheet_trade.Cells[1, 6]        = "Clash";
                xlWorksheet_trade.Cells[1, 7]        = "Clash Level";
                xlWorksheet_trade.Cells[1, 8]        = "Status";
                xlWorksheet_trade.Cells.Cells[1, 9]  = "Clash Location (X)";
                xlWorksheet_trade.Cells.Cells[1, 10] = "Clash Location (Y)";
                xlWorksheet_trade.Cells.Cells[1, 11] = "Clash Location (Z)";
                xlWorksheet_trade.Cells.Cells[1, 12] = "Min X Grid Coordinate";
                xlWorksheet_trade.Cells.Cells[1, 13] = "Min Y Grid Coordinate";
                xlWorksheet_trade.Cells.Cells[1, 14] = "Max X Grid Coordinate";
                xlWorksheet_trade.Cells.Cells[1, 15] = "Max Y Grid Coordinate";
                xlWorksheet_trade.Cells.Cells[1, 16] = "File Path";
                xlWorksheet_trade.Cells.Cells[1, 17] = "Assigned To";
                xlWorksheet_trade.Cells.Cells[1, 18] = "Approved By";
                xlWorksheet_trade.Cells.Cells[1, 19] = "Approved Time";
                xlWorksheet_trade.Cells.Cells[1, 20] = "Description";


                //write clash statuses to excel file by Test
                int counterSumDate = 2;
                foreach (string name in sumTestDate)
                {
                    string cellName = "A" + counterSumDate.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = name;
                    counterSumDate++;
                }

                int counterTest = 2;
                foreach (string name in testName)
                {
                    string cellName = "B" + counterTest.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = name;
                    counterTest++;
                }

                int counterNew = 2;
                foreach (int valueNew in resultNew)
                {
                    string cellName = "C" + counterNew.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueNew;
                    counterNew++;
                }

                int counterActive = 2;
                foreach (int valueActive in resultActive)
                {
                    string cellName = "D" + counterActive.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueActive;
                    counterActive++;
                }

                int counterReviewed = 2;
                foreach (int valueReviewed in resultReviewed)
                {
                    string cellName = "E" + counterReviewed.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueReviewed;
                    counterReviewed++;
                }

                int counterApproved = 2;
                foreach (int valueApproved in resultApproved)
                {
                    string cellName = "F" + counterApproved.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueApproved;
                    counterApproved++;
                }

                int counterResolved = 2;
                foreach (int valueResolved in resultResolved)
                {
                    string cellName = "G" + counterResolved.ToString();
                    var    range    = xlWorksheet.get_Range(cellName, cellName);
                    range.Value2 = valueResolved;
                    counterResolved++;
                }

                //write totals Open, Closed, Field Coordinate to Cells
                xlWorksheet.Cells[2, 9]  = totNew;
                xlWorksheet.Cells[2, 10] = totActive;
                xlWorksheet.Cells[2, 11] = totReviewed;
                xlWorksheet.Cells[2, 12] = totApproved;
                xlWorksheet.Cells[2, 13] = totResolved;
                xlWorksheet.Cells[2, 15] = totOpen;
                xlWorksheet.Cells[2, 16] = totClosed;
                xlWorksheet.Cells[2, 17] = totReviewed;

                //Complete Data on Worksheet (per Discipline Clash Involvement)
                int tradeDateCount = 2;
                foreach (string date in tradeDate)
                {
                    string cellName = "A" + tradeDateCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = date;
                    tradeDateCount++;
                }

                int counterFz = 2;
                foreach (string valueFz in focusZone)
                {
                    string cellName = "B" + counterFz.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = valueFz;
                    counterFz++;
                }

                int testNameCount = 2;
                foreach (string tn in indiTest)
                {
                    string cellName = "C" + testNameCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = tn;
                    testNameCount++;
                }

                int dis1Count = 2;
                foreach (string dis1 in tradeDiscipline1)
                {
                    string cellName = "D" + dis1Count.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = dis1;
                    dis1Count++;
                }

                int dis2Count = 2;
                foreach (string dis2 in tradeDiscipline2)
                {
                    string cellName = "E" + dis2Count.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = dis2;
                    dis2Count++;
                }

                int tradeClashCount = 2;
                foreach (string clash in tradeClash)
                {
                    string cellName = "F" + tradeClashCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = clash;
                    tradeClashCount++;
                }

                int levelCount = 2;
                foreach (string lvl in clashLevel)
                {
                    string cellName = "G" + levelCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = lvl;
                    levelCount++;
                }

                int tradeStatusCount = 2;
                foreach (string status in tradeStatus)
                {
                    string cellName = "H" + tradeStatusCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = status;
                    tradeStatusCount++;
                }

                int coordXCount = 2;
                foreach (double x in indiCoordX)
                {
                    string cellName = "I" + coordXCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = x;
                    coordXCount++;
                }

                int coordYCount = 2;
                foreach (double y in indiCoordY)
                {
                    string cellName = "J" + coordYCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = y;
                    coordYCount++;
                }

                int coordZCount = 2;
                foreach (double z in indiCoordZ)
                {
                    string cellName = "K" + coordZCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = z;
                    coordZCount++;
                }

                int xMinCount = 2;
                foreach (double xMin in gridXMinCoord)
                {
                    string cellName = "L" + xMinCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = xMin;
                    xMinCount++;
                }

                int yMinCount = 2;
                foreach (double yMin in gridYMinCoord)
                {
                    string cellName = "M" + yMinCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = yMin;
                    yMinCount++;
                }

                int xMaxCount = 2;
                foreach (double xMax in gridXMaxCoord)
                {
                    string cellName = "N" + xMaxCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = xMax;
                    xMaxCount++;
                }

                int yMaxCount = 2;
                foreach (double yMax in gridYMaxCoord)
                {
                    string cellName = "O" + yMaxCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = yMax;
                    yMaxCount++;
                }

                int tradeFileCount = 2;
                foreach (string file in tradeFile)
                {
                    string cellName = "P" + tradeFileCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = file;
                    tradeFileCount++;
                }

                int assignToCount = 2;
                foreach (string assign in clashAssignTo)
                {
                    string cellName = "Q" + assignToCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = assign;
                    assignToCount++;
                }

                int approvedByCount = 2;
                foreach (string approve in clashApprovedBy)
                {
                    string cellName = "R" + approvedByCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = approve;
                    approvedByCount++;
                }

                int approveTimeCount = 2;
                foreach (string time in clashApproveTime)
                {
                    string cellName = "S" + approveTimeCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = time;
                    approveTimeCount++;
                }

                int descriptionCount = 2;
                foreach (string description in clashDescription)
                {
                    string cellName = "T" + descriptionCount.ToString();
                    var    range    = xlWorksheet_trade.get_Range(cellName, cellName);
                    range.Value2 = description;
                    descriptionCount++;
                }

                //Locate file save location
                string[] clashDate = tradeDate[0].Split('/');
                string   modDate   = "";

                if (clashDate[0].Length == 1)
                {
                    clashDate[0] = "0" + clashDate[0];
                }

                if (clashDate[1].Length == 1)
                {
                    clashDate[1] = "0" + clashDate[1];
                }
                modDate = clashDate[2] + clashDate[0] + clashDate[1];


                SaveFileDialog saveClashData = new SaveFileDialog();

                saveClashData.Title    = "Save to...";
                saveClashData.Filter   = "Excel Workbook | *.xlsx|Excel 97-2003 Workbook | *.xls";
                saveClashData.FileName = modDate + "-Clash_Test_Data-" + focusZone[0].ToString();

                if (saveClashData.ShowDialog() == DialogResult.OK)
                {
                    string path = saveClashData.FileName;
                    xlWorkbook.SaveCopyAs(path);
                    xlWorkbook.Saved = true;
                    xlWorkbook.Close(true, Missing.Value, Missing.Value);
                    xlApp.Quit();
                }

                xlApp.Visible = false;
                //-----------------------------------------------------------------------------------------//
            }

            catch (Exception exception)
            {
                MessageBox.Show("Error! Check if clash test(s) exist or previously run.  Original Message: " + exception.Message);
            }

            return(0);
        }
Esempio n. 23
0
        public override int Execute(params string[] ps)
        {
            Document doc             = Application.ActiveDocument;
            string   currentFilename = doc.CurrentFileName;
            string   filename        = doc.FileName;
            string   title           = doc.Title;

            Units            units          = doc.Units;
            DocumentModels   models         = doc.Models;
            DocumentInfoPart info           = doc.DocumentInfo;
            string           currentSheetId = info.Value.CurrentSheetId; // "little_house_2021.rvt"
            DocumentDatabase db             = doc.Database;
            bool             ignoreHidden   = true;
            BoundingBox3D    bb             = doc.GetBoundingBox(ignoreHidden);
            Point3D          min            = bb.Min;
            Point3D          max            = bb.Max;
            int n;

            n = models.Count;

            Debug.Print("\n{0}: sheet {1}, bounding box {2}, {3} model{4}{5}\n",
                        title, currentSheetId, Util.BoundingBoxString(bb),
                        n, Util.PluralSuffix(n), Util.DotOrColon(n));

            // First attempt, based on Navisworks-Geometry-Primitives,
            // using walkNode oState.CurrentPartition:

            //WalkPartition wp = new WalkPartition();
            //wp.Execute();

            // Second attempt, retrieving root item descendants:

            Debug.Print("Model item tree structure:");

            foreach (Model model in models)
            {
                string model_filename = Path.GetFileName(
                    model.FileName);

                string path = "C:/tmp/"
                              + model_filename.Replace(".nwd", ".txt");

                ModelItem rootItem = model.RootItem;

                ModelItemEnumerableCollection mis
                    = rootItem.DescendantsAndSelf;

                n = mis.Count();

                Debug.Print(
                    "\nModel {0} contains {1} model items listed in '{2}'\n",
                    model_filename, n, path);

                ItemTree mitree = new ItemTree(mis);

                using (StreamWriter writer
                           = new StreamWriter(path))
                {
                    mitree.WriteTo(writer);
                }

                /*
                 * ItemData.InstanceCount = 0;
                 *
                 * List<ItemData> layers
                 * = new List<ItemData>( mis
                 *  .Where<ModelItem>( mi => mi.IsLayer )
                 *  .Select<ModelItem, ItemData>(
                 *    mi => new ItemData( mi ) ) );
                 *
                 * n = layers.Count();
                 * Debug.Print(
                 * "  {0} layers containing {1} hierarchical model items",
                 * n, ItemData.InstanceCount );
                 *
                 * int iLayer = 0;
                 *
                 * foreach( ItemData layer in layers )
                 * {
                 * List<ItemData> cats = layer.Children;
                 * n = cats.Count();
                 * Debug.Print(
                 *  "    {0}: {1} has {2} categories",
                 *  iLayer++, layer, n );
                 *
                 * int iCategory = 0;
                 *
                 * foreach( ItemData cat in cats )
                 * {
                 *  List<ItemData> fams = cat.Children;
                 *  n = fams.Count();
                 *  Debug.Print(
                 *    "      {0}: {1} has {2} families",
                 *    iCategory++, cat, n );
                 *
                 *  int iFamily = 0;
                 *
                 *  foreach( ItemData fam in fams )
                 *  {
                 *    List<ItemData> types = fam.Children;
                 *    n = types.Count();
                 *    Debug.Print(
                 *      "        {0}: {1} has {2} types",
                 *      iFamily++, fam, n );
                 *
                 *    int iType = 0;
                 *
                 *    foreach( ItemData typ in types )
                 *    {
                 *      List<ItemData> instances = typ.Children;
                 *      n = instances.Count();
                 *      Debug.Print(
                 *        "          {0}: {1} has {2} instances",
                 *        iType++, typ, n );
                 *
                 *      int iInst = 0;
                 *
                 *      foreach( ItemData inst in instances )
                 *      {
                 *        List<ItemData> subinsts = inst.Children;
                 *        n = subinsts.Count();
                 *        Debug.Print(
                 *          "            {0}: {1} has {2} subinstances",
                 *          iInst++, inst, n );
                 *
                 *        int iSubinst = 0;
                 *
                 *        foreach( ItemData subinst in subinsts )
                 *        {
                 *          List<ItemData> children = subinst.Children;
                 *          n = children.Count();
                 *          Debug.Print(
                 *            "              {0}: {1} has {2} children",
                 *            iSubinst++, inst, n );
                 *        }
                 *      }
                 *    }
                 *  }
                 * }
                 * }
                 */

                if (50 > n)
                {
                    List <ModelItem> migeos
                        = new List <ModelItem>();

                    foreach (ModelItem mi in mis)
                    {
                        Debug.Print(
                            "    '{0}' '{1}' '{2}' has geo {3}",
                            mi.DisplayName, mi.ClassDisplayName,
                            mi.ClassName, mi.HasGeometry);

                        if (mi.HasGeometry)
                        {
                            migeos.Add(mi);
                        }
                    }
                    Debug.Print("  {0} model items have geometry:", migeos.Count());
                    foreach (ModelItem mi in migeos)
                    {
                        Debug.Print(
                            "    '{0}' '{1}' '{2}' {3} bb {4}",
                            mi.DisplayName, mi.ClassDisplayName,
                            mi.ClassName, mi.HasGeometry,
                            Util.BoundingBoxString(mi.BoundingBox()));

                        if ("Floor" == mi.DisplayName)
                        {
                            RvtProperties.DumpProperties(mi);
                            RvtProperties props = new RvtProperties(mi);
                            int           id    = props.ElementId;
                        }
                    }
                }
            }
            return(0);
        }