Exemple #1
0
        //  Load list of Inventor Templates from user selected path, applying filter on files extension
        public List <FileInfo> GetInventorTemplates(string path)
        {
            NLogger.LogText("Entered GetInventorTemplates method with path {path}", path);

            List <FileInfo> inventorTemplates = null;
            List <string>   fileExtensions    = new List <string> {
                ".iam", ".ipt", ".zip"
            };

            try
            {
                var g = Directory.EnumerateFiles(path).Select(p => new FileInfo(p));

                NLogger.LogText("Retrieved Inventor files {InventorFiles}", g.ToList().Count.ToString());

                inventorTemplates = g.Where(j => fileExtensions.Contains(j.Extension)).ToList();

                NLogger.LogText("Filtered Inventor files {InventorFiles}", inventorTemplates.Count.ToString());

                NLogger.LogText("Exit GetInventorTemplates method");
            }
            catch (Exception ex)
            {
                NLogger.LogError($"Following error occurred in GetInventorTemplates: {ex}");
                throw new UIRelevantException(LanguageHandler.GetString("msgBox_BIM360NotSync"));
            }

            return(inventorTemplates);
        }
        //  Extract all relevant information from selected elements and create an internal structure for passing parameters around
        public List <ElementStructure> ProcessElements(IList <Element> RevitElements)
        {
            NLogger.LogText("Entered ProcessElements");

            elementStructureList.Clear();

            //  Extract information from received Revit elements
            foreach (var elem in RevitElements)
            {
                var elementOrderedParamsList     = new List <ElementOrderedParameter>();
                var elementTypeOrderedParamsList = new List <ElementOrderedParameter>();
                var elementTypeSingleParamsList  = new List <ElementOrderedParameter>();

                elementOrderedParamsList = GetParameters(elem);

                //  Extract the corresponding ElementType
                var         elemTypeId = elem.GetTypeId();
                ElementType elemType   = (ElementType)doc.GetElement(elemTypeId);

                if (elemType == null)
                {
                    throw new UIRelevantException(LanguageHandler.GetString("msgBox_SelElNoRevFam"));
                }

                elementTypeOrderedParamsList = GetParameters(elemType);
                elementTypeSingleParamsList.Add(new ElementOrderedParameter
                {
                    ParameterName  = BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM.ToString(),
                    ParameterValue = GetSingleParameter(elemType, BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM)
                });

                elementStructureList.Add(new ElementStructure {
                    Element     = elem,
                    ElementType = elemType,
                    ElementOrderedParameters     = elementOrderedParamsList,
                    ElementTypeOrderedParameters = elementTypeOrderedParamsList,
                    ElementTypeSingleParameters  = elementTypeSingleParamsList
                });
            }

            NLogger.LogText("Exit ProcessElements");

            return(elementStructureList);
        }