I am creating a category in a Revit family that is a linestyle and after i set it, it exists but i just cant find it in the family and yet i f try to recreate it revit creates an error that it already exists. i tried using regeneration and this doesnt work.
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();
}
This is how new linestyles can be created
Category cat = famDoc.OwnerFamily.FamilyCategory; Category newSubCat = null;