实现删除一些线条
本帖最后由 作者 于 2010-11-28 10:14:11 编辑 <br /><br /> <p><font face="Verdana">如何实现删除以下这红色长方形,只保留填充?</font></p><p> </p>
<p><font face="Verdana">谢谢狐哥!!在你的帮助下<font face="Verdana">问题终于解决了。。。</font></font></p> <p>先用选择集过滤出红色的长方形</p>
<p>再</p>
<div class="Element5">DBObject.Erase Method ()</div> <p><font face="Verdana">比喻我是以下方法创建的圆,然后填充圆,最后如何删除那圆,而保留填充</font></p>
<p><font face="Verdana">ObjectId Cirent01 = AddCircle(centerPoint, 6);</font></p> <p>DBObject ent = tr.GetObject(Cirent01, OpenMode.ForWrite);</p>ent.Erase(); 狐哥,我是按以下方式做的,我需要如何删除
public void CreateHatch1()
{
// 创建填充边界.
ObjectId loopId2 = ModelSpace.AddCircle(new Point3d(150, 50, 0), 40);
// 定义一个ObjectId集合.
ObjectIdCollection loops1 = new ObjectIdCollection();
loops2.Add(loopId2);
// 定义一个ObjectId集合数组.
ObjectIdCollection[] loops = new ObjectIdCollection;
loops.SetValue(loops1, 1);
// 实施填充.
ObjectId hatchId = ModelSpace.AddHatch(loops, 0, "ANSI31", ModelSpace.Rad2Ang(30), 2);
//程序运行到了这里如何删除[创建填充边界Circle,保留填充线]
}
<p> </p>
<p>using(var tr = .......)</p>
<p>{</p>
<p>foreach(Object id in loops1)</p>
<p>{</p>
<p>DBObject ent = tr.GetObject(Cirent01, OpenMode.ForWrite);</p>
<p>ent.Erase(); </p>
<p>}</p>
<p>}</p> 这样是可以删除,但是那填充线也没有了,请问是什么原因?
public static void AddHatch(Transaction tr, BlockTableRecord btr, IEnumerable<ObjectIdCollection> idCollections, HatchPatternType patternType, string patternName, double patternAngle, double patternScale)
{
Hatch hatch =
new Hatch
{
PatternAngle = patternAngle,
PatternScale = patternScale,
};
hatch.SetDatabaseDefaults();
hatch.SetHatchPattern(patternType, patternName);
btr.AppendEntity(hatch);
tr.AddNewlyCreatedDBObject(hatch, true);
hatch.Associative = false;
foreach (var ids in idCollections)
{
hatch.AppendLoop(HatchLoopTypes.External, ids);
}
}
public static void Test2()
{
var db = HostApplicationServices.WorkingDatabase;
var doc = Application.DocumentManager.GetDocument(db);
var ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
var btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
Circle c = new Circle(Point3d.Origin, Vector3d.ZAxis, 8);
btr.AppendEntity(c);
tr.AddNewlyCreatedDBObject(c, true);
AddHatch(tr, btr, new List<ObjectIdCollection> { new ObjectIdCollection { c.ObjectId } }, HatchPatternType.CustomDefined, "ansi31", 0, 1);
c.Erase();
tr.Commit();
}
}
<p>谢谢狐哥</p>
<p>现在可以了,但是还有一点不明白,在使用c.Erase();时,可以删除那个圆,如果是10个圆这个删除需要如何写啊</p> <p>汗</p>
<p>如果是集合,那就foreach</p>
页:
[1]
2