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);
}
}
C# net autocad批量打印(图纸设置,打印比例设置)
最新推荐文章于 2023-03-24 15:52:16 发布