public static void CreateTransmittalAndPdf() { List <Sheet> dict = new List <Sheet>(); List <PrintModel> printModels = new List <PrintModel>(); Active.Document.SendStringToExecute("REGENALL ", true, false, true); using (Transaction tr = Active.Database.TransactionManager.StartTransaction()) { //фильтр для выбора только блока BlockSelector blockSelector = new BlockSelector(); blockSelector.GetFilterForSelectBlockId(); var res = blockSelector.SelectionResult; if (res.Status != PromptStatus.OK) { Active.Editor.WriteMessage("Надо выбрать блок"); return; } SelectionSet selSet = res.Value; ObjectId[] idArrayTemp = selSet.GetObjectIds(); ObjectIdCollection idArray = new ObjectIdCollection(); foreach (var objectId in idArrayTemp) { BlockReference blRef = (BlockReference)tr.GetObject(objectId, OpenMode.ForRead); BlockTableRecord block = tr.GetObject(blRef.DynamicBlockTableRecord, OpenMode.ForRead) as BlockTableRecord; if (!(block is null)) { string blockName = block.Name; if (blockName == "Формат" | blockName == "ФорматM25") { idArray.Add(objectId); } } } GetSheetsFromBlocks(Active.Editor, dict, tr, idArray); string selAttrName = "НОМЕР_ЛИСТА"; GetPrintParametersToPdf(Active.Editor, printModels, tr, idArray, selAttrName); Utils utils = new Utils(); //utils.CreateOnlyVed(dict); utils.CreateJsonFile(dict); foreach (var printModel in printModels) { //Active.Editor.WriteMessage("{0} печатаем ", printModel.DocNumber); PlotCurrentLayout(printModel.DocNumber, printModel); } //utils.CreateOnlytrans(dict); tr.Commit(); } }
public void CreatePdfName() { Active.Document.SendStringToExecute("REGENALL ", true, false, true); Dictionary <string, string> attrList = new Dictionary <string, string>(); Window1 window = new Window1(new BlockViewModel(attrList)); Application.ShowModalWindow(window); if (window.isClicked) { //ObjectIdCollection objectIds = Utils.SelectDynamicBlockReferences(); List <Sheet> dict = new List <Sheet>(); using (Transaction tr = Active.Database.TransactionManager.StartTransaction()) { BlockSelector blockSelector = new BlockSelector(); blockSelector.GetFilterForSelectBlockId(window.BlockName); bool isExec = true; var res = blockSelector.SelectionResult; if (res.Status != PromptStatus.OK) { isExec = false; Active.Editor.WriteMessage("Надо выбрать блок"); } if (isExec) { SelectionSet selSet = res.Value; ObjectId[] idArrayTemp = selSet.GetObjectIds(); //ObjectIdCollection idArray = new ObjectIdCollection(idArrayTemp); //TODO printing X Y //string selAttrName = attributeName.AttributeName; FileNameCreator fileNameCreator = new FileNameCreator(window, idArrayTemp); //GetPrintParametersToPdf(Active.Editor, printModels, tr, objectIds, selAttrName); fileNameCreator.GetPrintParametersToPdf(tr); Utils utils = new Utils(); utils.CreateJsonFile(dict); foreach (var printModel in fileNameCreator.GetPrintModels()) { PlotCurrentLayout(printModel.DocNumber, printModel); } } tr.Commit(); } } }
public static void CreateDwg() { Active.Document.SendStringToExecute("REGENALL ", true, false, true); Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Dictionary <ObjectId, bool> layersDictionary = LayerManipulation.GetLayersIsBlockedCol(); if (doc == null) { return; } doc.LockOrUnlockLayers(false, ignoreCurrent: false, lockZero: true); bool isExec = true; using (Transaction tr = Active.Database.TransactionManager.StartTransaction()) { BlockSelector blockSelector = new BlockSelector(); blockSelector.GetFilterForSelectBlockId(); var res = blockSelector.SelectionResult; if (res.Status != PromptStatus.OK) { isExec = false; Active.Editor.WriteMessage("Надо выбрать блок"); } if (isExec) { SelectionSet selSet = res.Value; ObjectId[] idArrayTemp = selSet.GetObjectIds(); //idArray.Select(id => (BlockReference) tr.GetObject(id, OpenMode.ForRead)) // .Where(br => // ((BlockTableRecord) tr.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead)).Name == // "Формат") // .Select(br => br.ObjectId); ObjectIdCollection idArray = new ObjectIdCollection(); foreach (var objectId in idArrayTemp) { BlockReference blRef = (BlockReference)tr.GetObject(objectId, OpenMode.ForRead); BlockTableRecord block = tr.GetObject(blRef.DynamicBlockTableRecord, OpenMode.ForRead) as BlockTableRecord; string blockName = block.Name; if (blockName == "Формат") { idArray.Add(objectId); } else if (blockName == "ФорматM25") { idArray.Add(objectId); } //Active.Document.Editor.WriteMessage(blockName); } //MyCommands.GetSheetsFromBlocks(Active.Editor, dict, tr, idArray); //MyCommands.GetPrintParametersToPdf(Active.Editor, printModels, tr, idArray); //Active.Editor.WriteMessage("печать {0} - {1}", printModels[0].DocNumber, printModels.Count); foreach (ObjectId objectId in idArray) { ObjectCopier objectCopier = new ObjectCopier(objectId); ObjectIdCollection objectIds = objectCopier.SelectCrossingWindow(); BlockReference blkRef = (BlockReference)tr.GetObject(objectId, OpenMode.ForRead); string selAttrName = "НОМЕР_ЛИСТА"; string fileName = Utils.GetBlockAttributeValue(blkRef, selAttrName); //HostApplicationServices hs = HostApplicationServices.Current; //string path = Application.GetSystemVariable("DWGPREFIX"); //hs.FindFile(doc.Name, doc.Database, FindFileHint.Default); string createdwgFolder = Path.GetFileNameWithoutExtension(db.OriginalFileName); string folderdwg = Path.GetDirectoryName(db.OriginalFileName); string dwgFilename = Path.Combine(folderdwg, fileName + ".dwg"); objectCopier.CopyObjectsNewDatabases(objectIds, dwgFilename); // objectCopier.CopyObjectsBetweenDatabases(objectIds, dwgFilename); Active.Editor.WriteMessage("{0} сохранен", dwgFilename); string newFileName = ZoomFilesAndSave(dwgFilename); File.Delete(dwgFilename); System.IO.File.Move(newFileName, dwgFilename); } } doc.LockLayers(layersDictionary); tr.Commit(); } }