public void runUpdate() { modelsCellsForUpdate_.Clear(); cellFrames_.Clear(); ElementScanCriteria scanCriteria = new ElementScanCriteriaClass(); scanCriteria.ExcludeNonGraphical(); scanCriteria.IncludeOnlyVisible(); scanRecurse(App.ActiveModelReference, scanCriteria, true); // TODO запустить progressBar foreach (CellElement cell in checkedCellsForUpdate_) { var frame = cellFrames_[cell.MdlElementRef()]; AppTF.ModelReferenceRewriteFrameList(cell.ModelReference, frame); } }
public void scanForUpdate(TreeView treeView) // TODO без TreeView { treeView.AfterCheck -= TreeView_AfterCheck; treeView.AfterCheck += TreeView_AfterCheck; checkedCellsForUpdate_.Clear(); modelsCellsForUpdate_.Clear(); cellFrames_.Clear(); /* TODO * Поиск: * - по имени Cell; * - по CatalogGroupName */ ElementScanCriteria scanCriteria = new ElementScanCriteriaClass(); scanCriteria.ExcludeNonGraphical(); scanCriteria.IncludeOnlyVisible(); scanRecurse(App.ActiveModelReference, scanCriteria, false); treeView.Nodes.Clear(); foreach (var pair in modelsCellsForUpdate_) { ModelReference model = pair.Key; List <CellElement> updateList = pair.Value; TreeNode modelNode = treeView.Nodes.Add(model.Name + $" ({updateList.Count})"); foreach (var cell in updateList) { TFFrameListClass frame = cellFrames_[cell.MdlElementRef()]; TreeNode cellNode = modelNode.Nodes.Add(cell.ID.ToString()); cellNode.Tag = cell; } modelNode.Checked = true; } }
private void ButtonRozdziel_Click(object sender, EventArgs e) { string iFileName = textBoxFileName.Text; StreamWriter logFile = new StreamWriter(new FileStream(iFileName.Substring(0, iFileName.LastIndexOf(".", StringComparison.Ordinal)) + ".log", FileMode.Create), Encoding.UTF8); logFile.WriteLine("Rozdielanie pliku: {0}\n", iFileName); MicroStationDGN.Application oMstn = new MicroStationDGN.Application(); DesignFile iFile = oMstn.OpenDesignFile(iFileName, true); if (iFile.Models.Count > 1) { MessageBox.Show(@"Ilość modeli w pliku większa niż 1 !"); Application.Exit(); } ModelReference modelIn = iFile.Models[1]; foreach (Level levelIn in iFile.Levels) { string levelInName = levelIn.Name; if (levelIn.IsInUse) { logFile.WriteLine("warstwa {0}: uzywana", levelInName); File.Copy(iFileName, @"C:\temp\" + levelIn.Name + ".dgn", true); DesignFile oFile = oMstn.OpenDesignFileForProgram(@"C:\temp\" + levelIn.Name + ".dgn", false); ModelReference modelOut = oFile.Models[1]; foreach (Level levelOut in oFile.Levels) { string levelOutName = levelOut.Name; if (levelOutName != levelInName) { if (levelOut.IsInUseWithinModel(modelOut)) { ElementScanCriteria elementScanCriteriaOut = new ElementScanCriteriaClass(); elementScanCriteriaOut.ExcludeAllLevels(); elementScanCriteriaOut.IncludeLevel(levelOut); ElementEnumerator elementEnumeratorOut = modelOut.Scan(elementScanCriteriaOut); //Array elementOut = elementEnumeratorOut.BuildArrayFromContents(); while (elementEnumeratorOut.MoveNext()) { modelOut.RemoveElement(elementEnumeratorOut.Current); } } if (!levelOut.IsInUse && levelOut.Number != 0) { oFile.DeleteLevel(levelOut); } } } oFile.RewriteLevels(); oFile.Save(); oFile.Close(); } else { logFile.WriteLine("warstwa {0}: brak", levelInName); } } logFile.Close(); iFile.Close(); oMstn.Quit(); }