C# net autocad批量打印
private void btn采用outpdf采用Click(object sender, EventArgs e){
AcadDocument doc = null;
string destPath = string.Empty;
foreach (var file in fileslist)
{
doc = 采用app.Documents.Open(file, true);
doc.SetVariable("sdi", 0);
doc.SetVariable("Filedia", 0);
doc.SetVariable("BACKGROUNDPLOT", 0);
doc.ActiveLayout.ConfigName = "DWG To PDF.pc3";
doc.ActiveLayout.PlotWithLineweights = true; //线宽比例
doc.ActiveLayout.PlotWithPlotStyles = true; //使用样式
//设置打印图纸大小
string[] cMNameLst = (string[])doc.ActiveLayout.GetCanonicalMediaNames();
foreach (string name in cMNameLst)
{
//查找纸张大小
//if (name.Contains("2000.00") && name.Contains("2000.00"))
//{
// doc.ActiveLayout.CanonicalMediaName = name;
// break;
//}
}
doc.ActiveLayout.PaperUnits = AcPlotPaperUnits.acMillimeters;
doc.ActiveLayout.StyleSheet = "monochrome.ctb";
doc.ActiveLayout.CanonicalMediaName = "ISO采用A3采用(420.00采用x采用297.00采用MM)";
doc.ActiveLayout.PlotType = AcPlotType.acExtents;
doc.ActiveLayout.CenterPlot = true; // 居中
doc.ActiveLayout.PlotRotation = AcPlotRotation.ac0degrees;//0 横向,90 纵向,180反向,
doc.ActiveLayout.UseStandardScale = true; // 使用标准比例
// doc.ActiveLayout.StandardScale = AcPlotScale.acScaleToFit; // 自动缩放适应
doc.ActiveLayout.StandardScale = AcPlotScale.ac1采用1; //1:1打印
doc.Plot.QuietErrorMode = true;
destPath = Path.Combine(tmpPath, Path.GetFileNameWithoutExtension(file) + ".pdf");
doc.Plot.PlotToFile(destPath);
if (doc != null) doc.Close(false);
}
}
页:
[1]