cad2008用c#二次开发的填充颜色的问题
cad2008用c#二次开发的填充颜色的问题,下面的代码画一个圆填充颜色没问题,我想画几根线组合的封闭图形(就是几个对象的封闭图),再填充颜色,该怎么写呢?
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
Circle circle = new Circle(new Point3d(10, 10, 0), Vector3d.ZAxis, 200);
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(HostApplicationServices.WorkingDatabase.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
ObjectIdCollection collection = new ObjectIdCollection();
collection.Add(circle.ObjectId);
// collection.Add(circle1.ObjectId);
Hatch hatch = new Hatch();
hatch.Elevation = 0;
hatch.HatchStyle = HatchStyle.Normal;
hatch.ColorIndex = 10;
hatch.PatternAngle = 0;
hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); //设置填充图案
// hatch.Associative = true;
hatch.AppendLoop(HatchLoopTypes.Default, collection); //设置填充边界 //
hatch.EvaluateHatch(true);
btr.AppendEntity(hatch);
trans.AddNewlyCreatedDBObject(hatch, true);
trans.Commit();
}
catch
{
ed.WriteMessage("Error ");
}
finally
{
trans.Dispose();
}