public static void bublick() {
Document doc = acApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction()) {
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
// 1. Создаем объект штриховки
Hatch Hobj = new Hatch();
Hobj.SetHatchPattern(HatchPatternType.CustomDefined, "SOLID");
// 2. Создаем объекты окружностей
Circle max_Cir = new Circle(); max_Cir.Radius = 1;
Circle min_Cir = new Circle(); min_Cir.Radius = 0.5;
// 3. добавляем записи в таблицу
ObjectId idmax = btr.AppendEntity(max_Cir);
ObjectId idmin = btr.AppendEntity(min_Cir);
btr.AppendEntity(Hobj);
tr.AddNewlyCreatedDBObject(max_Cir, true);
tr.AddNewlyCreatedDBObject(min_Cir, true);
tr.AddNewlyCreatedDBObject(Hobj, true);
// 4. Назначение ассоциации
ObjectId[] ids = { idmax, idmin };
ObjectIdCollection coll = new ObjectIdCollection(ids);
acadnet_Hath_LoopsObj(ref Hobj, coll,
HatchLoopTypes.Outermost);
tr.Commit();
}
}
public static void acadnet_Hath_LoopsObj(ref Hatch entH,
ObjectIdCollection IDColl,
HatchLoopTypes mode) {
entH.UpgradeOpen();
entH.Associative = true;
if (IDColl != null) {
entH.AppendLoop(mode, IDColl);
entH.EvaluateHatch(true);
}
}