Plotting Device Information with events

Plotting Device Information with events

Amremad
Collaborator Collaborator
2,423 Views
11 Replies
Message 1 of 12

Plotting Device Information with events

Amremad
Collaborator
Collaborator

hi

 

how can i catch the plotting information (paper size and scale ... ) using plotting device??

0 Likes
Accepted solutions (1)
2,424 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable

Hi,

 

Try to use PlotSettings, PlotSettingsValidator. AutoCAD DevBlog will give you a hint at this link.

 

-Khoa

www.netscriptcad.com

 

0 Likes
Message 3 of 12

Amremad
Collaborator
Collaborator

no no no

 

i need to know when user plote

 

whate the device and paper size and other plotting information

0 Likes
Message 4 of 12

Balaji_Ram
Alumni
Alumni

The Plot event does not provide such information.

It is limited to what the "BeginPlotEventArgs" class provides. 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 12

norman.yuan
Mentor
Mentor
Accepted solution

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

Drive CAD With Code

EESignature

Message 6 of 12

Balaji_Ram
Alumni
Alumni

Sorry, I did not pay attention to the "BeginPageEventArgs" class.

 

Thanks to Norman for correcting me and the link to his nice blog post.



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 12

Amremad
Collaborator
Collaborator
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 ??

 

 

0 Likes
Message 8 of 12

Balaji_Ram
Alumni
Alumni

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.



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 12

Amremad
Collaborator
Collaborator

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

0 Likes
Message 10 of 12

Amremad
Collaborator
Collaborator

i solve it

 

i wort  in Initialize Method

 

PlotManager = New  PlotReactorManager

0 Likes
Message 11 of 12

Amremad
Collaborator
Collaborator

it's work good


but i have two think can't catch it

1- Scale 

2- which layout printed

0 Likes
Message 12 of 12

norman.yuan
Mentor
Mentor

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

Drive CAD With Code

EESignature

0 Likes