BuildingCoder.CmdCreateLineStyle.CreateLineStyle C# (CSharp) Метод

CreateLineStyle() публичный Метод

Create a new line style using NewSubcategory
public CreateLineStyle ( Document doc ) : void
doc Document
Результат void
        void CreateLineStyle(Document doc)
        {
            // Use this to access the current document in a macro.
              //
              //Document doc = this.ActiveUIDocument.Document;

              // Find existing linestyle.  Can also opt to
              // create one with LinePatternElement.Create()

              FilteredElementCollector fec
            = new FilteredElementCollector( doc )
              .OfClass( typeof( LinePatternElement ) );

              LinePatternElement linePatternElem = fec
            .Cast<LinePatternElement>()
            .First<LinePatternElement>( linePattern
              => linePattern.Name == "Long dash" );

              // 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 ) )
              {
            t.Start( "Create LineStyle" );

            // Add the new linestyle

            Category newLineStyleCat = categories
              .NewSubcategory( lineCat, "New LineStyle" );

            doc.Regenerate();

            // Set the linestyle properties
            // (weight, color, pattern).

            newLineStyleCat.SetLineWeight( 8,
              GraphicsStyleType.Projection );

            newLineStyleCat.LineColor = new Color(
              0xFF, 0x00, 0x00 );

            newLineStyleCat.SetLinePatternId(
              linePatternElem.Id,
              GraphicsStyleType.Projection );

            t.Commit();
              }
        }
CmdCreateLineStyle