[求助]使用CAD的API怎样填充一个圆?
怎样填充一个圆?使用下面代码先创建一个圆然后填充,为什么运行到fillHatch.EvaluateHatch(false); 行时出现错误:“eAmbiguousOutput”?各位高手帮忙解决一下,先谢谢了。try
{
Database db = HostApplicationServices.WorkingDatabase;// 获得当前工作空间的数据库
using(Transaction trans = db.TransactionManager.StartTransaction())// begin the transaction
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;//获得块表
BlockTableRecord btr = bt.GetObject(OpenMode.ForWrite) as BlockTableRecord;//获得模型空间的块表记录
 oint3d Point = Point3d(10, 200, 200);
Circle pointCircle = new Circle(Point, Autodesk..Geometry.Vector3d.ZAxis, 10);
btr.AppendEntity(pointCircle);
trans.AddNewlyCreatedDBObject(pointCircle, true);
ObjectIdCollection circleIds = new ObjectIdCollection();
circleIds.Add(pointCircle.Id);
trans.Commit();
Hatch fillHatch = new Hatch();// 填充
fillHatch.SetDatabaseDefaults();
btr.AppendEntity(fillHatch);
trans.AddNewlyCreatedDBObject(fillHatch, true);
fillHatch.Associative = true;
fillHatch.AppendLoop(HatchLoopTypes.Default, circleIds);
fillHatch.EvaluateHatch(false);
} // Using
}// try
catch (System.Exception e)
{
CadEditor.Show(e.Message);
} 不好意思 ,代码修正一下, 各位高手帮帮办忙,谢谢。
try
{
Database db = HostApplicationServices.WorkingDatabase;// 获得当前工作空间的数据库
using(Transaction trans = db.TransactionManager.StartTransaction())// begin the transaction
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;//获得块表
BlockTableRecord btr = bt.GetObject(OpenMode.ForWrite) as BlockTableRecord;//获得模型空间的块表记录
 oint3d Point = Point3d(10, 200, 200);
Circle pointCircle = new Circle(Point, Autodesk.AutoCAD.Geometry.Vector3d.ZAxis, 10);
btr.AppendEntity(pointCircle);
trans.AddNewlyCreatedDBObject(pointCircle, true);
ObjectIdCollection circleIds = new ObjectIdCollection();
circleIds.Add(pointCircle.Id);
Hatch fillHatch = new Hatch();// 填充
fillHatch.SetDatabaseDefaults();
btr.AppendEntity(fillHatch);
trans.AddNewlyCreatedDBObject(fillHatch, true);
fillHatch.Associative = true;
fillHatch.AppendLoop(HatchLoopTypes.Default, circleIds);
fillHatch.EvaluateHatch(false);
trans.Commit();
} // Using
}// try
catch (System.Exception e)
{
CadEditor.Show(e.Message);
}
加上fillHatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI35");
页:
[1]