Сообщество программистов Autodesk в СНГ

ADN Club => AutoCAD .NET API => Тема начата: Дамир Михайлович от 09-08-2018, 14:27:30

Название: не валидируется Validate
Отправлено: Дамир Михайлович от 09-08-2018, 14:27:30
Разбираюсь с разными вариантами печати dwg файлов. В данный момент не получается решить проблему.
На строке 152
Код - C# [Выбрать]
  1. piv.Validate(pi);
возникает ошибка. Загружаю плагин командой netload. В ходе выполнения должен открываться другой чертёж-его и печатаю. Если работать с текущим чертежом, печатается корректно.
Код - C# [Выбрать]
  1. using Autodesk.AutoCAD.Runtime;
  2. using Autodesk.AutoCAD.ApplicationServices;
  3. using Autodesk.AutoCAD.DatabaseServices;
  4. using Autodesk.AutoCAD.EditorInput;
  5. using Autodesk.AutoCAD.Geometry;
  6. using Autodesk.AutoCAD.PlottingServices;
  7. using System;
  8. using System.IO;
  9. using System.Collections.Generic;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using System.Diagnostics;
  13. using System.Threading;
  14. using System.Windows.Forms;
  15. using System.Collections.Specialized;
  16.  
  17. namespace Plot1
  18. {
  19.  
  20.     public class Commands : IExtensionApplication
  21.     {
  22.  
  23.         [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  24.         static extern int acedTrans13(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  25.         [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  26.         static extern int acedTrans12(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  27.         static int acedTrans(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result)
  28.         {
  29.             return Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 12 ?
  30.               acedTrans13(point, fromRb, toRb, disp, result) :
  31.               acedTrans12(point, fromRb, toRb, disp, result);
  32.         }
  33.  
  34.  
  35.         public void Initialize()
  36.         {
  37.             PlotPDF();
  38.         }
  39.  
  40.         public void Terminate()
  41.         {
  42.  
  43.         }
  44.        
  45.         static public void PlotPDF()
  46.         {
  47.  
  48.             string line = @"D:\autocad\qq.dwg";          
  49.  
  50.             Database db = new Database(false, false);
  51.            
  52.             db.ReadDwgFile(line, FileShare.ReadWrite, true, String.Empty);
  53.             db.UpdateExt(true);
  54.            
  55.             Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(line, false);
  56.            
  57.             if (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument != doc)
  58.             {
  59.                 Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc;
  60.             }
  61.            
  62.             Transaction tr = db.TransactionManager.StartTransaction();
  63.  
  64.             short bgp = (short)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("BACKGROUNDPLOT");
  65.             Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
  66.             using (tr)
  67.             {
  68.                 BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
  69.                
  70.                 // A PlotEngine does the actual plotting
  71.                 // (can also create one for Preview)
  72.                 if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
  73.                 {
  74.                     PlotEngine pe = PlotFactory.CreatePublishEngine();
  75.                     using (pe)
  76.                     {
  77.                         // Collect all the paperspace layouts
  78.                         // for plotting
  79.                         ObjectIdCollection layoutsToPlot = new ObjectIdCollection();
  80.                         foreach (ObjectId btrId in bt)
  81.                         {
  82.                             BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  83.                             if ((btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) || (btr.IsLayout && btr.Name.ToUpper() == BlockTableRecord.ModelSpace.ToUpper()))
  84.                             {
  85.                                 layoutsToPlot.Add(btrId);
  86.                             }
  87.                         }
  88.                         // Create a Progress Dialog to provide info
  89.                         // and allow thej user to cancel                        
  90.                         PlotProgressDialog ppd = new PlotProgressDialog(false, layoutsToPlot.Count, true);
  91.                         using (ppd)
  92.                         {                            
  93.                             int numSheet = 1;
  94.                             foreach (ObjectId btrId in layoutsToPlot)
  95.                             {
  96.                                 PlotInfo pi = new PlotInfo();
  97.                                 PlotInfoValidator piv = new PlotInfoValidator();
  98.                                 piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
  99.                                 BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  100.                                 Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);
  101.                                 // We need a PlotSettings object
  102.                                 // based on the layout settings
  103.                                 // which we then customize
  104.                                 PlotSettings ps = new PlotSettings(lo.ModelType);
  105.  
  106.                                 ps.CopyFrom(lo);
  107.  
  108.                                 // The PlotSettingsValidator helps
  109.                                 // create a valid PlotSettings object
  110.  
  111.  
  112.                                 PlotSettingsValidator psv = PlotSettingsValidator.Current;//текущий доk
  113.  
  114.  
  115.  
  116.                                 // We'll plot the extents, centered and
  117.                                 // scaled to fit
  118.                              
  119.                                 psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
  120.                                 psv.SetUseStandardScale(ps, true);
  121.                                 psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
  122.                                 psv.SetPlotCentered(ps, true);
  123.                                
  124.                                 PlotRotation Rot = PlotRotation.Degrees000;
  125.  
  126.                                 if ((lo.Limits.MaxPoint.X < lo.Limits.MaxPoint.Y))
  127.                                 {
  128.                                     Rot = PlotRotation.Degrees090;
  129.                                 }
  130.                                 psv.SetPlotRotation(ps, Rot);                                
  131.  
  132.                                 // We'll use the standard DWFx PC3, as
  133.                                 // this supports multiple sheets
  134.                                                              
  135.                                 psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", null);
  136.                                
  137.                                 psv.RefreshLists(ps);
  138.  
  139.  
  140.                                 // We need a PlotInfo object
  141.                                 // linked to the layout                                
  142.                                 pi.Layout = lo.Id;
  143.                                                              
  144.  
  145.  
  146.                                 // Make the layout we're plotting current
  147.                                 LayoutManager.Current.CurrentLayout = lo.LayoutName;
  148.                                 // We need to link the PlotInfo to the
  149.                                 // PlotSettings and then validate it
  150.                                 pi.OverrideSettings = ps;
  151.                                                                
  152.                                 piv.Validate(pi);
  153.                                
  154.  
  155.                                 if (numSheet == 1)
  156.                                 {
  157.                                     ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Обработка документа");
  158.                                     ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Отмена");
  159.                                     ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Отмена листа");
  160.                                     ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Обработка слоёв");
  161.                                     ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Обработка листа");
  162.                                     ppd.LowerPlotProgressRange = 0;
  163.                                     ppd.UpperPlotProgressRange = 100;
  164.                                     ppd.PlotProgressPos = 0;
  165.                                     // Let's start the plot, at last
  166.                                     ppd.OnBeginPlot();                                    
  167.                                     ppd.IsVisible = true;
  168.                                     pe.BeginPlot(ppd, null);
  169.                                     // We'll be plotting a single document                                    
  170.                                     pe.BeginDocument(pi, doc.Name, null, 1, true, "d:\\test-multi-sheet");
  171.                                 }
  172.                                 // Which may contain multiple sheets
  173.                                 ppd.StatusMsgString = "Обработка " + doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - страница " + numSheet.ToString() + " из " + layoutsToPlot.Count.ToString();
  174.                                 ppd.OnBeginSheet();
  175.                                 ppd.LowerSheetProgressRange = 0;
  176.                                 ppd.UpperSheetProgressRange = 100;
  177.                                 ppd.SheetProgressPos = 0;
  178.                                 PlotPageInfo ppi = new PlotPageInfo();
  179.                                 pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
  180.                                 pe.BeginGenerateGraphics(null);
  181.                                 ppd.SheetProgressPos = 50;
  182.                                 pe.EndGenerateGraphics(null);
  183.                                 // Finish the sheet
  184.                                 pe.EndPage(null);
  185.                                 ppd.SheetProgressPos = 100;
  186.                                 ppd.OnEndSheet();
  187.                                 numSheet++;
  188.                             }
  189.  
  190.                             // Finish the document
  191.                             pe.EndDocument(null);
  192.                             // And finish the plot
  193.                             ppd.PlotProgressPos = 100;
  194.                             ppd.OnEndPlot();
  195.                             pe.EndPlot(null);
  196.                             Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", bgp);
  197.                         }
  198.                     }
  199.                 }
  200.                 else
  201.                 {                    
  202.                     MessageBox.Show("Принтер занят");
  203.                 }
  204.             }
  205.         }
  206.     }
  207. }
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 09-08-2018, 14:31:56
1. Из кода я не понял как запускается печать. Это команда?
2. В коде сначала создаётся Database и в неё читается файл, а потом идёт попытка его открыть как документ. Так делать нельзя.
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 09-08-2018, 14:37:02
1. Из кода я не понял как запускается печать. Это команда?
Открывается acad, из него netload грузит плагин. в коде прописан путь до чертежа, который откроется для печати.

2. В коде сначала создаётся Database и в неё читается файл, а потом идёт попытка его открыть как документ. Так делать нельзя.
Спасибо! Исправлю!
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 09-08-2018, 14:42:31
Открывается acad, из него netload грузит плагин. в коде прописан путь до чертежа, который откроется для печати.
Это вторая ошибка. Так делать не следует.
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 09-08-2018, 14:46:30
Какая конкретно ошибка (исключение) возникает на строке:
Код - C# [Выбрать]
  1. piv.Validate(pi);
?
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 09-08-2018, 14:50:51
Каким образом тогда я могу реализовать пакетную печать?
Publish мне не подходит, поскольку для каждого листа нужно будет отдельно настраивать параметры печати.
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 09-08-2018, 14:53:12
Каким образом тогда я могу реализовать пакетную печать?
Я имел в виду, что вызывать в методе Initialize обращение к элементам чертежа - это очень плохая манера. Оформи в виде команды и запускай её.
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 10-08-2018, 07:36:58
Каким образом тогда я могу реализовать пакетную печать?
Я имел в виду, что вызывать в методе Initialize обращение к элементам чертежа - это очень плохая манера. Оформи в виде команды и запускай её.

Всё поправил как вы сказали.
Текст ошибки:
Autodesk.AutoCAD.Runtime.Exception
  HResult=0x80131500
  Сообщение = eLayoutNotCurrent
  Источник = accoremgd
  Трассировка стека:
   at Autodesk.AutoCAD.PlottingServices.PlotInfoValidator.Validate(PlotInfo info)
   at Plot.Commands.PlotPDF() in D:\VS projects\example7\Class1.cs:line 152
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 10-08-2018, 11:24:53
Всё поправил как вы сказали.
Где? Не вижу кода.
Сообщение = eLayoutNotCurrent
Лист не текущий (активный). Нужно чтобы был текущим.
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 10-08-2018, 12:20:05
Перенёс открытие базы данных в транзакции


Код - C# [Выбрать]
  1. using Autodesk.AutoCAD.Runtime;
  2. using Autodesk.AutoCAD.ApplicationServices;
  3. using Autodesk.AutoCAD.DatabaseServices;
  4. using Autodesk.AutoCAD.EditorInput;
  5. using Autodesk.AutoCAD.Geometry;
  6. using Autodesk.AutoCAD.PlottingServices;
  7. using System;
  8. using System.IO;
  9. using System.Collections.Generic;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using System.Diagnostics;
  13. using System.Threading;
  14. using System.Windows.Forms;
  15. using System.Collections.Specialized;
  16.  
  17. namespace Plot1
  18. {
  19.  
  20.     public class Commands : IExtensionApplication
  21.     {
  22.  
  23.         [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  24.         static extern int acedTrans13(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  25.         [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  26.         static extern int acedTrans12(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  27.         static int acedTrans(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result)
  28.         {
  29.             return Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 12 ?
  30.               acedTrans13(point, fromRb, toRb, disp, result) :
  31.               acedTrans12(point, fromRb, toRb, disp, result);
  32.         }
  33.         [CommandMethod("PlotPDF")]
  34.  
  35.  
  36.         static public void PlotPDF()
  37.         {
  38.  
  39.             string line = @"D:\autocad\qq.dwg";
  40.  
  41.  
  42.             Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(line, false);
  43.  
  44.             if (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument != doc)
  45.             {
  46.                 Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc;
  47.             }
  48.  
  49.             Transaction tr = doc.TransactionManager.StartTransaction();
  50.  
  51.             short bgp = (short)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("BACKGROUNDPLOT");
  52.             Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
  53.             using (tr)
  54.             {
  55.                 Database db = doc.Database;
  56.  
  57.                 BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
  58.  
  59.                 // A PlotEngine does the actual plotting
  60.                 // (can also create one for Preview)
  61.                 if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
  62.                 {
  63.                     PlotEngine pe = PlotFactory.CreatePublishEngine();
  64.                     using (pe)
  65.                     {
  66.                         // Collect all the paperspace layouts
  67.                         // for plotting
  68.                         ObjectIdCollection layoutsToPlot = new ObjectIdCollection();
  69.                         foreach (ObjectId btrId in bt)
  70.                         {
  71.                             BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  72.                             if ((btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) || (btr.IsLayout && btr.Name.ToUpper() == BlockTableRecord.ModelSpace.ToUpper()))
  73.                             {
  74.                                 layoutsToPlot.Add(btrId);
  75.                             }
  76.                         }
  77.                         // Create a Progress Dialog to provide info
  78.                         // and allow thej user to cancel                        
  79.                         PlotProgressDialog ppd = new PlotProgressDialog(false, layoutsToPlot.Count, true);
  80.                         using (ppd)
  81.                         {
  82.                             int numSheet = 1;
  83.                             foreach (ObjectId btrId in layoutsToPlot)
  84.                             {
  85.                                 PlotInfo pi = new PlotInfo();
  86.                                 PlotInfoValidator piv = new PlotInfoValidator();
  87.                                 piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
  88.                                 BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  89.                                 Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);
  90.                                 // We need a PlotSettings object
  91.                                 // based on the layout settings
  92.                                 // which we then customize
  93.                                 PlotSettings ps = new PlotSettings(lo.ModelType);
  94.  
  95.                                 ps.CopyFrom(lo);
  96.  
  97.                                 // The PlotSettingsValidator helps
  98.                                 // create a valid PlotSettings object
  99.  
  100.  
  101.                                 PlotSettingsValidator psv = PlotSettingsValidator.Current;//текущий доk
  102.  
  103.  
  104.  
  105.                                 // We'll plot the extents, centered and
  106.                                 // scaled to fit
  107.  
  108.                                 psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
  109.                                 psv.SetUseStandardScale(ps, true);
  110.                                 psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
  111.                                 psv.SetPlotCentered(ps, true);
  112.  
  113.                                 PlotRotation Rot = PlotRotation.Degrees000;
  114.  
  115.                                 if ((lo.Limits.MaxPoint.X < lo.Limits.MaxPoint.Y))
  116.                                 {
  117.                                     Rot = PlotRotation.Degrees090;
  118.                                 }
  119.                                 psv.SetPlotRotation(ps, Rot);
  120.  
  121.                                 // We'll use the standard DWFx PC3, as
  122.                                 // this supports multiple sheets
  123.  
  124.                                 psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", null);
  125.  
  126.                                 psv.RefreshLists(ps);
  127.  
  128.  
  129.                                 // We need a PlotInfo object
  130.                                 // linked to the layout                                
  131.                                 pi.Layout = lo.Id;
  132.  
  133.  
  134.  
  135.                                 // Make the layout we're plotting current
  136.                                 LayoutManager.Current.CurrentLayout = lo.LayoutName;
  137.                                 // We need to link the PlotInfo to the
  138.                                 // PlotSettings and then validate it
  139.                                 pi.OverrideSettings = ps;
  140.  
  141.                                 piv.Validate(pi);
  142.  
  143.  
  144.                                 if (numSheet == 1)
  145.                                 {
  146.                                     ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Обработка документа");
  147.                                     ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Отмена");
  148.                                     ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Отмена листа");
  149.                                     ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Обработка слоёв");
  150.                                     ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Обработка листа");
  151.                                     ppd.LowerPlotProgressRange = 0;
  152.                                     ppd.UpperPlotProgressRange = 100;
  153.                                     ppd.PlotProgressPos = 0;
  154.                                     // Let's start the plot, at last
  155.                                     ppd.OnBeginPlot();
  156.                                     ppd.IsVisible = true;
  157.                                     pe.BeginPlot(ppd, null);
  158.                                     // We'll be plotting a single document                                    
  159.                                     pe.BeginDocument(pi, doc.Name, null, 1, true, "d:\\test-multi-sheet");
  160.                                 }
  161.                                 // Which may contain multiple sheets
  162.                                 ppd.StatusMsgString = "Обработка " + doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - страница " + numSheet.ToString() + " из " + layoutsToPlot.Count.ToString();
  163.                                 ppd.OnBeginSheet();
  164.                                 ppd.LowerSheetProgressRange = 0;
  165.                                 ppd.UpperSheetProgressRange = 100;
  166.                                 ppd.SheetProgressPos = 0;
  167.                                 PlotPageInfo ppi = new PlotPageInfo();
  168.                                 pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
  169.                                 pe.BeginGenerateGraphics(null);
  170.                                 ppd.SheetProgressPos = 50;
  171.                                 pe.EndGenerateGraphics(null);
  172.                                 // Finish the sheet
  173.                                 pe.EndPage(null);
  174.                                 ppd.SheetProgressPos = 100;
  175.                                 ppd.OnEndSheet();
  176.                                 numSheet++;
  177.                             }
  178.  
  179.                             // Finish the document
  180.                             pe.EndDocument(null);
  181.                             // And finish the plot
  182.                             ppd.PlotProgressPos = 100;
  183.                             ppd.OnEndPlot();
  184.                             pe.EndPlot(null);
  185.                             Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", bgp);
  186.                         }
  187.                     }
  188.                 }
  189.                 else
  190.                 {
  191.                     MessageBox.Show("Принтер занят");
  192.                 }
  193.             }
  194.         }
  195.  
  196.         public void Initialize()
  197.         {
  198.  
  199.         }
  200.  
  201.         public void Terminate()
  202.         {
  203.  
  204.  
  205.         }
  206.     }
  207. }
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 10-08-2018, 14:56:15
Перенёс открытие базы данных в транзакции
Всё неправильно. Зачем ты вообще открываешь базу данных?
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 10-08-2018, 14:58:20
Если чертёж открыт в редакторе и макрос запускается из этого чертежа, то печать работает корректно.
То есть,
Код - C# [Выбрать]
  1. Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
вместо
Код - C# [Выбрать]
  1. Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(line, false);

Так же, при запуске макроса для чертежа,не открытого в редакторе, если в layoutsToPlot я добавлю только закладку модель и далее
Код - C# [Выбрать]
  1. if (db.TileMode == true)
и после этого печать
То, по моему мнению, активным должен быть лист модели. Но ошибка та же- eLayoutNotCurrent
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 10-08-2018, 14:59:32
Перенёс открытие базы данных в транзакции
Всё неправильно. Зачем ты вообще открываешь базу данных?
Чтобы получить доступ к таблице блоков.
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 10-08-2018, 15:05:26
Замени:
Код - C# [Выбрать]
  1. [CommandMethod("PlotPDF")]
на
Код - C# [Выбрать]
  1. [CommandMethod("PlotPDF",CommandFlags.Session)]
и вставь транзакцию в такой блок:
Код - C# [Выбрать]
  1. using (DocumentLock docLock = doc.LockDocument())
  2. {
  3. // Сюда транзакцию
  4. }
  5.  
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 10-08-2018, 18:19:35
Вот рабочий код. Проверял в AutoCAD 2019.

Код - C# [Выбрать]
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.DatabaseServices;
  3. using Autodesk.AutoCAD.PlottingServices;
  4. using Autodesk.AutoCAD.Runtime;
  5. using System;
  6. using System.Runtime.InteropServices;
  7. using System.Windows.Forms;
  8. using System.Collections.Generic;
  9.  
  10. namespace Plot1
  11. {
  12.  
  13.   public class Commands : IExtensionApplication
  14.   {
  15.  
  16.     [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  17.     static extern int acedTrans13(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  18.     [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  19.     static extern int acedTrans12(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  20.     static int acedTrans(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result)
  21.     {
  22.       return Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 12 ?
  23.         acedTrans13(point, fromRb, toRb, disp, result) :
  24.         acedTrans12(point, fromRb, toRb, disp, result);
  25.     }
  26.  
  27.     [CommandMethod("PlotPDF", CommandFlags.Session)]
  28.     public void PlotPDF()
  29.     {
  30.  
  31.       string line = @"D:\autocad\qq.dwg";
  32.       short bgp = (short)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("BACKGROUNDPLOT");
  33.       Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
  34.       Document curDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  35.  
  36.       Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(line, false);
  37.  
  38.       if (curDoc != doc)
  39.       {
  40.         Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc;
  41.       }
  42.  
  43.       using (DocumentLock docLock = doc.LockDocument())
  44.       {
  45.  
  46.         Database db = doc.Database;
  47.         // A PlotEngine does the actual plotting
  48.         // (can also create one for Preview)
  49.         if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
  50.         {
  51.           PlotEngine pe = PlotFactory.CreatePublishEngine();
  52.           using (pe)
  53.           {
  54.             using (Transaction tr = doc.TransactionManager.StartTransaction())
  55.             {
  56.               BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
  57.               // Collect all the paperspace layouts
  58.               // for plotting
  59.               ObjectIdCollection layoutsToPlot = new ObjectIdCollection();
  60.               foreach (ObjectId btrId in bt)
  61.               {
  62.                 BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  63.                 if ((btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) || (btr.IsLayout && btr.Name.ToUpper() == BlockTableRecord.ModelSpace.ToUpper()))
  64.                 {
  65.                   layoutsToPlot.Add(btr.LayoutId);
  66.                 }
  67.               }
  68.               SortWithTabOrder(ref layoutsToPlot);
  69.               // Create a Progress Dialog to provide info
  70.               // and allow the user to cancel                        
  71.               PlotProgressDialog ppd = new PlotProgressDialog(false, layoutsToPlot.Count, true);
  72.               using (ppd)
  73.               {
  74.                 int numSheet = 1;
  75.                 foreach (ObjectId layoutId in layoutsToPlot)
  76.                 {
  77.                   PlotInfo pi = new PlotInfo();
  78.                   PlotInfoValidator piv = new PlotInfoValidator();
  79.                   piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
  80.                   Layout lo = (Layout)tr.GetObject(layoutId, OpenMode.ForRead);
  81.                   // Make the layout we're plotting current
  82.                   LayoutManager.Current.SetCurrentLayoutId(lo.ObjectId);
  83.  
  84.                   // We need a PlotSettings object
  85.                   // based on the layout settings
  86.                   // which we then customize
  87.                   PlotSettings ps = new PlotSettings(lo.ModelType);
  88.  
  89.                   ps.CopyFrom(lo);
  90.  
  91.                   // The PlotSettingsValidator helps
  92.                   // create a valid PlotSettings object
  93.  
  94.                   PlotSettingsValidator psv = PlotSettingsValidator.Current;//текущий доk
  95.  
  96.                   // We'll plot the extents, centered and
  97.                   // scaled to fit
  98.  
  99.                   psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
  100.                   psv.SetUseStandardScale(ps, true);
  101.                   psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
  102.                   psv.SetPlotCentered(ps, true);
  103.  
  104.                   PlotRotation Rot = PlotRotation.Degrees000;
  105.  
  106.                   if ((lo.Limits.MaxPoint.X < lo.Limits.MaxPoint.Y))
  107.                   {
  108.                     Rot = PlotRotation.Degrees090;
  109.                   }
  110.                   psv.SetPlotRotation(ps, Rot);
  111.  
  112.                   // We'll use the standard DWFx PC3, as
  113.                   // this supports multiple sheets
  114.  
  115.                   psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", null);
  116.  
  117.                   psv.RefreshLists(ps);
  118.  
  119.  
  120.                   // We need a PlotInfo object
  121.                   // linked to the layout                                
  122.                   pi.Layout = lo.Id;
  123.  
  124.                   // We need to link the PlotInfo to the
  125.                   // PlotSettings and then validate it
  126.                   pi.OverrideSettings = ps;
  127.  
  128.                   piv.Validate(pi);
  129.  
  130.  
  131.                   if (numSheet == 1)
  132.                   {
  133.                     ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Обработка документа");
  134.                     ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Отмена");
  135.                     ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Отмена листа");
  136.                     ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Обработка слоёв");
  137.                     ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Обработка листа");
  138.                     ppd.LowerPlotProgressRange = 0;
  139.                     ppd.UpperPlotProgressRange = 100;
  140.                     ppd.PlotProgressPos = 0;
  141.                     // Let's start the plot, at last
  142.                     ppd.OnBeginPlot();
  143.                     ppd.IsVisible = true;
  144.                     pe.BeginPlot(ppd, null);
  145.                     // We'll be plotting a single document                                    
  146.                     pe.BeginDocument(pi, doc.Name, null, 1, true, "d:\\test-multi-sheet");
  147.                   }
  148.                   // Which may contain multiple sheets
  149.                   ppd.StatusMsgString = "Обработка " + doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - страница " + numSheet.ToString() + " из " + layoutsToPlot.Count.ToString();
  150.                   ppd.OnBeginSheet();
  151.                   ppd.LowerSheetProgressRange = 0;
  152.                   ppd.UpperSheetProgressRange = 100;
  153.                   ppd.SheetProgressPos = 0;
  154.                   PlotPageInfo ppi = new PlotPageInfo();
  155.                   pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
  156.                   pe.BeginGenerateGraphics(null);
  157.                   ppd.SheetProgressPos = 50;
  158.                   pe.EndGenerateGraphics(null);
  159.                   // Finish the sheet
  160.                   pe.EndPage(null);
  161.                   ppd.SheetProgressPos = 100;
  162.                   ppd.OnEndSheet();
  163.                   numSheet++;
  164.                 }
  165.  
  166.                 // Finish the document
  167.                 pe.EndDocument(null);
  168.                 // And finish the plot
  169.                 ppd.PlotProgressPos = 100;
  170.                 ppd.OnEndPlot();
  171.                 pe.EndPlot(null);
  172.               }
  173.               tr.Commit();
  174.             }
  175.           }
  176.         }
  177.         else
  178.         {
  179.           MessageBox.Show("Принтер занят");
  180.         }
  181.       }
  182.       Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", bgp);
  183.       if (curDoc != doc)
  184.       {
  185.         Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = curDoc;
  186.         doc.CloseAndDiscard();
  187.       }
  188.     }
  189.     /// <summary>
  190.     /// Сортируем листы в том порядке, в котором они в AutoCAD
  191.     /// </summary>
  192.     /// <param name="ids"></param>
  193.     void SortWithTabOrder(ref ObjectIdCollection ids)
  194.     {
  195.       if (ids.Count == 0) return;
  196.       SortedDictionary<int, ObjectId> tab = new SortedDictionary<int, ObjectId>();
  197.       using (Transaction tr = ids[0].Database.TransactionManager.StartTransaction())
  198.       {
  199.         foreach (ObjectId id in ids)
  200.         {
  201.           Layout layout = tr.GetObject(id, OpenMode.ForRead) as Layout;
  202.           tab[layout.TabOrder] = id;
  203.         }
  204.         tr.Commit();
  205.       }
  206.       ids.Clear();
  207.       foreach (KeyValuePair<int, ObjectId> pair in tab)
  208.       {
  209.         ids.Add(pair.Value);
  210.       }
  211.     }
  212.  
  213.     public void Initialize() { }
  214.  
  215.     public void Terminate()  { }
  216.   }
  217. }
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 13-08-2018, 10:05:25
Если я правильно понял, то
Код - C# [Выбрать]
  1. SetCurrentLayoutId
в строке 82 присутствует в ObjectARX начиная с версии 2016.
В autocad старше 2016 такое не скомпилируется?
У меня autocad 2015 и ObjectARX 2015. При отладке даже пошагово не запускается. Сразу появляется ошибка:

System.MissingMethodException: Метод не найден:
"Void Autodesk.AutoCAD.DatabaseServices.LayoutManager.SetCurrentLayoutId(Autodesk.AutoCAD.DatabaseServices.ObjectId)".
 
Разработка этого плагина главным образом нацелена на версии autocad 2013-2015.
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 13-08-2018, 10:42:27
Дамир Михайлович,
Замени на:
Код - C# [Выбрать]
  1. LayoutManager.Current.CurrentLayout = lo.LayoutName;
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 13-08-2018, 10:51:34
Поменял. Та же ошибка на Validate:


Autodesk.AutoCAD.Runtime.Exception
  HResult=0x80131500
  Сообщение = eLayoutNotCurrent
  Источник = accoremgd
  Трассировка стека:
   at Autodesk.AutoCAD.PlottingServices.PlotInfoValidator.Validate(PlotInfo info)
   at Plot1.Commands.PlotPDF() in D:\VS projects\example 8\Class1.cs:line 127
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 13-08-2018, 11:33:51
Вот этот код я проверил с AutoCAD 2013, 2015, 2019 - везде работает:
Код - C# [Выбрать]
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.DatabaseServices;
  3. using Autodesk.AutoCAD.PlottingServices;
  4. using Autodesk.AutoCAD.Runtime;
  5. using System;
  6. using System.Runtime.InteropServices;
  7. using System.Windows.Forms;
  8. using System.Collections.Generic;
  9.  
  10. namespace Plot1
  11. {
  12.  
  13.   public class Commands : IExtensionApplication
  14.   {
  15.  
  16.     [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  17.     static extern int acedTrans13(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  18.     [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTrans")]
  19.     static extern int acedTrans12(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result);
  20.     static int acedTrans(double[] point, IntPtr fromRb, IntPtr toRb, int disp, double[] result)
  21.     {
  22.       return Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 12 ?
  23.         acedTrans13(point, fromRb, toRb, disp, result) :
  24.         acedTrans12(point, fromRb, toRb, disp, result);
  25.     }
  26.  
  27.     [CommandMethod("PlotPDF", CommandFlags.Session)]
  28.     public void PlotPDF()
  29.     {
  30.  
  31.       string line = @"D:\autocad\qq.dwg";
  32.       short bgp = (short)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("BACKGROUNDPLOT");
  33.       Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
  34.       Document curDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  35.  
  36.       Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(line, false);
  37.  
  38.       if (curDoc != doc)
  39.       {
  40.         Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc;
  41.       }
  42.  
  43.       using (DocumentLock docLock = doc.LockDocument())
  44.       {
  45.  
  46.         Database db = doc.Database;
  47.         // A PlotEngine does the actual plotting
  48.         // (can also create one for Preview)
  49.         if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
  50.         {
  51.           PlotEngine pe = PlotFactory.CreatePublishEngine();
  52.           using (pe)
  53.           {
  54.             using (Transaction tr = doc.TransactionManager.StartTransaction())
  55.             {
  56.               BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
  57.               // Collect all the paperspace layouts
  58.               // for plotting
  59.               ObjectIdCollection layoutsToPlot = new ObjectIdCollection();
  60.               foreach (ObjectId btrId in bt)
  61.               {
  62.                 BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
  63.                 if ((btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) || (btr.IsLayout && btr.Name.ToUpper() == BlockTableRecord.ModelSpace.ToUpper()))
  64.                 {
  65.                   layoutsToPlot.Add(btr.LayoutId);
  66.                 }
  67.               }
  68.               SortWithTabOrder(ref layoutsToPlot);
  69.               // Create a Progress Dialog to provide info
  70.               // and allow the user to cancel                        
  71.               PlotProgressDialog ppd = new PlotProgressDialog(false, layoutsToPlot.Count, true);
  72.               using (ppd)
  73.               {
  74.                 int numSheet = 1;
  75.                 foreach (ObjectId layoutId in layoutsToPlot)
  76.                 {
  77.                   PlotInfo pi = new PlotInfo();
  78.                   PlotInfoValidator piv = new PlotInfoValidator();
  79.                   piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
  80.                   Layout lo = (Layout)tr.GetObject(layoutId, OpenMode.ForRead);
  81.                   // Make the layout we're plotting current
  82.                   LayoutManager.Current.CurrentLayout = lo.LayoutName;
  83.  
  84.                   // We need a PlotSettings object
  85.                   // based on the layout settings
  86.                   // which we then customize
  87.                   PlotSettings ps = new PlotSettings(lo.ModelType);
  88.  
  89.                   ps.CopyFrom(lo);
  90.  
  91.                   // The PlotSettingsValidator helps
  92.                   // create a valid PlotSettings object
  93.  
  94.                   PlotSettingsValidator psv = PlotSettingsValidator.Current;//текущий доk
  95.  
  96.                   // We'll plot the extents, centered and
  97.                   // scaled to fit
  98.  
  99.                   psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
  100.                   psv.SetUseStandardScale(ps, true);
  101.                   psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
  102.                   psv.SetPlotCentered(ps, true);
  103.  
  104.                   PlotRotation Rot = PlotRotation.Degrees000;
  105.  
  106.                   if ((lo.Limits.MaxPoint.X < lo.Limits.MaxPoint.Y))
  107.                   {
  108.                     Rot = PlotRotation.Degrees090;
  109.                   }
  110.                   psv.SetPlotRotation(ps, Rot);
  111.  
  112.                   // We'll use the standard DWFx PC3, as
  113.                   // this supports multiple sheets
  114.  
  115.                   psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", null);
  116.  
  117.                   psv.RefreshLists(ps);
  118.  
  119.  
  120.                   // We need a PlotInfo object
  121.                   // linked to the layout                                
  122.                   pi.Layout = lo.Id;
  123.  
  124.                   // We need to link the PlotInfo to the
  125.                   // PlotSettings and then validate it
  126.                   pi.OverrideSettings = ps;
  127.  
  128.                   piv.Validate(pi);
  129.  
  130.  
  131.                   if (numSheet == 1)
  132.                   {
  133.                     ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Обработка документа");
  134.                     ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Отмена");
  135.                     ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Отмена листа");
  136.                     ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Обработка слоёв");
  137.                     ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Обработка листа");
  138.                     ppd.LowerPlotProgressRange = 0;
  139.                     ppd.UpperPlotProgressRange = 100;
  140.                     ppd.PlotProgressPos = 0;
  141.                     // Let's start the plot, at last
  142.                     ppd.OnBeginPlot();
  143.                     ppd.IsVisible = true;
  144.                     pe.BeginPlot(ppd, null);
  145.                     // We'll be plotting a single document                                    
  146.                     pe.BeginDocument(pi, doc.Name, null, 1, true, "d:\\test-multi-sheet");
  147.                   }
  148.                   // Which may contain multiple sheets
  149.                   ppd.StatusMsgString = "Обработка " + doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - страница " + numSheet.ToString() + " из " + layoutsToPlot.Count.ToString();
  150.                   ppd.OnBeginSheet();
  151.                   ppd.LowerSheetProgressRange = 0;
  152.                   ppd.UpperSheetProgressRange = 100;
  153.                   ppd.SheetProgressPos = 0;
  154.                   PlotPageInfo ppi = new PlotPageInfo();
  155.                   pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
  156.                   pe.BeginGenerateGraphics(null);
  157.                   ppd.SheetProgressPos = 50;
  158.                   pe.EndGenerateGraphics(null);
  159.                   // Finish the sheet
  160.                   pe.EndPage(null);
  161.                   ppd.SheetProgressPos = 100;
  162.                   ppd.OnEndSheet();
  163.                   numSheet++;
  164.                 }
  165.  
  166.                 // Finish the document
  167.                 pe.EndDocument(null);
  168.                 // And finish the plot
  169.                 ppd.PlotProgressPos = 100;
  170.                 ppd.OnEndPlot();
  171.                 pe.EndPlot(null);
  172.               }
  173.               tr.Commit();
  174.             }
  175.           }
  176.         }
  177.         else
  178.         {
  179.           MessageBox.Show("Принтер занят");
  180.         }
  181.       }
  182.       Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", bgp);
  183.       if (curDoc != doc)
  184.       {
  185.         Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = curDoc;
  186.         doc.CloseAndDiscard();
  187.       }
  188.     }
  189.     /// <summary>
  190.     /// Сортируем листы в том порядке, в котором они в AutoCAD
  191.     /// </summary>
  192.     /// <param name="ids"></param>
  193.     void SortWithTabOrder(ref ObjectIdCollection ids)
  194.     {
  195.       if (ids.Count == 0) return;
  196.       SortedDictionary<int, ObjectId> tab = new SortedDictionary<int, ObjectId>();
  197.       using (Transaction tr = ids[0].Database.TransactionManager.StartTransaction())
  198.       {
  199.         foreach (ObjectId id in ids)
  200.         {
  201.           Layout layout = tr.GetObject(id, OpenMode.ForRead) as Layout;
  202.           tab[layout.TabOrder] = id;
  203.         }
  204.         tr.Commit();
  205.       }
  206.       ids.Clear();
  207.       foreach (KeyValuePair<int, ObjectId> pair in tab)
  208.       {
  209.         ids.Add(pair.Value);
  210.       }
  211.     }
  212.  
  213.     public void Initialize() { }
  214.  
  215.     public void Terminate()  { }
  216.   }
  217. }

Прикладываю готовый проект.
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 13-08-2018, 11:53:43
Проверка с AutoCAD 2015:

Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 14-08-2018, 07:59:23
Протестировал.
Всё отлично работает!
Спасибо!
Название: Re: не валидируется Validate
Отправлено: Александр Ривилис от 14-08-2018, 12:23:43
Протестировал.
Всё отлично работает!
Спасибо!
Так что было в прошлый раз не так? Этот код - это код из #14 и замена из #16.
Название: Re: не валидируется Validate
Отправлено: Дамир Михайлович от 14-08-2018, 12:29:13
После ответа #16 я исправил код так же, как в сообщении #18, но ошибка не пропала.
Некоторое время спустя запустил и уже не было ошибки.
Все разы запускал в отладке пошагово.
Сейчас всё работает отлично.