Plotting a window from AutoCAD using .NET

This post extends this previous post that dealt with driving a single-sheet AutoCAD plot by adding some code to handle selection and transformation of a window to plot.

First order of business was to allow the user to select the window to plot. For this I used the classic combination of Editor.GetPoint() for the first corner) and Editor.GetCorner() for the second. All well and good, but the points returned by these functions are in UCS (User Coordinate System) coordinates. Which meant that as it stood, the code would work just fine if (and only if) the view we were using to select the window was parallell with the World Coordinate System (and no additional UCS was in place). In order to deal with the very common scenario of either a UCS being used or the current modelspace view being orbited (etc.), we need to transform the current UCS coordinates into DCS, the Display Coordinate System.

Thankfully that's pretty easy: no need for matrices or anything, we simply use another old friend, acedTrans() (the ObjectARX equivalent of the (trans) function, for you LISPers out there). There isn't a direct equivalent for this function in the managed API (that I'm aware of), so we have to use P/Invoke to call the ObjectARX function. The technique is shown in this DevNote, for those of you that have access to the ADN website:

How to call acedTrans from .NET application?

Otherwise the changes to the original code are very minor: we need to set the extents of the window to plot and then set the plot type to "window", apparently in that order. AutoCAD complained when I initially made the calls in the opposite sequence.

Here's the C# code:

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.PlottingServices;

using Autodesk.AutoCAD.Geometry;

using System.Runtime.InteropServices;

using System;

namespace PlottingApplication

{

  public class SimplePlottingCommands

  {

    [DllImport("acad.exe",

              CallingConvention = CallingConvention.Cdecl,

              EntryPoint="acedTrans")

    ]

    static extern int acedTrans(

      double[] point,

      IntPtr fromRb,

      IntPtr toRb,

      int disp,

      double[] result

    );

    [CommandMethod("winplot")]

    static public void WindowPlot()

    {

      Document doc =

        Application.DocumentManager.MdiActiveDocument;

      Editor ed = doc.Editor;

      Database db = doc.Database;

      PromptPointOptions ppo =

        new PromptPointOptions(

          "\nSelect first corner of plot area: "

        );

      ppo.AllowNone = false;

      PromptPointResult ppr =

        ed.GetPoint(ppo);

      if (ppr.Status != PromptStatus.OK)

        return;

      Point3d first = ppr.Value;

      PromptCornerOptions pco =

        new PromptCornerOptions(

          "\nSelect second corner of plot area: ",

          first

        );

      ppr = ed.GetCorner(pco);

      if (ppr.Status != PromptStatus.OK)

        return;

      Point3d second = ppr.Value;

      // Transform from UCS to DCS

      ResultBuffer rbFrom =

        new ResultBuffer(new TypedValue(5003, 1)),

                  rbTo =

        new ResultBuffer(new TypedValue(5003, 2));

      double[] firres = new double[] { 0, 0, 0 };

      double[] secres = new double[] { 0, 0, 0 };

      // Transform the first point...

      acedTrans(

        first.ToArray(),

        rbFrom.UnmanagedObject,

        rbTo.UnmanagedObject,

        0,

        firres

      );

      // ... and the second

      acedTrans(

        second.ToArray(),

        rbFrom.UnmanagedObject,

        rbTo.UnmanagedObject,

        0,

        secres

      );

      // We can safely drop the Z-coord at this stage

      Extents2d window =

        new Extents2d(

          firres[0],

          firres[1],

          secres[0],

          secres[1]

        );

      Transaction tr =

        db.TransactionManager.StartTransaction();

      using (tr)

      {

        // We'll be plotting the current layout

        BlockTableRecord btr =

          (BlockTableRecord)tr.GetObject(

            db.CurrentSpaceId,

            OpenMode.ForRead

          );

        Layout lo =

          (Layout)tr.GetObject(

            btr.LayoutId,

            OpenMode.ForRead

          );

        // We need a PlotInfo object

        // linked to the layout

        PlotInfo pi = new PlotInfo();

        pi.Layout = btr.LayoutId;

        // We need a PlotSettings object

        // based on the layout settings

        // which we then customize

        PlotSettings ps =

          new PlotSettings(lo.ModelType);

        ps.CopyFrom(lo);

        // The PlotSettingsValidator helps

        // create a valid PlotSettings object

        PlotSettingsValidator psv =

          PlotSettingsValidator.Current;

        // We'll plot the extents, centered and

        // scaled to fit

        psv.SetPlotWindowArea(ps, window);

        psv.SetPlotType(

          ps,

        Autodesk.AutoCAD.DatabaseServices.PlotType.Window

        );

        psv.SetUseStandardScale(ps, true);

        psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);

        psv.SetPlotCentered(ps, true);

        // We'll use the standard DWF PC3, as

        // for today we're just plotting to file

        psv.SetPlotConfigurationName(

          ps,

          "DWF6 ePlot.pc3",

          "ANSI_A_(8.50_x_11.00_Inches)"

        );

        // We need to link the PlotInfo to the

        // PlotSettings and then validate it

        pi.OverrideSettings = ps;

        PlotInfoValidator piv =

          new PlotInfoValidator();

        piv.MediaMatchingPolicy =

          MatchingPolicy.MatchEnabled;

        piv.Validate(pi);

        // A PlotEngine does the actual plotting

        // (can also create one for Preview)

        if (PlotFactory.ProcessPlotState ==

            ProcessPlotState.NotPlotting)

        {

          PlotEngine pe =

            PlotFactory.CreatePublishEngine();

          using (pe)

          {

            // Create a Progress Dialog to provide info

            // and allow thej user to cancel

            PlotProgressDialog ppd =

              new PlotProgressDialog(false, 1, true);

            using (ppd)

            {

              ppd.set_PlotMsgString(

                PlotMessageIndex.DialogTitle,

                "Custom Plot Progress"

              );

              ppd.set_PlotMsgString(

                PlotMessageIndex.CancelJobButtonMessage,

                "Cancel Job"

              );

              ppd.set_PlotMsgString(

                PlotMessageIndex.CancelSheetButtonMessage,

                "Cancel Sheet"

              );

              ppd.set_PlotMsgString(

                PlotMessageIndex.SheetSetProgressCaption,

                "Sheet Set Progress"

              );

              ppd.set_PlotMsgString(

                PlotMessageIndex.SheetProgressCaption,

                "Sheet Progress"

              );

              ppd.LowerPlotProgressRange = 0;

              ppd.UpperPlotProgressRange = 100;

              ppd.PlotProgressPos = 0;

              // Let's start the plot, at last

              ppd.OnBeginPlot();

              ppd.IsVisible = true;

              pe.BeginPlot(ppd, null);

              // We'll be plotting a single document

              pe.BeginDocument(

                pi,

                doc.Name,

                null,

                1,

                true, // Let's plot to file

                "c:\\test-output"

              );

              // Which contains a single sheet

              ppd.OnBeginSheet();

              ppd.LowerSheetProgressRange = 0;

              ppd.UpperSheetProgressRange = 100;

              ppd.SheetProgressPos = 0;

              PlotPageInfo ppi = new PlotPageInfo();

              pe.BeginPage(

                ppi,

                pi,

                true,

                null

              );

              pe.BeginGenerateGraphics(null);

              pe.EndGenerateGraphics(null);

              // Finish the sheet

              pe.EndPage(null);

              ppd.SheetProgressPos = 100;

              ppd.OnEndSheet();

              // Finish the document

              pe.EndDocument(null);

              // And finish the plot

              ppd.PlotProgressPos = 100;

              ppd.OnEndPlot();

              pe.EndPlot(null);

            }

          }

        }

        else

        {

          ed.WriteMessage(

            "\nAnother plot is in progress."

          );

        }

      }

    }

  }

}

  1. Hi Kean.

    You can use Point3d directly in P/Invoke where the parameter is an ads_point (note the use of the 'out' param modifier for output params):

    static extern int acedTrans( Point3d point, IntPtr fromRb, IntPtr toRb, int disp, out Point3d result );
  2. Thanks, Tony.

    In this case it doesn't really improve the flow of the code, as we need to create an Extents2d object from the results. But it's certainly a good tip for cases where Point3ds are to be used afterwards.

    Regards,

    Kean

  3. Hello Kean,

    I am trying to print Autocad file using .NET windows application. I am not able to find Autodesk in my using function. Can you guide me how to do this?
    It will be better if I could get code to accomplish this. I have autocad 2007 installed in my system.

    Thanks and Warm Regards,
    Sudarshan

  4. Hi Sudarshan,

    You will need to set a project reference to acmgd.dll and acdbmgd.dll (in the AutoCAD install folder).

    Check out this introductory post, which talks about using the ObjectARX Wizard to set your project up.

    Regards,

    Kean

  5. Hi Kean,

    Thank you for the reply. I am able to set project references. How do I print the Autocad drawing from .NET? I was not able to find the solutions on internet.
    Is there any function in Autocad that can take path of drawing and print it to printer?

    Regards,

    Sudarshan

  6. Hi Sudarshan,

    Not a single function - there's a complete Plotting API that does this. Take a look at the posts under "Plotting".

    Regards,

    Kean

  7. Hi Kean,

    Can you send me code from which I can achieve plotting of drawing from .NET?
    I had a look at the plotting, but was not able to understand since input is taken from Autocad.

    I am in really need of this.

    Regards,
    Sudarshan

  8. Sudarshan - I don't understand what it is you want that's different from what's posted. All those posts plot drawings in different ways (whether single or multi-sheet, or with/without preview).

    If you're trying to do this without AutoCAD running (which you did not state in your previous comments) then it won't work, I'm afraid.

    Regards,

    Kean

  9. Hi Kean,

    Can you send the project file to my email id? I will try to trace the application from beginning. Also I am not able to incorporate your code into my application.

    regards,
    Sudarshan

  10. Hi Sudarshan,

    I'm sorry - if I start providing this kind of custom support, it'll never end. I help when there are specific issues with my posts, but otherwise it's just not feasible.

    Please post to the .NET discussion group or request help from my team via the Autodesk Developer Network (if you're a member).

    Also, the AutoCAD Developer Center has a lot of helpful "getting started" information, including some Labs for AutoCAD .NET.

    Regards,

    Kean

  11. Kean,

    When I include your code into my application it says " Application' is an ambiguous reference". Can you guide me how to solve this error?

    Regards,
    Sudarshan

  12. Sudarshan,

    It's probably because you're including System.Windows.Forms:

    using System.Windows.Forms;

    Both this and Autodesk.AutoCAD.ApplicationServices include an Application type. So you need to disambiguate the use of Application by prefixing the use of Application with the relevant namespace (for instance).

    Regards,

    Kean

  13. How do I solver this error?

    An unhandled exception of type 'System.IO.FileNotFoundException' occurred in WindowsApplication6.exe

    Additional information: File or assembly name acdbmgd, or one of its dependencies, was not found.

    Regards,
    Sudarshan

  14. Sudarshan - please post your introductory support-related question to the ADN team or the .NET discussion group.

    Regards,

    Kean

  15. I shall do that Kean.
    Is there any way to Converting autocad drawing into PDF format?

    Regards,
    Sudarshan

  16. You will need to plot. You can use the standard "DWG to PDF.pc3" device or a 3rd party printer driver.

    Kean

  17. What has to be included to get AutoDesk.AutoCAD.Interop.Application?

    Sudarshan

  18. Kean,
    Can you tell me which part of code has to be used just to plot(Without selecting the points)? I need to plot the drawing file.

    Sudarshan

  19. Good stuff Kean,
    You've been kicked (a good thing) - Trackback from CadKicks.com
    cadkicks.com/adk...

  20. Can anybody explain howthe code works

  21. Sony -

    I'd suggest downloading the ObjectARX SDK (autodesk.com/objectarx) and looking at the documentation... it is mainly covering ObjectARX, but the .NET layer is very "thin", so the descriptions should be adequate for both environments (although not ideal).

    Kean

  22. Thanks Kean,

    Actually i wanted to ask can i get sample code for custom plotting of autocad layout drawings from .net using vb.net.My application will be having a interface where it will show the plotter set,and also scale options and user can select any layout which displayed in the listbox provided.

    basically a plotter manager .net application which will take layout drawings and send it for plotting according to the settings made by the user.

    And i also wanted a sample code as how to convert Autocad file to PDF Format without opening autocad

  23. i want to load a dll automatically when autocad 2008 opens instead of using netload.can any one help?

  24. how to avoid proxy information dialog box from appearing while openeing a autocad civil 3d 2008 drawing in autocad 2008.

    Proxy information:Drawing contains objectARX entities.

  25. Sony,

    Please post your questions to the AutoCAD .NET Discussion Group - this is not the right forum.

    BTW - check out this post for the automatic loading question.

    Regards,

    Kean

  26. how to convert a dwg file to pdf file

  27. Hi kean..

    I have problem converting a dwg to pdf.Autocad 2008 civil 3D..The conversion is fine but the text appears more thicker and fat compared to DWG Output..can i get any solution regartding this..its urgent..

  28. Kean Walmsley Avatar

    Hi Sony,

    Just a guess, but you may need to tweak the plot styles you're using. I'm far from being a plotting expert, though - the standard user-oriented AutoCAD discussion group might give some further clues.

    Regards,

    Kean

  29. how to get into the standard user-oriented AutoCAD discussion group ..?

  30. Kean Walmsley Avatar

    Here's the list of the AutoCAD Discussion Groups and apparently there's a specific group for Printing and Plotting.

    Kean

  31. Hi kean,

    i had a unicode problem for my vc++ code done for Autocad 2004.

    Since i want my code to run for Autocad 2008 i am facing some unicode problem..can i get help regarding solving the issue.

  32. can i know where i can download the object ARX for 2004??

  33. Sorry, Sony - this is not a way to get support. Please use ADN or the discussion groups.

    That said, AutoCAD 2004 is no longer supported, so I don't know how you'd get hold of its ObjectARX SDK.

    Kean

  34. how to save plot file?

  35. This code does plot to a file.

    Kean

  36. how can I explicitly specify path of .plt file?

  37. The BeginDocument() call.

    Kean

  38. Hello Keane,
    I want to get Attributes of a Autocad electrical diagram.how should i do?

  39. Sorry - I don't know AutoCAD Electrical,

    I suggest posting your question to the ADN team (if you're a member) or one of our discussion groups.

    Kean

  40. Hi Kean:

    During "GetEntity" call - I want to have the picked point on the selected object (it's a 3D drawing). I think I've to use "acedTrans" from DCS to WCS - in some way - but how?

    Regards
    -Partha

  41. There's some code in this recent post that may help (search the page for "EyeToWorld").

    Kean

  42. Hi Kean,

    I just wanted to know where i can get the support for converting the Old Project to New VS2008 regarding the UNICODE Conversion Problems.

  43. Hi Sony,

    Aside from these two posts, the ADN team will be able to help you (if you're a member) or the AutoCAD .NET Discussion Group, otherwise.

    Good luck,

    Kean

  44. Error53error LNK2019: unresolved external symbol "public: enum Acad::ErrorStatus __thiscall AcDbDatabase::insert(class AcDbObjectId &,char const *,class AcDbDatabase *,bool)" (?insert@AcDbDatabase@@QAE?AW4ErrorStatus@Acad@@AAVAcDbObjectId@@PBDPAV1@_N@Z) referenced in function "protected: void __thiscall SeconMain::OnCmdProcess(void)" (?OnCmdProcess@SeconMain@@IAEXXZ)SeconMain.obj

    i converted my old object arx progrsmme from vc 6.0 to VS 2005..I have solved all the errors but now i am getting LINK error as shown above.i Tried to solve this but No threads helped in solving the problem..Can you just suggest me the site or support where i can get the solution for the problem..

    Thanks in advance
    Sony

  45. Sorry - the ADN team will be able to help, I'm sure.

    Kean

  46. Hi Kean

    Can i know how to get the SDI value programmatically in vc++6.0 and set the value through programme

  47. Sony,

    You seem to be using this one post as a support forum, which it is not.

    Please redirect your questions to the ADN team or to the Autodesk Discusion Groups.

    Kean

  48. Hi kean,

    I was just guessing as whether its possible to add a Single Mtext object in Autocad and Text as two different color..

    i meant part of text ,say for example is in Red and other part is blue..

    Mtext example--"Hi how are you"

    "Hi" should be in red and "how are you" should be in blue..through Programmatically..

  49. Sony,

    You seem to be ignoring my repeated requests to find another way to get support. Please stop posting comments like this, or I will be forced to block you (something I haven't yet had cause to do and am reluctant to start).

    Kean

  50. Hi Kean..

    I wrote here 'cause i saw the transformation about wcs and dcs. I'm not sure if my trouble is similar.

    I'm looking without found it, something to perform a good zoom in a viewport in paperspace.
    I'm not able to center my objects in my viewport.

    If i run ZoomWin in viewport it works always in 3d ucs.

    Have You got an Idea ? I have the rights points in 3d but when i run the zoom Autocad return in plan view.

    Resume:
    Creation Layout
    Creation some viewport
    SettingViewpoint in viewport
    _____________________________

    Now here I need to center my objects in a particular viewport.

    ____________________________
    Any suggestion is appreciated!!!
    thanks in advance for your attention.

  51. Giuliano,

    It sounds as though you actually want to modify the view inside the viewport object?

    That's a different problem than the one solved by this post - you should be able to get the Viewport object from the paperspace block table record and manipulate it directly.

    Regards,

    Kean

  52. Michael Csikos Avatar
    Michael Csikos

    Hi Kean

    I've been using this code for months without problems. Now we are adding the ability to plot the non-current layouts. But, would you believe I can't work out how to set the current layout? The following is not working:

    LayoutManager.Current.CurrentLayout = layoutName;

    I've also tried just retrieving the Layout object and plotting it directly, but the PlotInfoValidator throws eLayoutNotCurrent.

    Kind regards
    Michael

  53. Michael Csikos Avatar
    Michael Csikos

    Hi Kean

    I've been using this code for months without problems. Now we are adding the ability to plot the non-current layouts. But, would you believe I can't work out how to set the current layout? The following is not working:

    LayoutManager.Current.CurrentLayout = layoutName;

    I've also tried just retrieving the Layout object and plotting it directly, but the PlotInfoValidator throws eLayoutNotCurrent.

    Kind regards
    Michael

  54. Michael Csikos Avatar
    Michael Csikos

    I probably should have mentioned I'm using AutoCAD 2009 x64 - I know there are other things which simply don't work under x64 (like ToolTips). I hope setting the current layout doesn't fall into that category.

    Michael

  55. Michael Csikos Avatar
    Michael Csikos

    Sorry for the number of posts.

    A little more info: setting the layout works if the CommandMethod is NOT CommandFlags.Session. What I'm writing is a batch plotter which opens a list of dwg files, switches to the appropriate layout, and plots, so obviously it needs to be Session. The line that sets the CurrentLayout has no effect (no exception thrown either).

    Regards
    Michael

  56. Kean Walmsley Avatar

    Could it be you're forgetting to lock the document? If the command is modal (i.e. not session) the locking is handled automatically. Session commands work across documents, so you need to do it manually with Document.LockDocument().

    Kean

  57. Michael Csikos Avatar
    Michael Csikos

    Indeed that was the problem. Thanks Kean.

  58. Hello Kean,

    First, thanks for that great post, but i have still one problem. If i use PlotType.Window and a PlotRotation.Degrees000 I don't see anything on the paper. Also the plot will be empty. But if set the PlotRotation.Degrees.090 or anything else, it works. Do you have an idea, what's wrong?

    regards,
    Patrick

  59. Hi Patrick,

    I'm sorry - I don't know what's happening here. Have you tried with different paper-sizes?

    Regards,

    Kean

  60. Hi Kean.

    Thank you for all of your efforts in "Through the Interface" - a very valuable resource. I realize this is an old post but hopefully you can offer some insight.

    I can't get past psv with a custom paper size. This works:
    psv.SetPlotConfigurationName(
    ps,
    "DWF6 ePlot.pc3",
    "ANSI_A_(8.50_x_11.00_Inches)"
    );
    But, if I create a custom page size in dwf6 eplot.pc3 called test, this does not work (eInvalidInput):
    psv.SetPlotConfigurationName(
    ps,
    "DWF6 ePlot.pc3",
    "test"
    );
    Can you try that for me please?

    TIA

  61. I found the answer here:
    keanw.com/2007/10/allowing-select.html.
    The setplotconfigurationname requires canonical media name.

  62. Kean Walmsley Avatar

    Great! Thanks for letting me know.

    I was struggling to find time to look into this, so I'm delighted you've found the answer.

    Kean

  63. Kean,

    I don't know what I'd do without your posts! Thanks for all the great work. I am experiencing the same problem reported by Patrick above. My program uses JPG-PLOT.pc3 file to output a JPG to file. I had the program working just fine using much of your code above, but I apparently broke it at some point. Now, when using PlotType.Window and a PlotRotation.Degrees000 the plot file is always empty. If I set PlotRotation.Degrees.090 or anything else, it works fine. I've checked the medianame that I'm passing to psv.SetPlotConfigurationName and it's valid. Ideas?

    Thanks!

  64. Steve,

    I haven't been able to reproduce the problem (I don't have the PC3 file you've mentioned).

    How about if you ommit the call to SetPlotRotation()? Surely setting a 0 rotation is the same as not setting one at all?

    Regards,

    Kean

  65. Kean,

    I'm a member of ADN and Wayne Brill there came up with the solution for the JPEG plot files coming out empty. Turns out there's a "feature" <g> of the plotting API that REQUIRES that the points specifying the window be from the upper left to the lower right. I was seeing the problem only with PlotType.Window and PlotRotation.Degrees000.

    The workaround is to pass the user-selected window points through a function that calculates the lower left and upper right corners and then create the Extents2d object that you pass to PlotSettingsValidator.SetPlotWindowArea() from those points.

    I can send the code Wayne created if that will help, Kean. This issue might be a good addition to a post or KB article.

    Steve

  66. Steve,

    Fantastic - thanks for letting me know.

    I see the case Wayne handled, so can take it from here.

    Best regards,

    Kean

  67. The link above fails because of the dot at the end.

    keanw.com/2007/10/allowing-select.html

  68. Hi Kean

    Question: PlotInfo, PlotSettings, and PlotSettingsValidator all are implementin IDisposeable. Is it really ok to not enclose them in a using directive, even they weren't created through the Transaction?

    Thank you for your hint.

    Best,
    Martin

  69. Thanks, Martin.

    I don't usually edit other people's comments on this blog, but as you pointed out the link they'd posted failed, I went ahead and deleted the full stop. It should work now.

    Regards,

    Kean

  70. Hi Martin,

    That's a good question.

    I can't remember, off the top of my head, why I didn't dispose them via using - I suggest making the change and testing to see what happens.

    In the context of this post, I'd say these objects belong to the first category 'Temporary objects of types not derived from DBObject', which are 'safe to be disposed of either "manually" (by your own code) or "automatically" (by the .NET garbage collector)'.

    Regards,

    Kean

  71. Tomislav Buturajac Avatar
    Tomislav Buturajac

    Hi Kean,
    very informative web you have.

    In all your examples you are using plot progress dialog. Can I call standard plot dialog before plotting from .net?
    Like, setting paper format and style but allowing user to change scale before plotting through standard plot dialog.

    Regards,
    Tomislav

  72. Hi Tomislav,

    Not that I'm aware of: you can certainly launch the PLOT command via SendStringToExecute() but I don't know how you'd specify certain parameters (without resorting to Windows messages on the dialog to simulate clicks - even that would be challenging, as you'd need to adapt to different combobox contents, etc.).

    Regards,

    Kean

  73. This ist for further readers:

    I found, that the call to psv.SetPlotConfigurationName(...); comes too late in those cases where an existing Layout has a configured printer not available on that machine (e.g. a file from an external construction company.) In detail, I added some more calls to set psv properties, e.g. for paper units. This call to set paper units failed with an error code of eInvalidInput.

    The call to SetPlotConfigurationName, followed by a call to RefreshLists has to be the first calls to the psv instance prior to set any of the other properties. At least in my case, it solved the problem.

  74. Hi Kean
    Just wondering...as I am creating a user interface that includes selecting a Plot Window button...

    Is it possible to emulate the way AutoCAD shows the previous sleced window by greying the area outside the window coordinates when the Window button is clicked?

    This would be a useful tool to have in the back of the ute...

    Regards
    Kieran

  75. Kean Walmsley Avatar

    Hi Kieran,

    An interesting suggestion - it would indeed be a handy little tool have available.

    I'll see what's exposed - the fact that it effectively blocks navigation via the ViewCube implies it's a little more complicated that placing transiently displaying some transparent rectangles.

    Regards,

    Kean

  76. Kean Walmsley Avatar

    From what I can tell, there isn't an easy approach for this... the internal mechanism would need to be exposed.

    Kean

  77. Hey Kean

    Thanks for the quick response.

    I'm going to see what I can do to as an alternative display to achieve the same net result.

    Thanks again for being a continual source of reference.

    Cheers

    Kieran

  78. Hey Kean,

    Should this plot program take significantly longer to print (around 30 seconds) than the normal plot command (around 3 seconds)?

    Thanks

    Jack

  79. Hi Jack,

    I wouldn't expect it to take that much longer, no. But then it is possible that it might, depending on the circumstances (how your app is running, whether it's being debugged... the core plotting code inside AutoCAD is native, but that difference seems extreme).

    Regards,

    Kean

  80. Just a thought: do make sure you're comparing the two techniques using foreground plotting (of course).

    Kean

  81. Aha, the foreground plotting was the issue. Plotting was set to foreground but publishing wasn't. Thanks for the help!

  82. Hi Kean,

    I'm trying to plot on a installed network plotter. However my code only produces a .plt file.

    Even with your choosemedia post it only produces this .plt file. All working fine for .pC3 files but not for the printer itself.

    is ther something i need to do like create the .pc3 file or some plottofile to false?

    regards,
    Jorit

  83. Kean Walmsley Avatar

    Hi Jorit,

    Sorry - I don't know why this is happening, I'm afraid. I have only used this approach to plot via PC3 files, as far as I remember (and it's been a while).

    Regards,

    Kean

  84. i am getting error near the below line,

    ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Plot Progress")

    "set_plotmsgstring is not a member of autodesk.autocad.plottingservices.plotprogressdialog"

    I have added refernece of acdbmgd.dll and acmgd.

    I am using VIsual sutdio 2008 and autocad 2007.

    Could anyone pelase help me out from this issue?

    Thank you.

  85. Hi Swetha,

    It sounds as though AutoCAD 2007 doesn't have all the API capabilities used in this blog post (which isn't a big surprise, given the relative maturity of the 2007 API).

    Regards,

    Kean

  86. Hmm... given the age of the post, I suspect it does work with AutoCAD 2007. But I haven't seen other reports of this problem. Very strange.

    Kean

  87. Kean

    I know this is an old post but it is about this subject.

    I wrote an out of process program to plot drawings which worked fine up to 2008, but in 2011 I am having problems with plotting a window.

    What I would like to ask is, in an out of process program what class/method would you use to set the plotting settings especially the plot window.

    Also if I re-write it as an in process program, same question.

    Thanks

  88. Colin,

    Although it's on this topic, it's not specifically related to the code in the post (and therefore constitutes a support request, which I unfortunately don't have time to deal with).

    I suggest posting your question via ADN, if you're a member, or otherwise the AutoCAD .NET Discussion Group.

    Regards,

    Kean

  89. Kean

    Will do

    thanks

  90. Márcio L. Cartacho Avatar
    Márcio L. Cartacho

    Hi,

    I am having some problems to control the drawing orientation Landscape or Portrait using API AutoCAD.Net C#.

    Some one can help me?

  91. This isn't a forum for support... please post your question to the ADN team, if you're a member, or otherwise the AutoCAD .NET Discussion Group.

    Regards,

    Kean

  92. Kean, I would definitely suggest only one thing, and that is a larger area for the code to be shown in your blog. These word wraps kill the ability to read your code in a browser. You are almost forced to copy it out.

    Thanks for the code.

  93. The template for the blog was defined by the team that manages the Autodesk blogging infrastructure... I've played with different font sizes, column widths, etc., but found what I have to be about as good as I could expect to get.

    I've had surprisingly few negative comments about this over the years, but I certainly agree that it's not ideal.

    Kean

  94. Plot Landscape:
    psv.SetPlotRotation(ps, PlotRotation.Degrees090);

    Plot Portrait:
    psv.SetPlotRotation(ps, PlotRotation.Degrees000);

  95. Job: - Plotted with Error(s) and Canceled Sheets

    Job ID: 1
    Sheet set name:
    Date and time started: 11/18/2013 11:51:51 PM
    Date and time completed: 11/18/2013 11:51:53 PM
    UserID: Cao Dung
    Profile ID: <<unnamed profile="">>
    Total sheets: 1
    Sheets plotted: 0
    Number of errors: 2
    Number of warnings: 0

    Sheet: UnsavedDwg_1-Model - Canceled

    File: <unsaved drawing="">
    Category name:
    Page setup:
    Device name: DWG To PDF.pc3 - plotted to file
    Plot file path: D:\DOCUMENTS\Cao Dung\Doccuments\WinPlot.PDF
    Paper size: ISO full bleed A3 (420.00 x 297.00 MM)

    ERROR:

    ERROR: The publishing operation was canceled.

  96. You seem to be indicating this isn't working for you. I'll need more information to be able to reproduce the problem (and it would have to be with the code in this blog post for me to find the time to look into it, unfortunately).

    Kean

  97. Is it possible to create add custom paper with dimensions from user?

  98. Is there a certain procedure for setting the PlotType to Layout? Every time I try to set through .Net it spits out an "eInvalidInput" error. I'm guessing I'm not setting the proper variables in the correct order.

    1. Kean Walmsley Avatar

      Please post your code to the AutoCAD .NET forum: someone there should be able to help.

      Kean

  99. Hi,
    I am trying to plot a layout using above code in AutoCAD 2018 version.
    And I am getting "eNoFileName" error while debugging using Visual Studio 2016.
    Please assist me...

Leave a Reply

Your email address will not be published. Required fields are marked *