hi
how can i catch the plotting information (paper size and scale ... ) using plotting device??
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
The Plot event does not provide such information.
It is limited to what the "BeginPlotEventArgs" class provides.
I was on vacation for a while. So, this reply might be a late. But here it goes anyway.
Have you looked at Autodesk.AutoCAD.PlottingServices.PlotReactorManager class?
It raises events when AutoCAD plots: Begin/EndPlot, Begin/EndDocument, BeginEndPage... I am not sure what "Plot" event Balaji was referring to, but PlotReactorManager class provides all information you need to know (copies of plot, paper size, plot device name...via BeginPlot/Document/PageEventArgs.
So, simply get an instance of PlotReactorManager and handle the events raised by it, you'll get all the information whan AutoCAD plots. Specifically, if you need to know paper size, you need to handle BeginPage, and the BeginPageEventArgs has a property "PlotInfo", which intern has a property "ValidatedSettings" (type of PlotSettings), from which you can get the information of paper size, scale...
I posted an article a couple of years ago that might be of help to you:
http://drive-cad-with-code.blogspot.ca/2011_02_01_archive.html
Norman Yuan
Sorry, I did not pay attention to the "BeginPageEventArgs" class.
Thanks to Norman for correcting me and the link to his nice blog post.
Imports Autodesk.AutoCAD.PlottingServices Public Class AMRLISP Dim WithEvents PlotManager As PlotReactorManager Private Sub PlotManager_BeginPlot(sender As Object, e As BeginPlotEventArgs) Handles PlotManager.BeginPlot MsgBox("BeginPlot") End Sub End Class
thankyou Mr. norman.yuan
can help me with above code?? plz
the message doesn't appear ... Why ??
Can you try this ?
Public Sub InitializePlotEvents() mPlotReactorManager = New PlotReactorManager() AddHandler mPlotReactorManager.BeginPlot, AddressOf BeginPlot AddHandler mPlotReactorManager.EndPlot, AddressOf EndPlot End Sub Private Sub BeginPlot(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.PlottingServices.BeginPlotEventArgs) WriteMessage("BeginPlot") End Sub Private Sub EndPlot(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.PlottingServices.EndPlotEventArgs) WriteMessage("EndPlot") End Sub
Edit :
Also remember to set the "BACKGROUNDPLOT” system variable to 0.
i need to use events not delegates
i know this way but i need to use the events , but i don't know what can i write in Initialize Method to run my events
As my previous reply pointed out: in the BeginPage event handler, the BeginPageEventArgs provides the information you need.
The code would be like:
void MyPlotReactorManager_BeginPage(object sender, BeginPageEventArgs e)
{
//Get Layout name the current plotted page is plotting
PlotInfo pInfo=e.PoltInfo;
ObjectId layoutId=pInfo.Layout;
//Then, you can open a transaction to get Layout object, hence, its name
//Get scale, depending on whether standard or custom scale is used
PlotSettings pSettings=pInfo.ValidatedSettings;
CustomScale scale=pSetting.CustomPrintScale;
//or
double stdScale=pSetting.StdScale
//Paper size
Point2d size=pSettiings.PlotPaperSize
}
Note, the code is just off my head and not tested, but you get the idea: just digging into BeginPageEventArgs's PlotInfo property would get all information you need.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.