/// <summary> /// 创建新的线样式 /// </summary> /// <param name="newColor"></param> /// <param name="weight"></param> /// <param name="linePatternId"></param> /// <returns></returns> private Category CreateNewLineType() { //获得设置里面的线 Category lineCategory = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines); //得到这个线下面所有的线样式 var subcats = lineCategory.SubCategories; foreach (Category item in subcats) { if (item.Name == "标记线") { //通过样式名称,查找我们自己设定的样式 _lineStyle = item; } } if (_lineStyle == null) { //所有的线型图案,即实线、中心线、点划线等 //List<LinePatternElement> linePatternElements = new FilteredElementCollector(doc).OfClass(typeof(LinePatternElement)).Select(s => s as LinePatternElement).ToList(); //LinePatternElement linePattern = linePatternElements.FirstOrDefault(x => x.Name == "划线"); Category newCategory = null; newCategory = doc.Settings.Categories.NewSubcategory(lineCategory, "标记线"); //设置线的颜色 newCategory.LineColor = new Color(0,166,0); //设置线的线型 //newCategory.SetLinePatternId(linePattern.Id, GraphicsStyleType.Projection); //设置线宽 //newCategory.SetLineWeight(weight, GraphicsStyleType.Projection); return newCategory; } return _lineStyle; }
/// <summary> /// 线样式 /// </summary> private Category _lineStyle { get; set; } //详情线设置线样式 DetailCurve.LineStyle = _lineStyle.GetGraphicsStyle(GraphicsStyleType.Projection)