Esempio n. 1
0
        static void Main(string[] args)
        {
            string connectionString = "Server=FELLIPE-MACWIN;Database=db_LibBim;Integrated Security=true";
            try
            {
                Repositorio rep = new Repositorio(connectionString);

                Console.WriteLine("Objetos Materiais:");
                foreach (ObjetoMaterial om in rep.ObjetoMateriais)
                {
                    Console.Write("Objeto: {0}, Material: {1}, Quantidade: {2}\n",
                        om.Objeto.Nome, om.Material.DescricaoMaterial, om.Quantidade);
                }

                Console.WriteLine("Materiais:");
                foreach(Material m in rep.Materiais)
                {
                    Console.WriteLine("IdMaterial: {0}, IdMedida: {1}, Descricao: {2}, Custo: {3}",
                        m.IdMaterial, m.IdMedidaMaterial, m.DescricaoMaterial, m.CustoMedida);
                }

                Console.WriteLine("Objetos");
                foreach (Objeto o in rep.Objetos)
                {
                    Console.WriteLine("Quantidade de Materiais deste objeto: {0}", o.Materiais.Count);
                    Console.WriteLine("id_objeto: {0}, id_medida={1}, descricao_medida: {4}, custo_mao_obra={2}, nome={3}",
                        o.IdObjeto, o.IdMedidaObjeto, o.CustoMaoDeObra, o.Nome, o.Medida.Descricao);
                }

                Console.WriteLine("Medidas:");
                foreach(Medida m in rep.Medidas)
                {
                    Console.WriteLine("id_Medida: {0}, Descricao: {1}", m.IdMedida, m.Descricao);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }

            Console.Write("Fim da Execução. Pressione qualquer tecla para finalizar.");
            Console.Read();
        }
Esempio n. 2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                // Cria o repositorio passando a string de conexao
                Repositorio rep = new Repositorio("Server=FELLIPE-MACWIN;Database=db_LibBim;Integrated Security=true");

                UIDocument uidoc = commandData.Application.ActiveUIDocument;

                // Get the element selection of current document.
                Selection selection = uidoc.Selection;
                ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
                Document document = uidoc.Document;

                // File to hold text content
                StringBuilder sb = new StringBuilder();
                FilterWalls(document, sb, rep);

                using (StreamWriter outfile = new StreamWriter(@"C:\Revit\wall.txt", false))
                {
                    try
                    {
                        outfile.Write(sb.ToString());
                        outfile.Close();
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Revit", "Não conseguiu criar o arquivo texto. Motivo: " + ex.Message);
                        return Result.Failed;
                    }

                }
            }
            catch (Exception e)
            {
                message = e.Message;
                return Result.Failed;
            }

            return Result.Succeeded;
        }
Esempio n. 3
0
        public static void FilterWalls(Document document, StringBuilder sb, Repositorio rep)
        {
            sb.AppendLine("== Tratando Paredes ==");
            StringBuilder temp = new StringBuilder();
            // Find all Wall instances in the document by using category filter
            ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
            // Apply the filter to the elements in the active document
            // Use shortcut WhereElementIsNotElementType() to find wall instances only
            FilteredElementCollector collector = new FilteredElementCollector(document);
            IList<Element> walls =
            collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
            sb.AppendLine(string.Format("Paredes encontradas: {0}", walls.Count));
            String prompt = string.Format("Total Walls: {0}. The walls in the current document are:\n", walls.Count);
            Wall wall;
            double total = 0d;
            Parameter parameter;
            int areaPerHour = 3;
            double totalTime = 0;
            int index = 0;
            double areaSquareMeters;

            double timePerWall;

            int bricksPerRootSquare = 30;
            int bricksPerWall = 0;
            int totalBricks = 0;

            decimal cost100Bricks = 100;
            decimal costBricksPerWall = 0;
            decimal totalBricksCost = 0;

            // Orcamento via Banco
            List<int> visitedTypes = new List<int>();
            ElementId currElemId;
            int currType;
            Wall newWall;
            IList<Element> currElems;
            foreach (Element e in walls)
            {
                wall = e as Wall;

                // Convert
                areaSquareMeters = UnitUtils.ConvertFromInternalUnits(wall.GetOrderedParameters()[20].AsDouble(), DisplayUnitType.DUT_SQUARE_METERS);

                prompt += string.Format("Parede:{0}, Área: {1}. Tempo Necessário: {2} horas.\n", ++index, wall.GetOrderedParameters()[20].AsValueString(), totalTime);

                // Timer
                timePerWall = areaSquareMeters / areaPerHour;

                // Material
                // Total bricks equal to total area per number of bricker per wall square meters
                bricksPerWall = (int) Math.Ceiling(areaSquareMeters * bricksPerRootSquare);

                // Values
                costBricksPerWall = bricksPerWall * cost100Bricks / 100;

                // Update Totals
                totalTime += timePerWall;
                totalBricks += bricksPerWall;
                totalBricksCost += costBricksPerWall;

                currElemId = wall.GetTypeId();
                currType = currElemId.IntegerValue;

                if(visitedTypes.Contains(currType))
                {
                    // Wall Type already visited
                    continue;
                }

                currElems = FilterElementsByTypeId(document, currElemId);

                foreach(Element e2 in currElems)
                {
                    newWall = e2 as Wall;
                    // TODO - Continuar daqui
                }

                // Log
                temp.AppendLine(string.Format("Parede {0}: {1} (Type: {2})", index, wall.Name, wall.GetTypeId()));
                temp.AppendLine(string.Format("Tempo de Construção: {0} horas", timePerWall));
                temp.AppendLine(string.Format("Área: {0}", wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsValueString()));
                temp.AppendLine(string.Format("Volume: {0}", wall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED).AsValueString()));
                temp.AppendLine(string.Format("Comprimento: {0} m", wall.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsValueString()));
                temp.AppendLine(string.Format("Altura: {0} m", wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsValueString()));
                temp.AppendLine(string.Format("Tijolos Necessários: {0} unidades", bricksPerWall));
                temp.AppendLine(string.Format("Custo do Tijolo: {0:C2}", costBricksPerWall));
                // Calculates Materials

                temp.AppendLine();
            }

            prompt = "Tempo Total de Construção das paredes: " + totalTime+"\n"+prompt;
            TaskDialog.Show("Revit", prompt);
            sb.AppendLine(string.Format("Tempo Total de Construção das Paredes: {0} horas", totalTime));
            sb.AppendLine(string.Format("Total de tijolos necessários: {0} unidades", totalBricks));
            sb.AppendLine(string.Format("Custo Total de tijolos: {0:C2}", totalBricksCost));
            sb.AppendLine("--").AppendLine().Append(temp.ToString());
            sb.AppendLine("== Fim Tratando Paredes ==");
        }