.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using com intero to plot layouts

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
OsamaElewa
995 Views, 2 Replies

using com intero to plot layouts

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

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: OsamaElewa

Well, there error message is correct, but you attacked wrong data you passed to PlotToFile() method: the second argument expects a AcadPlotConfiguration, while what you passed in is AcadDocument.PlotConfiguations, which is AcadPlotConfigurations (a collection of AcadPlotConfiguration objects).

Message 3 of 3
OsamaElewa
in reply to: norman.yuan

thanks alot for your support

I used the same code but i removed the 'app.ActiveDocument.PlotConfigurations' as its optional and the pdf works now.

 

thanks alot 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost