Recently i discovered that my Plotter Device List is not beeing refreshed after a AutoCAD profile change using:
PlotConfigManager.RefreshList(RefreshCode.All);
Neither could i find a Refresh function in the UserConfigurationManager:
Application.UserConfigurationManager.xxREFRESHxx
Run the following code twice, before and after a profile change, and for each profile a different Plotter Configuration Search path.
Notice the differences in the PC3 contents.
[CommandMethod("LPD")] public void ListPlotDevices() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; PlotSettingsValidator plotSettingsValidator = PlotSettingsValidator.Current; //The Device list generated by the plotSettingsValidator is not refreshed // after a AutoCAD Profile change -- within the same autoCAD session PlotConfigManager.RefreshList(RefreshCode.All); var pc3ListByPSV = plotSettingsValidator. GetPlotDeviceList(). Cast<string>(). Where(pd => Regex.IsMatch(pd,"PC3$",RegexOptions.IgnoreCase)). ToList(); ed.WriteMessage("\nPlot Device List by PlotSettings Validator:"); pc3ListByPSV.ForEach(pd => ed.WriteMessage("\n{0}", pd)); dynamic acadPreferences = Application.Preferences; dynamic acadPrefsFiles = acadPreferences.Files; string acadprinterConfigPath = acadPrefsFiles.PrinterConfigPath; ed.WriteMessage("\n\nPrinter Config Path:{0}", acadprinterConfigPath); var pc3ListByDir = Directory.EnumerateFiles(acadprinterConfigPath, "*.pc3").Select(n => Path.GetFileName(n)).ToList(); ed.WriteMessage("\nPlot Device List(PC3) by Directory search:"); pc3ListByDir.ForEach(pd => ed.WriteMessage("\n{0}", pd)); }
Any tips are welcome.
Solved! Go to Solution.
Solved by Balaji_Ram. Go to Solution.
Hi Anton,
Sorry for the delay.
Can you please try this code snippet to refresh the list ?
using (Transaction Tx = doc.Database.TransactionManager.StartTransaction()) { LayoutManager layoutMgr = LayoutManager.Current; Layout layout = Tx.GetObject(layoutMgr.GetLayoutId(layoutMgr.CurrentLayout), OpenMode.ForWrite) as Layout; plotSettingsValidator.RefreshLists(layout); Tx.Commit(); }
Regards,
Balaji
Hello Balaji_Ram ,
Thank you for you're time, this indeed solved the issue.
But does that mean that
PlotConfigManager.RefreshList(RefreshCode.All);
is worthless?
Sorry, I am not aware of the reason why the other PlotConfigManager.RefreshList would not work.
I will let you know if I find anything related to this.
Regards,
Balaji