.NET

Reply
Mentor
SENL1362
Posts: 166
Registered: ‎07-20-2011
Message 1 of 5 (286 Views)
Accepted Solution

Update Plotter Device List

286 Views, 4 Replies
01-28-2014 04:46 AM

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.

 

 

 

ADN Support Specialist
Balaji_Ram
Posts: 692
Registered: ‎03-21-2011
Message 2 of 5 (233 Views)

Re: Update Plotter Device List

02-04-2014 12:50 AM in reply to: SENL1362

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 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Mentor
SENL1362
Posts: 166
Registered: ‎07-20-2011
Message 3 of 5 (210 Views)

Re: Update Plotter Device List

02-05-2014 01:50 AM in reply to: Balaji_Ram

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?

 

 

ADN Support Specialist
Balaji_Ram
Posts: 692
Registered: ‎03-21-2011
Message 4 of 5 (197 Views)

Re: Update Plotter Device List

02-05-2014 03:18 AM in reply to: SENL1362

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



Balaji
Developer Technical Services
Autodesk Developer Network

Mentor
SENL1362
Posts: 166
Registered: ‎07-20-2011
Message 5 of 5 (193 Views)

Re: Update Plotter Device List

02-05-2014 03:35 AM in reply to: Balaji_Ram

No hurry, just curios to the reason why.
I'l Appreciate you're support.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.