Esempio n. 1
0
        private void CollectAreas()
        {
            try
            {
                progressForm            = new Form_ProgressBar();
                progressForm.LabelText  = "Collecting Information from the Revit Project..";
                progressForm.LabelCount = collectedAreas.Count + " areas found";
                progressForm.Show();
                progressForm.MaxValue = collectedAreas.Count;
                progressForm.Refresh();

                foreach (Area area in collectedAreas)
                {
                    progressForm.PerformStep();
                    AreaProperties ap = new AreaProperties(doc, area);
                    if (!areaDictionary.ContainsKey(ap.ID) && !ap.CurveArrArray.IsEmpty)
                    {
                        areaDictionary.Add(ap.ID, ap);
                        if (!areaTypeNames.Contains(ap.AreaType))
                        {
                            areaTypeNames.Add(ap.AreaType);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect Areas data. \n" + ex.Message, "Form_AreaMass:CollectAreas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                progressForm.Close();
            }
        }
Esempio n. 2
0
        private void CollectFloors()
        {
            try
            {
                progressForm            = new Form_ProgressBar();
                progressForm.LabelText  = "Collecting Information from the Revit Project..";
                progressForm.LabelCount = collectedFloors.Count + " floors found";
                progressForm.Show();
                progressForm.MaxValue = collectedFloors.Count;
                progressForm.Refresh();

                foreach (Floor floor in collectedFloors)
                {
                    progressForm.PerformStep();
                    FloorProperties fp = new FloorProperties(doc, floor);
                    if (!floorDictionary.ContainsKey(fp.ID))
                    {
                        floorDictionary.Add(fp.ID, fp);
                        if (!levelNames.Contains(fp.Level))
                        {
                            levelNames.Add(fp.Level);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                progressForm.Close();
                MessageBox.Show("Failed to collect Floors data. \n" + ex.Message, "Form_FloorMass:CollectFloors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 3
0
        private void CollectRooms()
        {
            try
            {
                progressForm            = new Form_ProgressBar();
                progressForm.LabelText  = "Collecting Information from the Revit Project..";
                progressForm.LabelCount = collectedRooms.Count + " rooms found";
                progressForm.Show();
                progressForm.MaxValue = collectedRooms.Count;
                progressForm.Refresh();

                foreach (Room room in collectedRooms)
                {
                    progressForm.PerformStep();
                    RoomProperties rp = new RoomProperties(doc, room);
                    if (!roomDictionary.ContainsKey(rp.ID) && null != room.Location)
                    {
                        roomDictionary.Add(rp.ID, rp);
                        if (!departmentNames.Contains(rp.Department))
                        {
                            departmentNames.Add(rp.Department);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect Rooms data. \n" + ex.Message, "Form_RoomMass:CollectRooms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                progressForm.Close();
            }
        }
Esempio n. 4
0
        //find elements which intersect more than two mass elements.
        private void FindOverlaps()
        {
            try
            {
                if (elementDictionary.Count > 0)
                {
                    progressForm            = new Form_ProgressBar();
                    progressForm.Text       = "Finding Overlapping Conditions";
                    progressForm.LabelText  = "Finding elements intersecting with more than two mass elements...";
                    progressForm.LabelCount = elementDictionary.Count.ToString() + " elements found";
                    progressForm.MaxValue   = elementDictionary.Count;
                    progressForm.Show();
                    progressFormOpend = true;
                    progressForm.Refresh();
                }

                List <int> elementIds = elementDictionary.Keys.ToList();
                foreach (int elementId in elementIds)
                {
                    progressForm.PerformStep();
                    ElementProperties ep = elementDictionary[elementId];
                    if (ep.MassContainers.Count > 0)
                    {
                        Solid   unionSolid = null;
                        Options opt        = m_app.Application.Create.NewGeometryOptions();
                        opt.ComputeReferences = true;
                        opt.DetailLevel       = Autodesk.Revit.DB.ViewDetailLevel.Fine;

                        GeometryElement geomElement = ep.ElementObj.get_Geometry(new Options(opt));
                        geomElement = geomElement.GetTransformed(ep.TransformValue);

                        foreach (GeometryObject obj in geomElement)
                        {
                            Solid solid = obj as Solid;
                            if (null != solid)
                            {
                                if (solid.Volume > 0)
                                {
                                    if (unionSolid == null)
                                    {
                                        unionSolid = solid;
                                    }
                                    else
                                    {
                                        try { unionSolid = BooleanOperationsUtils.ExecuteBooleanOperation(solid, unionSolid, BooleanOperationsType.Union); }
                                        catch { }
                                    }
                                }
                            }
                        }
                        ep.ElementSolid = unionSolid;

                        Dictionary <int, double> overlapMap = new Dictionary <int, double>();
                        if (unionSolid != null)
                        {
                            if (unionSolid.Volume > 0)
                            {
                                foreach (int massId in ep.MassContainers.Keys)
                                {
                                    Solid massSolid      = ep.MassContainers[massId];
                                    Solid intersectSolid = null;
                                    try { intersectSolid = BooleanOperationsUtils.ExecuteBooleanOperation(massSolid, unionSolid, BooleanOperationsType.Intersect); }
                                    catch { intersectSolid = null; }
                                    if (null != intersectSolid)
                                    {
                                        if (intersectSolid.Volume > 0)
                                        {
                                            double ratio = intersectSolid.Volume / unionSolid.Volume;
                                            if (!overlapMap.ContainsKey(massId))
                                            {
                                                overlapMap.Add(massId, ratio);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        ep.OpverappingMaps = overlapMap;
                        elementDictionary.Remove(ep.ElementId);
                        elementDictionary.Add(ep.ElementId, ep);
                    }
                }

                if (progressFormOpend)
                {
                    progressForm.Close();
                    progressFormOpend = false;
                }
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
Esempio n. 5
0
        private void CollectLinkedMass()
        {
            try
            {
                List <int> selectedMass = new List <int>();
                foreach (TreeNode typeNode in treeViewLinkedFile.Nodes)
                {
                    foreach (TreeNode instanceNode in typeNode.Nodes)
                    {
                        int  instanceId  = int.Parse(instanceNode.Name);
                        bool massChecked = false;
                        foreach (TreeNode massNode in instanceNode.Nodes)
                        {
                            if (massNode.Checked)
                            {
                                selectedMass.Add(int.Parse(massNode.Name));
                                massChecked = true;
                            }
                        }
                        if (!massChecked)
                        {
                            linkedMassDictionary.Remove(instanceId);
                        }
                    }
                }

                if (selectedMass.Count > 0)
                {
                    progressForm            = new Form_ProgressBar();
                    progressForm.Text       = "Finding Elements";
                    progressForm.LabelText  = "Finding elements intersecting with 3D mass in linked files . . .";
                    progressForm.LabelCount = selectedMass.Count.ToString() + " mass found";
                    progressForm.MaxValue   = selectedMass.Count;
                    progressForm.Show();
                    progressFormOpend = true;
                    progressForm.Refresh();

                    List <int> instanceIds = linkedMassDictionary.Keys.ToList();
                    foreach (int instanceId in instanceIds)
                    {
                        LinkedInstanceProperties         lip            = linkedMassDictionary[instanceId];
                        Dictionary <int, MassProperties> massDictionary = new Dictionary <int, MassProperties>();
                        foreach (Element massElement in lip.MassElements)
                        {
                            if (!selectedMass.Contains(massElement.Id.IntegerValue))
                            {
                                continue;
                            }

                            progressForm.PerformStep();
                            MassProperties mp         = new MassProperties(massElement);
                            Solid          unionSolid = null;
                            Options        opt        = m_app.Application.Create.NewGeometryOptions();
                            opt.ComputeReferences = true;
                            opt.DetailLevel       = Autodesk.Revit.DB.ViewDetailLevel.Fine;

                            GeometryElement geomElement = massElement.get_Geometry(new Options(opt));

                            if (null != lip.TransformValue)
                            {
                                geomElement = geomElement.GetTransformed(lip.TransformValue);
                            }
                            foreach (GeometryObject obj in geomElement)
                            {
                                Solid solid = obj as Solid;
                                if (null != solid)
                                {
                                    if (solid.Volume > 0)
                                    {
                                        if (unionSolid == null)
                                        {
                                            unionSolid = solid;
                                        }
                                        else
                                        {
                                            unionSolid = BooleanOperationsUtils.ExecuteBooleanOperation(unionSolid, solid, BooleanOperationsType.Union);
                                        }
                                    }
                                }
                            }
                            mp.MassSolid = unionSolid;

                            if (null != unionSolid)
                            {
                                if (unionSolid.Volume > 0)
                                {
                                    mp.ElementContainer = FindElementsInMass(m_doc, mp.MassSolid, mp.MassId, false);
                                    List <Element> linkedElements = FindElementsInLInkedFiles(massElement, geomElement);
                                    mp.ElementContainer.AddRange(linkedElements);
                                    mp.ElementCount = mp.ElementContainer.Count;
                                }
                            }

                            if (mp.MassParameters.Count > 0)
                            {
                                foreach (Parameter param in mp.MassParameters)
                                {
                                    if (!massParameters.Contains(param.Definition.Name))
                                    {
                                        massParameters.Add(param.Definition.Name);
                                    }
                                }
                            }
                            mp.IsHost         = false;
                            mp.LInkedFileName = lip.FileName;

                            if (!massDictionary.ContainsKey(mp.MassId))
                            {
                                massDictionary.Add(mp.MassId, mp);
                            }
                            integratedMassList.Add(mp);
                        }
                        lip.MassContainers = massDictionary;
                        linkedMassDictionary.Remove(instanceId);
                        linkedMassDictionary.Add(instanceId, lip);
                    }

                    progressForm.Close();
                    progressFormOpend = false;
                }
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
Esempio n. 6
0
        private void CollectHostMass(List <Element> massElements)
        {
            try
            {
                progressForm = new Form_ProgressBar();
                if (massElements.Count > 0)
                {
                    progressForm.Text       = "Finding Elements";
                    progressForm.LabelText  = "Finding elements intersecting with 3D mass in the host project . . .";
                    progressForm.LabelCount = massElements.Count.ToString() + " mass found";
                    progressForm.MaxValue   = massElements.Count;
                    progressForm.Show();
                    progressFormOpend = true;
                    progressForm.Refresh();
                }

                foreach (Element element in massElements)
                {
                    progressForm.PerformStep();

                    MassProperties mp = new MassProperties(element);
                    mp.WorksetId = element.WorksetId.IntegerValue; //from host project

                    Solid   unionSolid = null;
                    Options opt        = m_app.Application.Create.NewGeometryOptions();
                    opt.ComputeReferences = true;
                    opt.DetailLevel       = Autodesk.Revit.DB.ViewDetailLevel.Fine;
                    GeometryElement geomElement = element.get_Geometry(new Options(opt));
                    foreach (GeometryObject obj in geomElement)
                    {
                        Solid solid = obj as Solid;
                        if (null != solid)
                        {
                            if (solid.Volume > 0)
                            {
                                if (unionSolid == null)
                                {
                                    unionSolid = solid;
                                }
                                else
                                {
                                    unionSolid = BooleanOperationsUtils.ExecuteBooleanOperation(solid, unionSolid, BooleanOperationsType.Union);
                                }
                            }
                        }
                    }
                    mp.MassSolid = unionSolid;

                    if (null != unionSolid)
                    {
                        if (unionSolid.Volume > 0)
                        {
                            mp.ElementContainer = FindElementsInMass(m_doc, mp.MassSolid, mp.MassId, false);
                            List <Element> linkedElements = FindElementsInLInkedFiles(element, geomElement);
                            mp.ElementContainer.AddRange(linkedElements);
                            mp.ElementCount = mp.ElementContainer.Count;
                        }
                    }

                    if (mp.MassParameters.Count > 0)
                    {
                        foreach (Parameter param in mp.MassParameters)
                        {
                            if (!massParameters.Contains(param.Definition.Name))
                            {
                                massParameters.Add(param.Definition.Name);
                            }
                        }
                    }

                    mp.IsHost = true;
                    integratedMassList.Add(mp);
                }

                if (progressFormOpend)
                {
                    progressForm.Close();
                    progressFormOpend = false;
                }
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
Esempio n. 7
0
        private void DisplayAreaData()
        {
            try
            {
                progressForm.LabelText = "Preparing Components to be Displayed..";
                progressForm.CurValue  = 1;
                progressForm.Refresh();


                foreach (int areaId in areaDictionary.Keys)
                {
                    progressForm.PerformStep();
                    AreaProperties ap = areaDictionary[areaId];

                    int             index = dataGridViewArea.Rows.Add();
                    DataGridViewRow row   = dataGridViewArea.Rows[index];
                    row.Tag            = ap;
                    row.Cells[0].Value = false;
                    row.Cells[1].Value = ap.Number;
                    row.Cells[2].Value = ap.Name;
                    row.Cells[3].Value = ap.Level;
                    row.Cells[4].Value = ap.DesignOption;
                    row.Cells[5].Value = ap.AreaType;
                    row.Cells[6].Value = 10; //default height=10

                    if (placedAreas.Contains(ap.ID))
                    {
                        //row.ReadOnly = true;
                        row.Cells[0].Value             = false;
                        row.DefaultCellStyle.ForeColor = System.Drawing.Color.Gray;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            cell.ToolTipText = ap.ID + ": Mass family is already placed in the project.";
                        }
                    }
                    if (areaDiscrepancy.Contains(ap.ID))
                    {
                        row.Cells[0].Value             = true;
                        row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            cell.ToolTipText = ap.ID + ": Area boundary lines have been changed.";
                        }
                    }
                }

                if (defDictionary.Count > 0)
                {
                    string parameters = "";
                    foreach (string defName in defDictionary.Keys)
                    {
                        parameters += "[" + defName + "]   ";
                    }
                    richTextBoxParameters.Text = parameters;
                }
                progressForm.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to display area data.\n" + ex.Message, "Form_AreaMass:DisplayAreaData", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                progressForm.Close();
            }
        }
Esempio n. 8
0
        private void DisplayFloorData()
        {
            try
            {
                progressForm.LabelText = "Preparing Components to be Displayed..";
                progressForm.CurValue  = 1;
                progressForm.Refresh();

                foreach (int floorId in floorDictionary.Keys)
                {
                    progressForm.PerformStep();
                    FloorProperties fp = floorDictionary[floorId];

                    int             index = dataGridViewFloor.Rows.Add();
                    DataGridViewRow row   = dataGridViewFloor.Rows[index];
                    row.Tag            = fp;
                    row.Cells[0].Value = false;
                    row.Cells[1].Value = fp.TypeName;
                    row.Cells[2].Value = fp.Level;
                    row.Cells[3].Value = fp.Phase;
                    row.Cells[4].Value = fp.DesignOption;
                    row.Cells[5].Value = fp.Comments;
                    row.Cells[6].Value = 10;//default height

                    if (placedFloors.Contains(fp.ID))
                    {
                        row.Cells[0].Value             = false;
                        row.DefaultCellStyle.ForeColor = System.Drawing.Color.Gray;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            cell.ToolTipText = fp.ID + ": Mass family is already placed in the project.";
                        }
                    }
                    if (floorDiscrepancy.Contains(fp.ID))
                    {
                        row.Cells[0].Value             = true;
                        row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            cell.ToolTipText = fp.ID + ": Floor boundary lines have been changed.";
                        }
                    }
                }

                if (defDictionary.Count > 0)
                {
                    string parameters = "";
                    foreach (string defName in defDictionary.Keys)
                    {
                        parameters += "[" + defName + "]   ";
                    }
                    richTextBoxParameters.Text = parameters;
                }

                progressForm.Close();
            }
            catch (Exception ex)
            {
                progressForm.Close();
                MessageBox.Show("Failed to display floor data.\n" + ex.Message, "Form_CreateMass:DisplayFloorData", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }