Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all the thankful persons.
Now I am making polyline hatch application but it does not work and error.
I am stunned because of this problem.
Followings are my error image and code.
I hope someone can help me. Thanks in advance.
public static void Hatch()
{
var documentManager = Application.DocumentManager;
var currentDocument = documentManager.MdiActiveDocument;
var db = currentDocument.Database;
var ed = currentDocument.Editor;
using (var tr = db.TransactionManager.StartOpenCloseTransaction())
{
var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in blockTable)
{
var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForWrite);
var PlineCls = RXObject.GetClass(typeof(Polyline));
if (btr.IsLayout)
{
foreach (ObjectId id in btr)
{
if (id.ObjectClass == PlineCls)
{
var pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);
string curlay = pline.Layer;
if (IsreqHatch(curlay) == true)
{
ObjectIdCollection acObjIdColl = new ObjectIdCollection();
acObjIdColl.Add(pline.ObjectId);
Hatch acHatch = new Hatch();
btr.AppendEntity(acHatch);
tr.AddNewlyCreatedDBObject(acHatch, true);
acHatch.SetDatabaseDefaults();
acHatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI31");
acHatch.Associative = true;
acHatch.HatchStyle = HatchStyle.Ignore;
acHatch.AppendLoop(HatchLoopTypes.Outermost, acObjIdColl);
acHatch.EvaluateHatch(true);
}
}
}
}
}
tr.Commit();
}
}
Solved! Go to Solution.