图案填充
Database db = HostApplicationServices.WorkingDatabase;
ObjectIdCollection objIds = new ObjectIdCollection();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
Circle circle = new Circle(new Point3d(0, 0, 0), new Vector3d(0, 0, 1), 100);
ObjectId objid = btr.AppendEntity(circle);
objIds.Add(objid);
trans.AddNewlyCreatedDBObject(circle, true);
Hatch hatch = new Hatch();
hatch.PatternScale = 5;
//设置背景色
hatch.BackgroundColor = Color.FromRgb(19, 48, 236);
//设置填充图案颜色
hatch.ColorIndex = 10;
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI32");
btr.AppendEntity(hatch);
trans.AddNewlyCreatedDBObject(hatch, true);
hatch.PatternAngle = Math.PI / 4;
hatch.Associative = true;
hatch.AppendLoop(HatchLoopTypes.Outermost, objIds);
hatch.EvaluateHatch(true);
trans.Commit();
}