.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plotting Device Information with events

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Amremad
1428 Views, 11 Replies

Plotting Device Information with events

hi

 

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

11 REPLIES 11
Message 2 of 12
khoa.ho
in reply to: Amremad

Hi,

 

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

 

-Khoa

www.netscriptcad.com

 

Message 3 of 12
Amremad
in reply to: khoa.ho

no no no

 

i need to know when user plote

 

whate the device and paper size and other plotting information

Message 4 of 12
Balaji_Ram
in reply to: Amremad

The Plot event does not provide such information.

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



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 12
norman.yuan
in reply to: Amremad

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

 

 

Message 6 of 12
Balaji_Ram
in reply to: Amremad

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

Message 7 of 12
Amremad
in reply to: norman.yuan

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

 

 

Message 8 of 12
Balaji_Ram
in reply to: Amremad

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
in reply to: Balaji_Ram

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

Message 10 of 12
Amremad
in reply to: Amremad

i solve it

 

i wort  in Initialize Method

 

PlotManager = New  PlotReactorManager

Message 11 of 12
Amremad
in reply to: Amremad

it's work good


but i have two think can't catch it

1- Scale 

2- which layout printed

Message 12 of 12
norman.yuan
in reply to: Amremad

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.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost