Author Topic: Autocad 2012 Plotting error : invalid Input  (Read 2439 times)

0 Members and 1 Guest are viewing this topic.

btraemoore

  • Guest
Autocad 2012 Plotting error : invalid Input
« on: April 30, 2014, 05:10:48 PM »
RESOLUTION UPDATE
________________________________________________

Code - C#: [Select]
  1. var mediaName = config.Size.Equals("11x17") ? "Tabloid" : "Letter";
  2. var deviceName = config.ColorPrint ? config.Device.Pc3 : @config.Device.NetworkLocation;
  3. plotSettingsValidator.SetPlotConfigurationName( plotSettings, deviceName, mediaName );
  4.  
________________________________________________


UPDATE
________________________________________________

I have narrowed it down to being the method from the
Code - C#: [Select]
  1. plotSettingsValidator.SetCanonicalMediaName(plotSettings,mediaName):
  2.  

It is throwing the Invalid input exception - when i try to set it to "ANSI_B_(11.00_x_17.00_Inches)".

I am not really sure why, but i will update upon resolution.
________________________________________________


Good afternoon ladies and gentlemen.

I am attempting to print to a print server. I have set up an extenstion method the contents are:

Code - C#: [Select]
  1. static void ExecutePlotSequence(Document doc, PlotConfiguration config, bool withWindow)
  2.         {
  3.             using (var tr = doc.Database.TransactionManager.StartOpenCloseTransaction())
  4.             {
  5.                 var blkTableRecord = (BlockTableRecord)tr.GetObject(doc.Database.CurrentSpaceId, OpenMode.ForRead);
  6.  
  7.                 var layout = (Layout)tr.GetObject(blkTableRecord.LayoutId, OpenMode.ForRead);
  8.  
  9.                 var plotInfo = new PlotInfo();
  10.                 plotInfo.Layout = blkTableRecord.LayoutId;
  11.  
  12.                 var plotSettings = new PlotSettings(layout.ModelType);
  13.                 plotSettings.CopyFrom(layout);
  14.  
  15.                 var plotSettingsValidator = PlotSettingsValidator.Current;
  16.  
  17.                 if (withWindow)
  18.                 {
  19.                     var window = getwindow(doc);
  20.  
  21.                     if (window == null)
  22.                         return;
  23.  
  24.                     plotSettingsValidator.SetPlotWindowArea(plotSettings, getwindow(doc).Value);
  25.                     plotSettingsValidator.SetPlotType(plotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);
  26.                 }
  27.                 else
  28.                     plotSettingsValidator.SetPlotType(plotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Limits);
  29.  
  30.                 plotSettingsValidator.SetUseStandardScale(plotSettings, true);
  31.                 plotSettingsValidator.SetStdScaleType(plotSettings, StdScaleType.ScaleToFit);
  32.                 plotSettingsValidator.SetPlotCentered(plotSettings, true);
  33.  
  34.                 plotSettingsValidator.RefreshLists(plotSettings);
  35.  
  36.                 var list = plotSettingsValidator.GetCanonicalMediaNameList(plotSettings);
  37.                 foreach (var name in list)
  38.                     System.Diagnostics.Debug.WriteLine(name);
  39.  
  40.                [b] //
  41.                 //  Development note: invalid input
  42.                 //  This is where i am getting the error I am not sure which is the invalid input.
  43.                 //  I have tried both a print server and a pc3 file. I have also tried A and B size, Im not sure why it would be my plot settings, it just doesnt make since to me. [/b]
  44.  
  45.                 plotSettingsValidator.SetPlotConfigurationName(
  46.                     plotSettings,
  47.                     config.ColorPrint ? config.Device.Pc3 : config.Device.NetworkLocation,
  48.                     config.Size.Equals("11x17") ? "ANSI_B_(11.00_x_17.00_Inches)" : "ANSI_A_(8.50_x_11.00_Inches)");
  49.  
  50.                 plotInfo.OverrideSettings = plotSettings;
  51.  
  52.                 var plotInfoValidator = new PlotInfoValidator
  53.                 {
  54.                     MediaMatchingPolicy = MatchingPolicy.MatchEnabled
  55.                 };
  56.  
  57.                 plotInfoValidator.Validate(plotInfo);
  58.  
  59.                 if (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
  60.                     doc.Editor.WriteMessage("\nAnother plot is in progress.");
  61.                 else
  62.                     using (var plotEngine = PlotFactory.CreatePublishEngine())
  63.                     using (var progressDialog = getProgressDialog())
  64.                     {
  65.                         plotEngine.BeginPlot(progressDialog, null);
  66.  
  67.                         plotEngine.BeginDocument(plotInfo, doc.Name, null, 1, false, doc.Name);
  68.  
  69.                         progressDialog.OnBeginSheet();
  70.  
  71.                         progressDialog.LowerSheetProgressRange = 0;
  72.                         progressDialog.UpperSheetProgressRange = 100;
  73.                         progressDialog.SheetProgressPos = 0;
  74.  
  75.                         PlotPageInfo plotPageInfo = new PlotPageInfo();
  76.                         plotEngine.BeginPage(plotPageInfo, plotInfo, true, null);
  77.                         plotEngine.BeginGenerateGraphics(null);
  78.                         plotEngine.EndGenerateGraphics(null);
  79.  
  80.                         plotEngine.EndPage(null);
  81.                         progressDialog.SheetProgressPos = 100;
  82.                         progressDialog.OnEndSheet();
  83.  
  84.                         plotEngine.EndDocument(null);
  85.  
  86.                         progressDialog.PlotProgressPos = 100;
  87.                         progressDialog.OnEndPlot();
  88.                         plotEngine.EndPlot(null);
  89.                     }
  90.             }
  91.         }
  92.  

I have attached the related .cs files. Any help would be greatly appriciated.
« Last Edit: May 01, 2014, 11:47:26 AM by btraemoore »