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