填充图案
public struct HatchPatternName
{
public static readonly string solid = "SOLID";
public static readonly string angle = "ANGLE";
public static readonly string ansi31 = "ANSI31";
public static readonly string ansi32 = "ANSI32";
public static readonly string ansi33 = "ANSI33";
public static readonly string ansi34 = "ANSI34";
public static readonly string ansi35 = "ANSI35";
public static readonly string ansi36 = "ANSI36";
public static readonly string ansi37 = "ANSI37";
public static readonly string ansi38 = "ANSI38";
public static readonly string arb816 = "AR-B816";
public static readonly string arb816C = "AR-B816C";
public static readonly string arb88 = "AR-B88";
public static readonly string arbrelm = "AR-BRELM";
public static readonly string arbrstd = "AR-BRSTD";
public static readonly string arbconc = "AR-CONC";
}
渐变填充图案
public struct HatchGradientName
{
public static readonly string gr_linear = "Linear";
public static readonly string gr_cylinder = "CyLinder";
public static readonly string gr_invcylinder = "InvcyLinder";
public static readonly string gr_spherical = "Spherical";
public static readonly string gr_hemispherical = "Hemispherical";
public static readonly string gr_curved = "Curved";
public static readonly string gr_invspherical = "Invspherical";
public static readonly string gr_invhemisperical = "Invhemispherical";
public static readonly string gr_invcurved = "Invcurved";
}
使用
[CommandMethod("HatchDemo")]
public void HatchDemo()
{
Database db = HostApplicationServices.WorkingDatabase;
ObjectId rect = db.AddRectToModelSpace(new Point2d(100,100),new Point2d(500,300));
ObjectId hatchId = ObjectId.Null;
ObjectIdCollection objIds = new ObjectIdCollection();
objIds.Add(rect);
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Hatch hatch = new Hatch();
hatch.HatchObjectType = HatchObjectType.GradientObject;
hatch.SetGradient(GradientPatternType.PreDefinedGradient, HatchTool.HatchGradientName.gr_hemispherical);
Color color1 = Color.FromColorIndex(ColorMethod.ByColor, 1);
Color color2 = Color.FromColorIndex(ColorMethod.ByColor, 2);
GradientColor gColor1 = new GradientColor(color1, 0);
GradientColor gColor2 = new GradientColor(color2, 1);
new GradientColor(color2, 1);
hatch.SetGradientColors(new GradientColor[] { gColor1, gColor2 });
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
btr.AppendEntity(hatch);
trans.AddNewlyCreatedDBObject(hatch, true);
hatch.Associative = true;
hatch.AppendLoop(HatchLoopTypes.Outermost, objIds);
hatch.EvaluateHatch(true);
trans.Commit();
}
}