下載app免費(fèi)領(lǐng)取會(huì)員
Revit里要設(shè)置模型線的顏色有2中方法
一種是設(shè)置線的樣式
一種是設(shè)置OverrideGraphicSettings
第一種需要設(shè)置新建線的樣式,
然后通過模型線的線樣式參數(shù)設(shè)置
第二種是通過替換視圖中的圖形,它是
基于視圖的,顏色只在當(dāng)前視圖有效
下面是關(guān)鍵代碼:
新建線樣式
Category tCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines);
Reference r = uidoc.Selection.PickObject(ObjectType.Element);
Element elem = doc.GetElement(r);
Transaction trans = new Transaction(doc, "Trans");
trans.Start();
if (!tCat.SubCategories.Contains("MyLine"))
{
Category nCat = doc.Settings.Categories.NewSubcategory(tCat, "MyLine");
nCat.LineColor = new Color(255, 0, 0);
}
doc.Regenerate();
FilteredElementCollector temc = new FilteredElementCollector(doc);
temc.OfClass(typeof(GraphicsStyle));
GraphicsStyle mgs = temc.First(m => (m as GraphicsStyle).GraphicsStyleCategory.Name == "MyLine") as GraphicsStyle;
Parameter tp = elem.LookupParameter("線樣式");
tp.Set(mgs.Id);
trans.Commit();
替換視圖中的圖形
Reference r = uidoc.Selection.PickObject(ObjectType.Element);
Element elem = doc.GetElement(r);
OverrideGraphicSettings ogs = v.GetElementOverrides(elem.Id);
Transaction trans = new Transaction(doc, "trans");
trans.Start();
ogs.SetProjectionLineColor(new Color(255, 0, 0));
v.SetElementOverrides(elem.Id, ogs);
trans.Commit();
本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。
上一篇:二次開發(fā)教程:Revit開發(fā)之導(dǎo)出明細(xì)表到Excel
下一篇:二次開發(fā)教程:Revit開發(fā)讀取CAD信息
推薦專題