0

我正在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();
        }
4

1 回答 1

-1

这就是如何创建新的线条样式

类别 cat = 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();
            }
        }
于 2020-09-02T10:44:00.250 回答