It must be a trick question but
public Hatch HatchPline(ObjectId id)
{
Database db=HostApplicationServices.WorkingDatabase;
Hatch h = new Hatch();
ObjectIdCollection hs = new ObjectIdCollection();
hs.Add(id);
using(Transaction tr=db.TransactionManager.StartTransaction())
{
Polyline p=tr.GetObject(id,OpenMode.ForRead) as Polyline;
h.SetDatabaseDefaults();
h.Elevation=p.Elevation;
h.Normal = p.Normal;
h.PatternScale = 1;
h.SetHatchPattern(HatchPatternType.PreDefined,"ANSI31");
}
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord Cspace = tr.GetObject
(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
Cspace.AppendEntity(h);
tr.AddNewlyCreatedDBObject(h, true);
h.Associative = true;
h.AppendLoop(HatchLoopTypes.External, hs);
tr.Commit();
}
return h;
}
This makes associative hatch