为什么生成的填充没有面积属性?
各位老师好,为什么我用以下代码生成的填充,填充却没有面积属性?public class TEST02
{
public void ChangeHatch()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
ObjectIdCollection ids = new ObjectIdCollection();
using (DocumentLock @lock = doc.LockDocument())
{
using (Transaction trans = doc.TransactionManager.StartTransaction())
{
BlockTable blk = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord space = trans.GetObject(blk, OpenMode.ForWrite) as BlockTableRecord;
Circle circle = new Circle();
circle.Radius = 5000;
circle.Center = new Point3d(0, 0, 0);
space.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
trans.Commit();
ids.Add(circle.Id);
}
}
if (ids.Count > 0)
{
using (DocumentLock @lock = doc.LockDocument())
{
using (Transaction trans = doc.TransactionManager.StartTransaction())
{
BlockTable blk = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord space = trans.GetObject(blk, OpenMode.ForWrite) as BlockTableRecord;
// 生成新填充图案--------------
Hatch hatch = new Hatch();
hatch.HatchObjectType = HatchObjectType.HatchObject;
// hatch.HatchStyle = HatchStyle.Outer;
hatch.PatternAngle = 0;
hatch.PatternScale = 200;
hatch.Layer = "0";
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
hatch.ColorIndex = 2;
// hatch.Associative = true;
space.AppendEntity(hatch);
trans.AddNewlyCreatedDBObject(hatch, true);
hatch.AppendLoop(HatchLoopTypes.Outermost, ids);////图案添加边界环
hatch.EvaluateHatch(true);
trans.Commit();
}
}
}
}
}
首先排除cad版本问题,其次用惊惊博客或者ifox工程的生成填充方式(推荐),例如你可能遗留了hatch.SetDatabseDefault().
注明:
一次开发的填充算法:扫描线算法,而Acad的填充是一种含有隐匿操作的算法,这个世界除了桌子没有人知道它怎么干的,你可以查阅一下桌子和中望的官司里面有个三叶草《美国Autodesk公司起诉中望CAD侵权》 顺序应该按如下:
space.AppendEntity(hatch);
trans.AddNewlyCreatedDBObject(hatch, true);
hatch.Associative = true;
页:
[1]