Example #1
0
            public InstanceData(Element instance)
            {
                Instance = instance;

                ParameterMap m = Instance.ParametersMap;

                Parameter p = m.get_Item("Param1");

                Param1 = (p == null) ? string.Empty : p.AsString();

                p      = m.get_Item("Param2");
                Param2 = (p == null) ? false : (0 != p.AsInteger());

                p      = m.get_Item("Param3");
                Param3 = (p == null) ? 0 : p.AsInteger();
            }
Example #2
0
        Parameter GetParameterFromParameterMap(
            Element elem, string paramName)
        {
            ParameterMap         parameterMap = elem.ParametersMap;
            ParameterMapIterator itr          = parameterMap.ForwardIterator();

            while (itr.MoveNext())
            {
                if (paramName == itr.Key)
                {
                    return(parameterMap.get_Item(paramName));
                }
            }

            return(null);
        }
Example #3
0
        void ConvertParameterMapToDictionary(
            Element elem, out SortedDictionary <string, Parameter> outDictionary)
        {
            ParameterMap         parameterMap = elem.ParametersMap;
            ParameterMapIterator itr          = parameterMap.ForwardIterator();

            outDictionary = new SortedDictionary <string, Parameter>();

            while (itr.MoveNext())
            {
                string    paramName = itr.Key;
                Parameter parameter
                    = parameterMap.get_Item(paramName);
                outDictionary.Add(paramName, parameter);
            }
        }
Example #4
0
        void GetSortedParamsValues(
            Element elem, out SortedList <string, string> paramsValues)
        {
            ParameterMap         parameterMap = elem.ParametersMap;
            ParameterMapIterator itr          = parameterMap.ForwardIterator();

            paramsValues = new SortedList <string, string>();

            while (itr.MoveNext())
            {
                string    paramName = itr.Key;
                Parameter parameter
                    = parameterMap.get_Item(paramName);

                paramsValues.Add(paramName,
                                 GetParamValueAsStr(parameter));
            }
        }
Example #5
0
        /// <summary>
        /// Gets the revit parameter from project info
        /// </summary>
        /// <param name="parameterName">name of the parameter</param>
        /// <returns>parameter or null if not found</returns>
        private Parameter GetParameterFromProjectInfo(string parameterName)
        {
            Element pInfo = _doc.ProjectInformation;

            if (null == pInfo)
            {
                return(null);
            }

            ParameterMap theParamMap = pInfo.ParametersMap;

            if (!theParamMap.Contains(parameterName))
            {
                return(null);
            }

            return(theParamMap.get_Item(parameterName));
        }
Example #6
0
        public static Parameter GetParameterByDefinitionName(ParameterMap parameterMap, string name)
        {
            if (parameterMap == null)
            {
                Log.WriteLine("Element.ParametersMap is null");
                return(null);
            }
            Parameter result = null;

            if (parameterMap.Contains(name))
            {
                try
                {
                    result = parameterMap.get_Item(name);
                }
                catch (System.Exception value)
                {
                    Log.WriteLine("ParmeterMap contains the key, but can't get it");
                    Log.WriteLine(value);
                }
            }
            return(result);
        }
Example #7
0
        /// <summary>
        /// The method is used to collect template information, specifying the New Window Parameters
        /// </summary>
        private void CollectTemplateInfo()
        {
            List <Wall> walls = Utility.GetElements <Wall>(m_application, m_document);

            m_wallThickness = walls[0].Width;
            ParameterMap paraMap        = walls[0].ParametersMap;
            Parameter    wallheightPara = paraMap.get_Item("Unconnected Height");

            if (wallheightPara != null)
            {
                m_wallHeight = wallheightPara.AsDouble();
            }
            Parameter wallwidthPara = paraMap.get_Item("Length");

            if (wallwidthPara != null)
            {
                m_wallWidth = wallwidthPara.AsDouble();
            }
            m_windowInset = m_wallThickness / 10;
            FamilyType      type           = m_familyManager.CurrentType;
            FamilyParameter heightPara     = m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT);
            FamilyParameter widthPara      = m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH);
            FamilyParameter sillHeightPara = m_familyManager.get_Parameter("Default Sill Height");

            if (type.HasValue(heightPara))
            {
                switch (heightPara.StorageType)
                {
                case StorageType.Double:
                    m_height = type.AsDouble(heightPara).Value;
                    break;

                case StorageType.Integer:
                    m_height = type.AsInteger(heightPara).Value;
                    break;
                }
            }
            if (type.HasValue(widthPara))
            {
                switch (widthPara.StorageType)
                {
                case StorageType.Double:
                    m_width = type.AsDouble(widthPara).Value;
                    break;

                case StorageType.Integer:
                    m_width = type.AsDouble(widthPara).Value;
                    break;
                }
            }
            if (type.HasValue(sillHeightPara))
            {
                switch (sillHeightPara.StorageType)
                {
                case StorageType.Double:
                    m_sillHeight = type.AsDouble(sillHeightPara).Value;
                    break;

                case StorageType.Integer:
                    m_sillHeight = type.AsDouble(sillHeightPara).Value;
                    break;
                }
            }

            //set the height,width and sillheight parameter of the opening
            m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT),
                                m_height);
            m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH),
                                m_width);
            m_familyManager.Set(m_familyManager.get_Parameter("Default Sill Height"), m_sillHeight);

            //get materials

            FilteredElementCollector elementCollector = new FilteredElementCollector(m_document);

            elementCollector.WherePasses(new ElementClassFilter(typeof(Material)));
            IList <Element> materials = elementCollector.ToElements();

            foreach (Element materialElement in materials)
            {
                Material material = materialElement as Material;
                m_para.GlassMaterials.Add(material.Name);
                m_para.FrameMaterials.Add(material.Name);
            }

            //get categories
            Categories      categories = m_document.Settings.Categories;
            Category        category   = categories.get_Item(BuiltInCategory.OST_Windows);
            CategoryNameMap cnm        = category.SubCategories;

            if (cnm.Contains("Frame/Mullion"))
            {
                m_frameCat = cnm.get_Item("Frame/Mullion");
            }
            if (cnm.Contains("Glass"))
            {
                m_glassCat = cnm.get_Item("Glass");
            }

            //get referenceplanes
            List <ReferencePlane> planes = Utility.GetElements <ReferencePlane>(m_application, m_document);

            foreach (ReferencePlane p in planes)
            {
                if (p.Name.Equals("Sash"))
                {
                    m_sashPlane = p;
                }
                if (p.Name.Equals("Exterior"))
                {
                    m_exteriorPlane = p;
                }
                if (p.Name.Equals("Center (Front/Back)"))
                {
                    m_centerPlane = p;
                }
                if (p.Name.Equals("Top") || p.Name.Equals("Head"))
                {
                    m_topPlane = p;
                }
                if (p.Name.Equals("Sill") || p.Name.Equals("Bottom"))
                {
                    m_sillPlane = p;
                }
            }
        }