Quantcast
Channel: Autodesk India Community aggregator
Viewing all articles
Browse latest Browse all 1680

AutoCAD Customization: .NET: using com intero to plot layouts

$
0
0

Hi guys I am using com intero  to plot layouts, the code goes well untill reach the plotToFile() line and  the visual studio produces error message as attached in the image and text file.

I tried so many time to change in the string path "//" but the same error and using @ at the begginning also the same, as I think that the string may pruduce this error.

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.AutoCAD.Interop.Common;
using Autodesk.AutoCAD.Interop;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.PlottingServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

[assembly: CommandClass(typeof(ZFP_BatchPlotTest_2014.PlottingFunction))]
namespace ZFP_BatchPlotTest_2014
{
    
    public class PlottingFunction
    {
        [CommandMethod("ppdf", CommandFlags.Modal)]
        public void PlotPDF()
        {
            AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
            AcadLayouts LayoutsCOLL = app.ActiveDocument.Layouts;
            string strLayOutName;
            //AcadLayout cadLayout;
            //string strModel;

            foreach (AcadLayout cadlayout  in LayoutsCOLL)
            {
                app.ActiveDocument.SetVariable("backgroundplot", 0);
                if (app.ActiveDocument.GetVariable("tilemode") == 1)
                {
                    app.ActiveDocument.SetVariable("tilemode", 0);
                }

                app.ActiveDocument.ModelSpace.Layout.RefreshPlotDeviceInfo();
                strLayOutName = cadlayout.Name;
                app.ActiveDocument.ActiveLayout = cadlayout;
                if (strLayOutName != "Model")
                {
                    app.ActiveDocument.Regen(AcRegenType.acAllViewports);
                    app.ActiveDocument.ActiveLayout.ConfigName = "DWG To PDF.pc3";
                    app.ActiveDocument.ActiveLayout.PlotWithPlotStyles = true;
                    app.ActiveDocument.ActiveLayout.StyleSheet = "FINAL-BK.ctb";
                    app.ActiveDocument.ActiveLayout.CanonicalMediaName = "ISO_A0_(841.00_x_1189.00_MM)";
                    app.ActiveDocument.ActiveLayout.PaperUnits = AcPlotPaperUnits.acMillimeters;
                    app.ActiveDocument.ActiveLayout.PlotRotation = AcPlotRotation.ac90degrees;
                    app.ActiveDocument.ActiveLayout.StandardScale = AcPlotScale.ac1_1;
                    app.ActiveDocument.ActiveLayout.PlotType = AcPlotType.acExtents;
                    app.ActiveDocument.ActiveLayout.CenterPlot = true;
                    //app.ActiveDocument.Plot.DisplayPlotPreview(AcPreviewMode.acFullPreview);
                    app.ActiveDocument.Application.ZoomExtents();
                    //app.ActiveDocument.Plot.PlotToDevice();
                    string strLayoutpath = "L:\\" + strLayOutName + ".pdf";

                    app.ActiveDocument.Plot.PlotToFile(strLayoutpath, app.ActiveDocument.PlotConfigurations);

                }



            }
        }



    }
}

 

thanks for your support


Viewing all articles
Browse latest Browse all 1680

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>