void WFCSetup() { //Start by creating an array of the correct sizing for the given output. outputArray = new List <TileContainer> [outputArraySize, outputArraySize]; //Then loop through it, and put each possible tile in each spot. This is the unconstrainted step for (int x = 0; x < outputArraySize; x++) { for (int y = 0; y < outputArraySize; y++) { // TileContainer[] tempArray = new TileContainer[AllPossibleTiles.Count]; // AllPossibleTiles.CopyTo(tempArray); // outputArray[x, y] = new List<TileContainer>(tempArray.ToList<TileContainer>()); outputArray[x, y] = new List <TileContainer>(); foreach (TileContainer ToCopy in AllPossibleTiles) { outputArray[x, y].Add(ToCopy.DeepCopy()); } // outputArray[x, y].AddRange(AllPossibleTiles); //Now we go thorugh each option in the list and make the collisionx and y, the location of the square in case we need to find it, due to a collisison. foreach (TileContainer colhandler in outputArray[x, y]) { colhandler.collisionX = x; colhandler.collisionY = y; } } } }
public static void Paste() { Init(); if (ToCopy == null || ToCopy.Count == 0) { Ed.WriteMessage("\nБуфер пустой! Сначала нужно скопировать зоны покраски!"); return; } Base = Ed.GetPointWCS("Базовая точка"); // Группировка зон покраски по параметрам длины и высоты var sizeGroups = ToCopy.GroupBy(c => new { c.Length, c.Height }); using (var t = Db.TransactionManager.StartTransaction()) { // Получение определения блока зоны в текущем чертеже. ObjectId idBtrColorArea = GetColorAreaIdBtr(); var cs = Db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord; // Создание всех слоев для зон покраски checkLayers(); // Создание блока шаблона для каждого типоразмера зон покраски foreach (var size in sizeGroups) { var idBlRefTemplate = GetBlRefTemplate(size.Key.Length, size.Key.Height, idBtrColorArea, cs, t); var idColToCopy = new ObjectIdCollection(new[] { idBlRefTemplate }); foreach (var item in size) { copyItem(item, idColToCopy, cs.Id, t); } // Удаление блока шаблона var blRefTemplate = idBlRefTemplate.GetObject(OpenMode.ForWrite) as BlockReference; blRefTemplate.Erase(); } t.Commit(); } Ed.WriteMessage($"\nВставлено {ToCopy.Count} блоков зон покраски."); }