My experience is not with C# and AutoCad. I was trained on AutoLISP. But knowing how AC works I'd say your best bet is to take control over the command prompt as documented here.
By what you've said I'm assuming you'd like to print what ever is in model space; is that correct?
Well when you're in PaperSpace you can switch to ModelSpace by typing ._MSPACE
on the command line. This will enable you to work in MSpace through a hole in PSpace - so to speak. So, if the layout in PSpace is not showing the entire contents of MSpace you can switch to MSpace and enter z
or type zoom
on the command line. You'll then have all the options any user would inside model space utilizing the zoom
tool (All/Center/Dynamic...). All
would probably be the best bet.
So when the user clicks your button or enters your alias you can automate the entire process. You can switch to MSpace-> zoom all -> plot -> layout (what to plot).
Update:
I realize now that my link did not take you to the specific topic I intended.(?)
Here is a snippet of what I think you should try -
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
[CommandMethod("selectEntireAutoCadDrawing")]
public static void selectEntireAutoCadDrawing()
{
//This sets up your doc. Not sure if this is the way you're doing it.
//I imagine you'd probably pass the doc into the method.
Document yourACDoc = Application.DocumentManager.MdiActiveDocument;
//When your plug-in is invoked the first thing I'd do is make sure they're
//in PaperSpace
yourACDoc.SendStringToExecute("tilemode 0 ");
//Next enable ModelSpace through PaperSpace.
yourACDoc.SendStringToExecute("_mspace ");
//Now we zoom to the extents of the drawing.
//Not sure about the bools at the end. The AC documentation has it there for a
//zoom all example but AC doesn't ask any further questions after selecting the
//all or extents zoom types and doesn't elaborate on it?
yourACDoc.SendStringToExecute("._zoom _extents "/*, true, false, false*/);
//Head back to PaperSpace
yourACDoc.SendStringToExecute("_pspace ");
}
At this point your drawing should all be there in PaperSpace. Now just continue with the rest of your execution.
AC command line requires the space bar, return, or if set up correctly a mouse click to execute any command. That is why there are spaces between some parameters. It is essential to do it this way or they will be interpreted as unknown commands.
You might have to play around with it a bit, look at the API reference, or use a different zoom type. Zooms can get tricky if you have multiple users with different styles especially in a loosely managed shop. If this will be implemented in an environment where people are aware of it's limitations it should be fine.
Also - it'd be good to make yourself familiar with AC. You can use the command line as a debugger for it shows a list of all the commands entered and any error messages. It will also allow you to design in advance. Just enter the commands in AC make notes of the order and purpose of the prompts and code accordingly. There is also a way to record actions into a macro which is the route many with no programming knowledge take.
Good luck~