在 Revit 中更改线型后 api 无法在对象样式中找到新的线型
After changing linestyle in revit api cant find new linestyle in object styles
我正在 Revit 族中创建一个类别,它是一种线型,在我设置它之后,它存在,但我在族中找不到它,但如果尝试重新创建它,revit 会创建一个错误,它已经存在.我尝试使用再生,但这不起作用。
ElementId solidLineId = LinePatternElement.GetSolidPatternId();
// The new linestyle will be a subcategory of the Lines category
Categories categories = doc.Settings.Categories;
Category lineCat = categories.get_Item(BuiltInCategory.OST_Lines);
using (Transaction t = new Transaction(doc, "Create LineStyle"))
{
t.Start();
Category newLineStyleCat = categories.NewSubcategory(lineCat, "Black-01-Solid");
newLineStyleCat.SetLineWeight(1, GraphicsStyleType.Projection);
newLineStyleCat.LineColor = new Color(28,28, 28);
newLineStyleCat.SetLinePatternId(solidLineId, GraphicsStyleType.Projection);
t.Commit();
}
这就是创建新线型的方法
分类猫=famDoc.OwnerFamily.FamilyCategory;
类别 newSubCat = null;
if (!cat.SubCategories.Contains(subCatToAdd))
{
using (Transaction t = new Transaction(famDoc, "Add new or find existing subcategory"))
{
t.Start();
newSubCat = famDoc.Settings.Categories.NewSubcategory(cat, subCatToAdd);
GraphicsStyleType gst = GraphicsStyleType.Projection;
GraphicsStyle gs = newSubCat.GetGraphicsStyle(gst);
newSubCat.SetLineWeight(lineWeight, gst);
t.Commit();
}
}
我正在 Revit 族中创建一个类别,它是一种线型,在我设置它之后,它存在,但我在族中找不到它,但如果尝试重新创建它,revit 会创建一个错误,它已经存在.我尝试使用再生,但这不起作用。
ElementId solidLineId = LinePatternElement.GetSolidPatternId();
// The new linestyle will be a subcategory of the Lines category
Categories categories = doc.Settings.Categories;
Category lineCat = categories.get_Item(BuiltInCategory.OST_Lines);
using (Transaction t = new Transaction(doc, "Create LineStyle"))
{
t.Start();
Category newLineStyleCat = categories.NewSubcategory(lineCat, "Black-01-Solid");
newLineStyleCat.SetLineWeight(1, GraphicsStyleType.Projection);
newLineStyleCat.LineColor = new Color(28,28, 28);
newLineStyleCat.SetLinePatternId(solidLineId, GraphicsStyleType.Projection);
t.Commit();
}
这就是创建新线型的方法
分类猫=famDoc.OwnerFamily.FamilyCategory; 类别 newSubCat = null;
if (!cat.SubCategories.Contains(subCatToAdd))
{
using (Transaction t = new Transaction(famDoc, "Add new or find existing subcategory"))
{
t.Start();
newSubCat = famDoc.Settings.Categories.NewSubcategory(cat, subCatToAdd);
GraphicsStyleType gst = GraphicsStyleType.Projection;
GraphicsStyle gs = newSubCat.GetGraphicsStyle(gst);
newSubCat.SetLineWeight(lineWeight, gst);
t.Commit();
}
}