<?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: SaveEventHandler not working in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436511#M6284</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2976437"&gt;@WPerciful&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the code that you sent but when you save the drawing it post the message.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which message?&lt;/P&gt;
&lt;P&gt;The event is raised after the save dialog box is closed with OK.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2023 16:05:51 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2023-12-12T16:05:51Z</dc:date>
    <item>
      <title>SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12435945#M6278</link>
      <description>&lt;P&gt;This is my fist time written an event handler.&amp;nbsp; While my code has no errors, it doesn't work.&amp;nbsp; Does anyone have any idea what I'm doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Imports System.Windows.Controls
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime

Namespace BeginSaveHandlingSample
    Public Class SaveEventHandler
        Implements IExtensionApplication
        Public Sub Initialize()
            Dim docs = Application.DocumentManager
            AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
            For Each doc As Document In docs
                AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
            Next
        End Sub

        Private Sub OnDocumentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
            AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
        End Sub

        Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
            Application.ShowAlertDialog("It worked!")
        End Sub

        Public Sub Terminate()
        End Sub

        Private Sub IExtensionApplication_Initialize() Implements IExtensionApplication.Initialize
            Throw New NotImplementedException()
        End Sub
        Private Sub IExtensionApplication_Terminate() Implements IExtensionApplication.Terminate
            Throw New NotImplementedException()
        End Sub
    End Class

End Namespace&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 12:36:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12435945#M6278</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T12:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436060#M6279</link>
      <description>&lt;P&gt;Since the class implement IExtensionApplication, so whenever the code is loaded, AutoCAD will call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Initialize()&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if any un-handled exception is thrown in Initialize(), the DLL loading would failed silently. So, it is important to use Try...Catch in the Initialze() for the code that does serious work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in your case, it is straightforward: you should remove the "Throw New NotImplementedException", which is added by Visual Studio automatically, and leave the Initialize() empty. If you do not plan to do any initializing work, you could have made the class not implement IExtensionApplication. It looks like, you may want to study a bit of more on what/why to use/implement IExtensionApplication.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 13:15:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436060#M6279</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-12-12T13:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436083#M6280</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Try removing:&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-visual-basic" tabindex="0"&gt;&lt;CODE&gt;
        Private Sub IExtensionApplication_Initialize() Implements IExtensionApplication.Initialize
            Throw New NotImplementedException()
        End Sub
        Private Sub IExtensionApplication_Terminate() Implements IExtensionApplication.Terminate
            Throw New NotImplementedException()
        End Sub&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 13:23:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436083#M6280</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T13:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436366#M6281</link>
      <description>&lt;P&gt;When I remove those lines of code I get the following error which prohibits me from building the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WPerciful_0-1702393981222.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1303896i6F22260CF4B80AED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WPerciful_0-1702393981222.png" alt="WPerciful_0-1702393981222.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 15:13:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436366#M6281</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T15:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436417#M6282</link>
      <description>&lt;P&gt;Your code should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Imports System.Windows.Controls
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime

Namespace BeginSaveHandlingSample
    Public Class SaveEventHandler
        Implements IExtensionApplication
        Public Sub Initialize() Implements IExtensionApplication.Initialize
            Dim docs = Application.DocumentManager
            AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
            For Each doc As Document In docs
                AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
            Next
        End Sub

        Private Sub OnDocumentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
            AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
        End Sub

        Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
            Application.ShowAlertDialog("It worked!")
        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate
        End Sub
    End Class

End Namespace&lt;/LI-CODE&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>Tue, 12 Dec 2023 15:31:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436417#M6282</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T15:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436507#M6283</link>
      <description>&lt;P&gt;I tried the code that you sent but when you save the drawing it post the message.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:03:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436507#M6283</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T16:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436511#M6284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2976437"&gt;@WPerciful&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the code that you sent but when you save the drawing it post the message.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which message?&lt;/P&gt;
&lt;P&gt;The event is raised after the save dialog box is closed with OK.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:05:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436511#M6284</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T16:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436524#M6285</link>
      <description>&lt;P&gt;I'm trying to get this message when you perform the save.&amp;nbsp; It's only for testing right now but once it works I'm going to have it call a sub to do some clean up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;        Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
            Application.ShowAlertDialog("It worked!")
        End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:11:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436524#M6285</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T16:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436595#M6286</link>
      <description>&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6342887000112w748h540r906" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6342887000112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6342887000112w748h540r906');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6342887000112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:30:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436595#M6286</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T16:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436651#M6287</link>
      <description>&lt;P&gt;When you save nothing happens other than the save itself.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:59:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436651#M6287</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T16:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436727#M6288</link>
      <description>&lt;P&gt;The saving process can only be started after the user has clicked OK (if he clicks Cancel, the saving process will not start).&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 17:35:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436727#M6288</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T17:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436932#M6289</link>
      <description>&lt;P&gt;If you replace:&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-general" tabindex="0"&gt;&lt;CODE&gt;Application.ShowAlertDialog("It worked!")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;by any process which modify the database, it will occur after the save file dialog closed and before the save process itself begins.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 19:24:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12436932#M6289</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T19:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12437017#M6290</link>
      <description>&lt;P&gt;When I test the same code it doesn't do that. What could I be doing differently?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 20:16:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12437017#M6290</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-12T20:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12437200#M6291</link>
      <description>&lt;P&gt;Try something like this (not sure about my VB).&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Public Class Initialization
    Implements IExtensionApplication

    Public Sub Initialize() Implements IExtensionApplication.Initialize
	Dim docs = Application.DocumentManager
	AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
	For Each doc As Document In docs
	    AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
	Next
    End Sub

    Public Sub Terminate() Implements IExtensionApplication.Terminate
    End Sub

    Private Sub OnDocumentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
        AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
    End Sub

    Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
        Dim db As Database = CType(sender, Database)
        DoItBeforeSave(db)
    End Sub

    Private Shared Sub DoItBeforeSave(ByVal db As Database)
        Using tr = New OpenCloseTransaction()
            Dim circle As Circle = New Circle(Point3d.Origin, Vector3d.XAxis, 10.0)
            circle.ColorIndex = 30
            Dim modelSpace As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
            modelSpace.AppendEntity(circle)
            tr.AddNewlyCreatedDBObject(circle, True)
            tr.Commit()
        End Using
    End Sub
End Class&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 21:45:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12437200#M6291</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-12T21:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438516#M6292</link>
      <description>&lt;P&gt;When I test what you shared nothing happens.&amp;nbsp; Could it be a setting or something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Imports System.Windows.Controls
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime

Namespace BeginSaveHandlingSample
    Public Class Initialization
        Implements IExtensionApplication

        Public Sub Initialize() Implements IExtensionApplication.Initialize
            Dim docs = Application.DocumentManager
            AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
            For Each doc As Document In docs
                AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
            Next
        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate
        End Sub

        Private Sub OnDocumentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
            AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
        End Sub

        Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
            Dim db As Database = CType(sender, Database)
            DoItBeforeSave(db)
        End Sub

        Private Shared Sub DoItBeforeSave(ByVal db As Database)
            Using tr = New OpenCloseTransaction()
                Dim circle As Circle = New Circle(Point3d.Origin, Vector3d.XAxis, 10.0)
                circle.ColorIndex = 30
                Dim modelSpace As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
                modelSpace.AppendEntity(circle)
                tr.AddNewlyCreatedDBObject(circle, True)
                tr.Commit()
            End Using
        End Sub
    End Class

End Namespace&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 12:47:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438516#M6292</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-13T12:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438723#M6293</link>
      <description>&lt;P&gt;Did you try to close the file after saving it and re-open it?&lt;/P&gt;
&lt;P&gt;Or, force the newly created circle drawing.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;        Private Shared Sub DoItBeforeSave(ByVal db As Database)
            Using tr = New OpenCloseTransaction()
                Dim circle As New Circle(Point3d.Origin, Vector3d.ZAxis, 10.0)
                circle.ColorIndex = 30
                Dim modelSpace As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
                modelSpace.AppendEntity(circle)
                tr.AddNewlyCreatedDBObject(circle, True)
                circle.Draw()
                tr.Commit()
            End Using
        End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 14:06:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438723#M6293</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-13T14:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438801#M6294</link>
      <description>&lt;P&gt;I tried with a VB project in Visual Studio (you can brag about getting me to write VB).&lt;/P&gt;
&lt;P&gt;It works as expected.&lt;/P&gt;
&lt;P&gt;Here's the code:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime

Public Class Initialization
    Implements IExtensionApplication

    Public Sub Initialize() Implements IExtensionApplication.Initialize
        Dim docs = Application.DocumentManager
        AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
        For Each doc As Document In docs
            AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
        Next
    End Sub

    Public Sub Terminate() Implements IExtensionApplication.Terminate
    End Sub

    Private Sub OnDocumentCreated(sender As Object, e As DocumentCollectionEventArgs)
        AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
    End Sub

    Private Sub OnBeginSave(sender As Object, e As DatabaseIOEventArgs)
        Dim db As Database = CType(sender, Database)
        DoItBeforeSave(db)
    End Sub

    Private Shared Sub DoItBeforeSave(db As Database)
        Using tr = New OpenCloseTransaction()
            Dim circle As New Circle() With {
                .Center = Point3d.Origin,
                .Radius = 10.0,
                .ColorIndex = 30
            }
            Dim modelSpace As BlockTableRecord = CType(tr.GetObject(
                SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
            modelSpace.AppendEntity(circle)
            tr.AddNewlyCreatedDBObject(circle, True)
            circle.Draw()
            tr.Commit()
        End Using
    End Sub
End Class&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 14:32:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438801#M6294</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-13T14:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438822#M6295</link>
      <description>&lt;P&gt;I've implemented the new code, opened a new file and saved it.&amp;nbsp; Closed the file and ran save again.&amp;nbsp; Nothing happens.&amp;nbsp; How do&amp;nbsp; I force it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Imports System.Windows.Controls
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime

Namespace BeginSaveHandlingSample
    Public Class Initialization
        Implements IExtensionApplication

        Public Sub Initialize() Implements IExtensionApplication.Initialize
            Dim docs = Application.DocumentManager
            AddHandler docs.DocumentCreated, AddressOf OnDocumentCreated
            For Each doc As Document In docs
                AddHandler doc.Database.BeginSave, AddressOf OnBeginSave
            Next
        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate
        End Sub

        Private Sub OnDocumentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
            AddHandler e.Document.Database.BeginSave, AddressOf OnBeginSave
        End Sub

        Private Sub OnBeginSave(ByVal sender As Object, ByVal e As DatabaseIOEventArgs)
            Dim db As Database = CType(sender, Database)
            DoItBeforeSave(db)
        End Sub

        Private Shared Sub DoItBeforeSave(ByVal db As Database)
            Using tr = New OpenCloseTransaction()
                Dim circle As New Circle(Point3d.Origin, Vector3d.ZAxis, 10.0)
                circle.ColorIndex = 30
                Dim modelSpace As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
                modelSpace.AppendEntity(circle)
                tr.AddNewlyCreatedDBObject(circle, True)
                circle.Draw()
                tr.Commit()
            End Using
        End Sub
    End Class

End Namespace&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 14:39:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438822#M6295</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-13T14:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438987#M6296</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;" (you can brag about getting me to write VB)."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;You're a gentlemen and a scholar and I can't thank you enough for the help!&amp;nbsp; I am indeed already bragging about it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 15:42:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438987#M6296</guid>
      <dc:creator>WPerciful</dc:creator>
      <dc:date>2023-12-13T15:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: SaveEventHandler not working</title>
      <link>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438996#M6297</link>
      <description>&lt;P&gt;After you save the file, you should see an orange circle of radius equal to 10 and center at origin (0, 0).&lt;/P&gt;
&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6342967688112w772h540r46" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6342967688112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6342967688112w772h540r46');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6342967688112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 15:45:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/saveeventhandler-not-working/m-p/12438996#M6297</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-13T15:45:07Z</dc:date>
    </item>
  </channel>
</rss>

