Troubles in a C# interop to access a ActiveLayout.PlotType
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I doesen't acces or modify nothing in a ActiveLayout.
I'm using c# and interop and need to plot to a file a dwg.
The plot to file works well, but I need to change some properties like Plot Scale or Plot Type.
A conversion error occours.
In second place, the DefaultPlotStyleTable doesen't work too.
Somebody can helpe me?
My test code:
using System;
using System.IO;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
namespace ProcessoCAD
{
static class Program
{
private static Autodesk.AutoCAD.Interop.AcadApplication oAcadApp = null;
private static string sAcadID = "AutoCAD.Application.18";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Abre AutoCAD
try
{
oAcadApp = (Autodesk.AutoCAD.Interop.AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(sAcadID);
}
catch
{
System.Type AcadProg = System.Type.GetTypeFromProgID(sAcadID);
oAcadApp = (Autodesk.AutoCAD.Interop.AcadApplication)System.Activator.CreateInstance(AcadProg);
}
// Inicia ciclo de execução
if (oAcadApp != null)
{
string StyleTable = "AZEVEDO.ctb";
oAcadApp.Visible = true; //could leave this false to hide Acad from the user
Autodesk.AutoCAD.Interop.AcadDocument dm; // = oAcadApp.ActiveDocument;
dm = oAcadApp.Documents.Open("d:\\teste\\Teste.dwg", true, null);
dm.SetVariable("BACKGROUNDPLOT", 0);
dm.ActiveSpace = AcActiveSpace.acPaperSpace;
dm.ActiveLayout.PlotType = AcPlotType.acExtents;
dm.ActiveLayout.StandardScale = AcPlotScale.ac1_1;
oAcadApp.Preferences.Output.DefaultPlotStyleTable = StyleTable;
dm.Regen(AcRegenType.acActiveViewport);
// dm.Application.ZoomExtents();
// dm.Regen(AcRegenType.acAllViewports);
dm.Plot.QuietErrorMode = true;
dm.Plot.NumberOfCopies = 1;
dm.Plot.PlotToFile("d:\\teste\\Teste.pdf", "C:\\Program Files\\AutoCAD 2010\\UserDataCache\\Plotters\\DWG To PDF.pc3");
// dm.Plot.PlotToFile("d:\\teste\\Teste.plt", "C:\\Program Files\\AutoCAD 2010\\UserDataCache\\Plotters\\DWF6 ePlot.pc3");
//dm.Close(null, null);
//oAcadApp.Quit();
}
}
}
}