cad2008用c#二次开发的填充颜色的问题?

yuxrxll 2009-04-30 02:47:26
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();
}
...全文
165 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
UP!
aight 2009-06-05
  • 打赏
  • 举报
回复
帮楼主顶一下。
only_delusion 2009-04-30
  • 打赏
  • 举报
回复
顶下
蓝海D鱼 2009-04-30
  • 打赏
  • 举报
回复
up

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧