步骤:

函数实现:
public static ObjectId HatchEntity(this Database db,double patternScale,string patternName,double patternAngle,ObjectId entId)
{
ObjectId hatchId=ObjectId.Null;
using (Transaction transaction = db.TransactionManager.StartTransaction())
{
Hatch hatch = new Hatch();
hatch.PatternScale = patternScale;
hatch.SetHatchPattern(HatchPatternType.PreDefined, patternName);
BlockTable bt = transaction.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = transaction.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
hatchId=btr.AppendEntity(hatch);
transaction.AddNewlyCreatedDBObject(hatch, true);
hatch.PatternAngle = patternAngle;
hatch.Associative = true;
ObjectIdCollection obIds=new ObjectIdCollection();
obIds.Add(entId);
hatch.AppendLoop(HatchLoopTypes.Outermost, obIds);
hatch.EvaluateHatch(true);
transaction.Commit();
}
return hatchId;
}