revit二次开发 获取模型线可用的线样式

/// 
        /// 获取线样式类型
        /// 
        /// 
        /// 
        public static List GetLineStyles(this Document doc)
        {
            List result = new List();
            var styles = doc.GetElements();

            Category lineCategory = null;
            foreach (var g in styles)
            {
                if (g.GraphicsStyleCategory != null)
                {
                    var category = g.GraphicsStyleCategory.Parent;
                    if (category != null)
                    {
                        BuiltInCategory bic = (BuiltInCategory)category.Id.IntegerValue;
                        if (bic == BuiltInCategory.OST_Lines)
                        {
                            lineCategory = category;
                            break;
                        }
                    }
                }
            }

            if (lineCategory != null)
            {
                foreach (Category obj in lineCategory.SubCategories)
                {
                    BuiltInCategory integerValue = (BuiltInCategory)obj.Id.IntegerValue;
                    if (integerValue == BuiltInCategory.OST_GenericLines ||
                    integerValue == BuiltInCategory.OST_CenterLines ||
                    integerValue == BuiltInCategory.OST_DemolishedLines ||
                    integerValue == BuiltInCategory.OST_OverheadLines ||
                    integerValue == BuiltInCategory.OST_LinesBeyond ||
                    integerValue == BuiltInCategory.OST_HiddenLines ||
                    integerValue == BuiltInCategory.OST_CurvesMediumLines ||
                    integerValue == BuiltInCategory.OST_CurvesWideLines ||
                    integerValue == BuiltInCategory.OST_CurvesThinLines ||
                    integerValue == BuiltInCategory.OST_LinesHiddenLines)
                    {
                        GraphicsStyle gs = obj.GetGraphicsStyle(GraphicsStyleType.Projection);
                        result.Add(gs);
                    }

                    if (obj.Id.IntegerValue > 0)
                    {
                        GraphicsStyle gs = obj.GetGraphicsStyle(GraphicsStyleType.Projection);
                        result.Add(gs);
                    }
                }
            }

            return result.OrderBy(f => f.Name).ToList();
        }

 

你可能感兴趣的:(Revit二次开发,revit)