<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PLOTDATE field value updates via PLOT but not when plotted via API in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756074#M51644</link>
    <description>&lt;P&gt;I compared the code of each app and they are a match, which is what I expected because I built the BatchPlot app off of the other one.&lt;BR /&gt;&lt;BR /&gt;I really think this is an issue with the WorkingDatabase and the "Batch" nature of my app.&lt;BR /&gt;I can't post all my code but here is what I think is relevant:&lt;BR /&gt;&lt;BR /&gt;'This is sub that loops and processes each selected drawing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub MySub()
    Dim dwg As Document = Nothing
    For Each dwgFile In files
        'open the drawing
        dwg = Application.DocumentManager.Open(dwgFile, True)

'--TRIED THIS LINE WITHOUT SUCCESS
        'HostApplicationServices.WorkingDatabase = dwg.Database

'--TRIED THIS LINE WITHOUT SUCCESS
        'Application.DocumentManager.MdiActiveDocument = dwg		

	MyPlottingFunction()

	dwg.CloseAndDiscard()
    Next
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This is the function that handles the plotting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Function MyPlottingFunction()
    Try
'--HAVE CONFIRMED HERE VIA db.FileName PROPERTY THAT WorkingDatabase IS SET TO CURRENTLY OPEN/ACTIVE DRAWING
        Using db As Database = HostApplicationServices.WorkingDatabase	
            Using tr As Transaction = db.TransactionManager.StartTransaction

                Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead)
                Dim objLayout As Layout = tr.GetObject(btr.LayoutId, OpenMode.ForRead)
                Dim pi As PlotInfo = New PlotInfo
                pi.Layout = btr.LayoutId

	        ...
                ...
	    End Using
	End Using
    Catch
        ...
    End Try
End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;In the "MyPlottingFunction" above I even tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim db As Database = dwg.Database&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dwg PASSED IN AS BYREF PARAM (MY ORIG CODE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HostApplicationServices.WorkingDatabase = db&amp;nbsp;&amp;nbsp;&amp;nbsp; 'db PASSED IN AS BYREF PARAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I once struggeled with a batch application that was not setting my variables to the "active" drawing and found the solution was to add the Session attribute to the CommandMethod like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CommandMethod("BP", CommandFlags.Session)&amp;gt; _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub Main()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had this setting in my BatchPlot app from the begining however.&amp;nbsp; Stumped!&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jan 2013 00:22:34 GMT</pubDate>
    <dc:creator>MarkSanchezSPEC</dc:creator>
    <dc:date>2013-01-18T00:22:34Z</dc:date>
    <item>
      <title>PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3750675#M51639</link>
      <description>&lt;P&gt;A client has specified that we include a "PlotDate" field in lieu of regular attribute in their title block.&amp;nbsp; This is formatted to contain, what else, but the date and time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When our users enter the PLOT command, this field gets automatically updated to the current date and time, resulting in a plot with a plot stamp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when we use our custom Batch Plot utility (VB.NET API), the drawings get plotted but the PlotDate field does NOT get updated.&amp;nbsp; I have found that fields of this type do not get updated via events like other fields, but rather when you call the UPDATEFIELD command.&amp;nbsp; However, the PLOT command itself must be doing something similar, as evidenced by the fact that the value of the field changes upon each PLOT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about "updating/refreshing" a "PlotDate" field when plotting a file via the API?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2013 23:41:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3750675#M51639</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-10T23:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755158#M51640</link>
      <description>&lt;P&gt;Hello Mark,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a sample code to plot to PDF and the sample AutoCAD 2013 drawing that I am using which has a PlotDate field. The code to do the plotting is mostly from Kean's blog post.&lt;/P&gt;
&lt;P&gt;After the plotting using&amp;nbsp;this command,&amp;nbsp;the field does get updated. Can you please see how this differs from what you are trying ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("GenPdf")]
public void GenPdf()
{
    try
    {
        PlotExtents("DWG To PDF.pc3", "ISO_expand_A4_(210.00_x_297.00_MM)", "monochrome.ctb", @"C:\Temp\Test.pdf");
    }
    catch (System.Exception e)
    {
        e.GetBaseException().ToString();
    }
}

// Plotting progress based on 
// &lt;A href="http://through-the-interface.typepad.com/through_the_interface/2007/09/driving-a-multi.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2007/09/driving-a-multi.html&lt;/A&gt;
static public void PlotExtents(string printer, string format, string styleSheet, string pdfFilePath)
{
    try
    {
        Document doc = Application.DocumentManager.MdiActiveDocument;
        Editor ed = doc.Editor;
        Database db = doc.Database;

        using (Transaction tr = db.TransactionManager.StartTransaction())
        {
            BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
            Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

            PlotInfo pi = new PlotInfo();
            pi.Layout = btr.LayoutId;

            PlotSettings ps = new PlotSettings(lo.ModelType);
            PlotConfigInfo pci = new PlotConfigInfo();

            ps.CopyFrom(lo);
            ps.PlotPlotStyles = true;

            PlotSettingsValidator psv = PlotSettingsValidator.Current;
            psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
            psv.SetDefaultPlotConfig(ps);

            psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
            psv.SetUseStandardScale(ps, true);
            psv.SetPlotCentered(ps, true);
            psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);


            ////PS-PlotRotation
            Extents2d extent2d = ps.PlotPaperMargins;
            if (extent2d.MaxPoint.Y &amp;gt; extent2d.MaxPoint.X)
            {
                psv.SetPlotRotation(ps, PlotRotation.Degrees000);
            }
            else
            {
                psv.SetPlotRotation(ps, PlotRotation.Degrees090);
            }

            try
            {
                psv.SetPlotConfigurationName(ps, printer, null);
                psv.SetPlotConfigurationName(ps, printer, format);
                psv.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters);
            }
            catch (System.Exception e)
            {
                e.GetBaseException().ToString();
            }

            psv.GetCanonicalMediaNameList(ps);
            pi.OverrideSettings = ps;

            PlotInfoValidator piv = new PlotInfoValidator();
            piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
            piv.Validate(pi);

            if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
            {
                using (PlotEngine pe = PlotFactory.CreatePublishEngine())
                {
                    PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
                    using (ppd)
                    {
                        ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "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;

                        ppd.OnBeginPlot();
                        ppd.IsVisible = true;
                        ppd.OnBeginPlot();
                        ppd.IsVisible = true;
                        pe.BeginPlot(ppd, null);

                        pe.BeginDocument(pi, doc.Name, null, 1, true, pdfFilePath);

                        ppd.OnBeginSheet();
                        ppd.LowerSheetProgressRange = 0;
                        ppd.UpperSheetProgressRange = 100;
                        ppd.SheetProgressPos = 0;

                        PlotPageInfo ppi = new PlotPageInfo();
                        pe.BeginPage(ppi, pi, true, null);
                        pe.BeginGenerateGraphics(null);
                        ppd.SheetProgressPos = 50;
                        pe.EndGenerateGraphics(null);

                        pe.EndPage(null);
                        ppd.SheetProgressPos = 100;
                        ppd.OnEndSheet();

                        pe.EndDocument(null);

                        ppd.PlotProgressPos = 100;
                        ppd.OnEndPlot();

                        pe.EndPlot(null);
                    }
                }
            }
            else
            {
                ed.WriteMessage("\nCannot plot. System is busy plotting another one.");
            }

            tr.Commit();
        }
    }
    catch (System.Exception e)
    {
        // Display the error message here.
    }
}
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 06:16:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755158#M51640</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2013-01-17T06:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755803#M51641</link>
      <description>&lt;P&gt;Balaji,&lt;BR /&gt;I too originally got my code from Keans blog and have tweaked it to my use.&lt;BR /&gt;There were only a few lines from your post that I did not have in mine so I added them in the following manner:&lt;BR /&gt;&lt;BR /&gt;1. Added 1st missing line&lt;BR /&gt;2. Test plotted my drawing - Bad results&lt;BR /&gt;3. Added 2nd missing line, leaving 1st line&lt;BR /&gt;4. Test plotted my drawing - Bad results&lt;BR /&gt;5. etc.&lt;BR /&gt;&lt;BR /&gt;Even with all the missing lines added, I could not produce output where the field updated.&lt;BR /&gt;I was beginning to think that maybe it was an issue with my own drawing but everytime I issue the PLOT command in it, the field updates.&lt;BR /&gt;&lt;BR /&gt;Next I turned my attention to your posted file (Test.dwg)&lt;BR /&gt;The first thing I had to do though was save it down to 2010 format using DWG TrueView/DWG Convert.&lt;BR /&gt;My post on the subscription site notes that we use the 2012 Infrastructure Suite.&lt;BR /&gt;&lt;BR /&gt;Once I did that, I first used my original code to plot it out in Civil 2012 and once again the field did not update.&lt;BR /&gt;I then re-applied the missing lines from your post and re-plotted, but once again the field did not update.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;This leads me to believe that perhaps it is an issue with 2012 that was fixed in 2013?&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Can you try creating a similar drawing in 2012 (2010 format) then test your API code on it?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Mark&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:54:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755803#M51641</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-17T18:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755991#M51642</link>
      <description>&lt;P&gt;You create Batch Plot utility. I will ask&amp;nbsp;&lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;three&lt;/SPAN&gt;&lt;/SPAN&gt; naive question.&lt;BR /&gt;1. Do you switch WorkingDatabase to the Database which plotting?&lt;BR /&gt;2. Do you save Database after plotting?&lt;/P&gt;
&lt;P&gt;3. Code of Balaji (as is without your's changes) working as &lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;expected or no with AutoCAD 2012?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 22:18:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3755991#M51642</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-17T22:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756033#M51643</link>
      <description>&lt;P&gt;Update: It works in 2012 with the 2010 format.&amp;nbsp; I just tested another app I have that produces single plots of the current drawing - It is a sort of simplified version of the PLOT command for use mainly by our non-CAD staff.&amp;nbsp; Plotting Balaji's drawing with it just produced a plot with the PlotDate field updated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am going to compare this code carefully with my Batch Plot code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your comment regarding WorkingDatabase is resonating in my mind - I am not setting this currently in the BatchPlot nor the app mentioned above, but it DOES make sense to do so while in batch mode...will re-post efforts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 22:55:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756033#M51643</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-17T22:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756074#M51644</link>
      <description>&lt;P&gt;I compared the code of each app and they are a match, which is what I expected because I built the BatchPlot app off of the other one.&lt;BR /&gt;&lt;BR /&gt;I really think this is an issue with the WorkingDatabase and the "Batch" nature of my app.&lt;BR /&gt;I can't post all my code but here is what I think is relevant:&lt;BR /&gt;&lt;BR /&gt;'This is sub that loops and processes each selected drawing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub MySub()
    Dim dwg As Document = Nothing
    For Each dwgFile In files
        'open the drawing
        dwg = Application.DocumentManager.Open(dwgFile, True)

'--TRIED THIS LINE WITHOUT SUCCESS
        'HostApplicationServices.WorkingDatabase = dwg.Database

'--TRIED THIS LINE WITHOUT SUCCESS
        'Application.DocumentManager.MdiActiveDocument = dwg		

	MyPlottingFunction()

	dwg.CloseAndDiscard()
    Next
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This is the function that handles the plotting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Function MyPlottingFunction()
    Try
'--HAVE CONFIRMED HERE VIA db.FileName PROPERTY THAT WorkingDatabase IS SET TO CURRENTLY OPEN/ACTIVE DRAWING
        Using db As Database = HostApplicationServices.WorkingDatabase	
            Using tr As Transaction = db.TransactionManager.StartTransaction

                Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead)
                Dim objLayout As Layout = tr.GetObject(btr.LayoutId, OpenMode.ForRead)
                Dim pi As PlotInfo = New PlotInfo
                pi.Layout = btr.LayoutId

	        ...
                ...
	    End Using
	End Using
    Catch
        ...
    End Try
End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;In the "MyPlottingFunction" above I even tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim db As Database = dwg.Database&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dwg PASSED IN AS BYREF PARAM (MY ORIG CODE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HostApplicationServices.WorkingDatabase = db&amp;nbsp;&amp;nbsp;&amp;nbsp; 'db PASSED IN AS BYREF PARAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I once struggeled with a batch application that was not setting my variables to the "active" drawing and found the solution was to add the Session attribute to the CommandMethod like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CommandMethod("BP", CommandFlags.Session)&amp;gt; _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub Main()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had this setting in my BatchPlot app from the begining however.&amp;nbsp; Stumped!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 00:22:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756074#M51644</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-18T00:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756184#M51645</link>
      <description>&lt;P&gt;Hello Mark,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried making the command run in the "Session" context, but it still worked ok in AutoCAD 2012.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried not opening the drawing using "Application.DocumentManager.Open(dwgFile, True)" and having your code plot the drawing which is already open in the editor ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, I am not sure what else might be causing this issue.&lt;/P&gt;
&lt;P&gt;You may try isolating chunks of your code at a time and narrow down on the cause.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 06:12:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756184#M51645</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2013-01-18T06:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756189#M51647</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;...&lt;BR /&gt;&lt;STRONG&gt;dwg.CloseAndDiscard()&lt;BR /&gt;&lt;/STRONG&gt;...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My second question was: &lt;EM&gt;&lt;STRONG&gt;2. Do you save Database after plotting?&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;You DO NOT save dwg-file after ploting and that is why PLOTDATE is not changed.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 06:22:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3756189#M51647</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-18T06:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3758047#M51648</link>
      <description>&lt;P&gt;Saving would not work.&amp;nbsp; The application is a batch plotter only, which never makes any changes to a drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I don't completely agree.&amp;nbsp; We are not trying to save the updated "PlotDate" field in the drawing itself.&amp;nbsp; We only wish to have the current date/time show up in the output plot (hard copy or pdf).&amp;nbsp; This is what happens when we PLOT a drawing - the drawing could be saved (or not), just as long as the output contains the date/time of the plotting operation.&amp;nbsp; Sorry for the confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 16:05:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3758047#M51648</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-21T16:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3758907#M51650</link>
      <description>&lt;PRE&gt;using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.PlottingServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

[assembly: CommandClass(typeof(Rivilis.PDFPlot))]

namespace Rivilis
{

  public class PDFPlot
  {
    [CommandMethod("GenPdf", CommandFlags.Session)]
    public void GenPdf()
    {
      string[] files = { "C:\\FieldPlot1.dwg", "C:\\FieldPlot2.dwg", "C:\\FieldPlot3.dwg" }; &lt;STRONG&gt;// Test files with PLOTDATE field&lt;/STRONG&gt;
      object oldBgPlot = Application.GetSystemVariable("BACKGROUNDPLOT");
      &lt;STRONG&gt;Application.SetSystemVariable("BACKGROUNDPLOT", 0);&lt;/STRONG&gt;
      Document oldDoc = Application.DocumentManager.MdiActiveDocument;
      Database oldDb = HostApplicationServices.WorkingDatabase;
      try {
        foreach (string file in files) {
          Document doc = Application.DocumentManager.Open(file, true);
          Application.DocumentManager.MdiActiveDocument = doc;
          HostApplicationServices.WorkingDatabase = doc.Database;
          using (DocumentLock docloc = doc.LockDocument()) {
            PlotExtents("DWG To PDF.pc3", "ISO_expand_A4_(210.00_x_297.00_MM)", "monochrome.ctb", file + ".pdf");
          }
          doc.CloseAndDiscard();
        }
        Application.DocumentManager.MdiActiveDocument = oldDoc;
        HostApplicationServices.WorkingDatabase = oldDb;
        Application.SetSystemVariable("BACKGROUNDPLOT", oldBgPlot);
      }
      catch (System.Exception e) {
        System.Windows.Forms.MessageBox.Show(
          e.ToString(),
          "Error",
          System.Windows.Forms.MessageBoxButtons.OK,
          System.Windows.Forms.MessageBoxIcon.Error);
      }
    }

    // Plotting progress based on 
    // &lt;A href="http://through-the-interface.typepad.com/through_the_interface/2007/09/driving-a-multi.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2007/09/driving-a-multi.html&lt;/A&gt;
    static public void PlotExtents(string printer, string format, string styleSheet, string pdfFilePath)
    {

      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      Database db = doc.Database;
      try {
        using (Transaction tr = db.TransactionManager.StartTransaction()) {
          BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
          Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

          PlotInfo pi = new PlotInfo();
          pi.Layout = btr.LayoutId;

          PlotSettings ps = new PlotSettings(lo.ModelType);
          PlotConfigInfo pci = new PlotConfigInfo();

          ps.CopyFrom(lo);
          ps.PlotPlotStyles = true;

          PlotSettingsValidator psv = PlotSettingsValidator.Current;
          psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
          psv.SetDefaultPlotConfig(ps);

          psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
          psv.SetUseStandardScale(ps, true);
          psv.SetPlotCentered(ps, true);
          psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);


          ////PS-PlotRotation
          Extents2d extent2d = ps.PlotPaperMargins;
          if (extent2d.MaxPoint.Y &amp;gt; extent2d.MaxPoint.X) {
            psv.SetPlotRotation(ps, PlotRotation.Degrees000);
          }
          else {
            psv.SetPlotRotation(ps, PlotRotation.Degrees090);
          }

          try {
            psv.SetPlotConfigurationName(ps, printer, null);
            psv.SetPlotConfigurationName(ps, printer, format);
            psv.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters);
          }
          catch (System.Exception e) {
            e.GetBaseException().ToString();
          }

          psv.GetCanonicalMediaNameList(ps);
          pi.OverrideSettings = ps;

          PlotInfoValidator piv = new PlotInfoValidator();
          piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
          piv.Validate(pi);

          if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting) {
            using (PlotEngine pe = PlotFactory.CreatePublishEngine()) {
              PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
              using (ppd) {
                ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "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;

                ppd.OnBeginPlot();
                ppd.IsVisible = true;
                ppd.OnBeginPlot();
                ppd.IsVisible = true;
                pe.BeginPlot(ppd, null);

                pe.BeginDocument(pi, doc.Name, null, 1, true, pdfFilePath);

                ppd.OnBeginSheet();
                ppd.LowerSheetProgressRange = 0;
                ppd.UpperSheetProgressRange = 100;
                ppd.SheetProgressPos = 0;

                PlotPageInfo ppi = new PlotPageInfo();
                pe.BeginPage(ppi, pi, true, null);
                pe.BeginGenerateGraphics(null);
                ppd.SheetProgressPos = 50;
                pe.EndGenerateGraphics(null);

                pe.EndPage(null);
                ppd.SheetProgressPos = 100;
                ppd.OnEndSheet();

                pe.EndDocument(null);

                ppd.PlotProgressPos = 100;
                ppd.OnEndPlot();

                pe.EndPlot(null);
              }
            }
          }
          else {
            ed.WriteMessage("\nCannot plot. System is busy plotting another one.");
          }

          tr.Commit();
        }
      }
      catch (System.Exception e) {
        // Display the error message here.
        System.Windows.Forms.MessageBox.Show(
          e.ToString(),
          "Error",
          System.Windows.Forms.MessageBoxButtons.OK,
          System.Windows.Forms.MessageBoxIcon.Error);
      }
    }
  }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This code was tested with AutoCAD 2012 and seems to work as expected. &lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 16:07:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3758907#M51650</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-22T16:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3759295#M51651</link>
      <description>&lt;P&gt;That's it!&lt;/P&gt;&lt;P&gt;Placing the call to my plotting function in a DocumentLock Using statement allowed the PlotDate field to update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Using dl As DocumentLock = doc.LockDocument&lt;BR /&gt;       MyPlottingFunction()&lt;BR /&gt;End Using&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;Thank you Alexandar!&amp;nbsp; I owe you a drink if you come out to AU or the ADN conference in Las Vegas this year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 22:56:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3759295#M51651</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-22T22:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: PLOTDATE field value updates via PLOT but not when plotted via API</title>
      <link>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3759447#M51652</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;That's it!&lt;/P&gt;
&lt;P&gt;Placing the call to my plotting function in a DocumentLock Using statement allowed the PlotDate field to update. &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hps"&gt;&lt;SPAN&gt;&lt;SPAN class="hps"&gt;An interesting&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;side effect.&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Usually&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;DocumentLock&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;need to use&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;only when&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;we change&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;something in the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Database.&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;In this case,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;we are not changing&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;anything&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Database&lt;/SPAN&gt;&lt;SPAN&gt;, but the change&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is due to the&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;recalculation of&lt;/SPAN&gt; &lt;SPAN class="hps atn"&gt;of fields (&lt;/SPAN&gt;&lt;SPAN class="alt-edited"&gt;including&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;PLOTDATE)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 06:26:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/plotdate-field-value-updates-via-plot-but-not-when-plotted-via/m-p/3759447#M51652</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-23T06:26:20Z</dc:date>
    </item>
  </channel>
</rss>

