public void ListAttributes() { Dictionary <string, string> attrList = new Dictionary <string, string>(); MainWindow window = new MainWindow(new BlockViewModel(attrList)); Application.ShowModalWindow(window); if (window.isClicked == true) { //var objectIds = Utils.GetAllCurrentSpaceBlocksByName(window.NameBlock.Text); ObjectId mSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(Active.Database); ObjectIdCollection objectIds = Utils.SelectDynamicBlockReferences(mSpaceId); List <Sheet> dict = new List <Sheet>(); List <PrintModel> printModels = new List <PrintModel>(); BlockAttribute objectNameEn = window.ComboObjectNameEn.SelectedItem as BlockAttribute; BlockAttribute objectNameRu = window.ComboObjectNameRu.SelectedItem as BlockAttribute; BlockAttribute position = window.ComboBoxPosition.SelectedItem as BlockAttribute; BlockAttribute nomination = window.ComboBoxNomination.SelectedItem as BlockAttribute; BlockAttribute comment = window.ComboBoxComment.SelectedItem as BlockAttribute; BlockAttribute trItem = window.ComboBoxTrItem.SelectedItem as BlockAttribute; BlockAttribute trDocNumber = window.ComboBoxTrDocNumber.SelectedItem as BlockAttribute; BlockAttribute trDocTitleEn = window.ComboBoxTrDocTitleEn.SelectedItem as BlockAttribute; BlockAttribute trDocTitleRu = window.ComboBoxTrDocTitleRu.SelectedItem as BlockAttribute; AttributModel attributModel = new AttributModel(objectNameEn, objectNameRu, position, nomination, comment, trItem, trDocNumber, trDocTitleEn, trDocTitleRu); using (Transaction tr = Active.Database.TransactionManager.StartTransaction()) { MyCommands.GetSheetsFromBlocks(Active.Editor, dict, tr, objectIds); string selAttrName = "НОМЕР_ЛИСТА"; MyCommands.GetPrintParametersToPdf(Active.Editor, printModels, tr, objectIds, selAttrName); if (window.transmittalCheckBox.IsChecked == true) { Utils utils = new Utils(); utils.CreateOnlyVed(dict); utils.CreateOnlytrans(dict); foreach (var printModel in printModels) { PlotCurrentLayout(printModel.DocNumber, printModel); } } else { //Utils utils = new Utils(); //utils.CreateOnlyVed(dict); foreach (var printModel in printModels) { //PlotCurrentLayout(printModel.DocNumber, printModel.BlockExtents3d, printModel.StampViewName); } } tr.Commit(); } } }
/// <summary> /// создает колекцию листов из блоков штампа /// </summary> /// <param name="ed">editor</param> /// <param name="dict"> коллекция листов</param> /// <param name="tr"> транзакция </param> /// <returns>коллекция листов </returns> public static List <Sheet> GetSheetsFromBlocks(Editor ed, List <Sheet> dict, Transaction tr, ObjectIdCollection objectIdCollection, AttributModel attributModel) { string objectNameEn = attributModel.ObjectNameEn; string objectNameRu = attributModel.ObjectNameRu; string listNumber = attributModel.Position; string nomination = attributModel.Nomination; string commentAttr = attributModel.Comment; string trDocTitleEn = attributModel.TrDocTitleEn; string trDocTitleRu = attributModel.TrDocTitleRu; string sheetNumber = "", docNumber = "", comment = "", objectNameEng = "", docTitleEng = "", objectNameRus = "", docTitleRu = ""; foreach (ObjectId blkId in objectIdCollection) { BlockReference blkRef = (BlockReference)tr.GetObject(blkId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead); Extents3d extents3d = blkRef.GeometricExtents; ed.WriteMessage("\nBlock:{0} габариты {1} ", btr.Name, extents3d.MinPoint.ToString(), extents3d.MaxPoint.ToString()); btr.Dispose(); AttributeCollection attCol = blkRef.AttributeCollection; var attrDict = AttributeExtensions.GetAttributesValues(blkRef); docTitleEng = attrDict.FirstOrDefault(x => x.Key == objectNameEn).Value; docTitleRu = attrDict.FirstOrDefault(x => x.Key == objectNameRu).Value; sheetNumber = attrDict.FirstOrDefault(x => x.Key == listNumber).Value; docNumber = attrDict.FirstOrDefault(x => x.Key == nomination).Value; comment = attrDict.FirstOrDefault(x => x.Key == commentAttr).Value; //transItem = attrDict.FirstOrDefault(x => x.Key == trItem).Value; objectNameEng = attrDict.FirstOrDefault(x => x.Key == trDocTitleEn).Value; objectNameRus = attrDict.FirstOrDefault(x => x.Key == trDocTitleRu).Value; } return(dict); }