One of the technical issues CAD managers oftern ask thenself is how do I tracking plottings done through .
There are many ways to do that. AutoCAD itself provides plot and publish logging (via Options dialog box-> plot and Publish tab). There be other software that can monitor printing tasks sent to one or more printers...
With AutoCD .NET API, we can fairly easily to build a custom plotting logging application, which is the topic of this article.
The Autodesk.AutoCAD.PlottingServices.PlotReactorManager class provides all the functionalities needed to track plotting from an running AutoCAD session. This class exposes a series of events that fire from the beginning of plotting to the end of plotting. Some plotting information that would be the interest of plot tracking is exposed through various EventArgs. Therefore, simply handling approriate events and retrieving needed plotting information, then saving the information into some sort of data store, these all a custom plot tracking application needs to do.
Let's look at the code.
First, I define a data class that hold plotting information I want to track when AutoCAD does a plotting:
The data store used to save plot tracking data can be different, from file (plain text, Xml...), to database. AutoCAD built-in plotting log is a plain text file, usually saved where the the plotted drawing is, if enabled. Of course these kind of plotting logs are not convenient for plotting management: they scattered everywhere. In general, file based store is not very ideal solution with this custom plot tracking application: the user who runs AutoCAD, thus the plot tracking application, must have read/write permission to the log file. So, it could be a security hole, if you want this plot tracking to be a serious CAD management tool. Ideally, the data store would be some sort of central database.
In order for this custom plot tracking application to be able to save plotting log to different data store, I created an Interface called IPlottingLogWriter. For different data store, we can write different code to save the plotting log, as long as the IPlottingLogWriter is implemented. In this article, the the simplicity, I implemented an file data store, called PlottingLogFileWriter to save plotting log to a text file. As aforementioned, I could implement the IPlottingLogWriter to save the data to database, or send the plotting log data to a WCF service to be saved somewhere. This way, no matter what data storage mechanism the application uses, the code to track plotting will not have to be changed.
Here is the Interface and its implementing:
The interface: