<?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: Revit 2025 and Visual Studio Code DocumentOpened event in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13092101#M2492</link>
    <description>&lt;P&gt;Thank you both for your input it's really appreciated.&lt;BR /&gt;Jeremy, I fully intend on running through C# tutorials and or undertake a course to get the fundamentals down.&lt;BR /&gt;This query was for migration of an existing simple macro to C# as we're moving to Revit 2025&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2024 22:14:45 GMT</pubDate>
    <dc:creator>Eduardo.SaezDRTV4</dc:creator>
    <dc:date>2024-10-17T22:14:45Z</dc:date>
    <item>
      <title>Revit 2025 and Visual Studio Code DocumentOpened event</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090024#M2489</link>
      <description>&lt;P&gt;I'm very green with C# and am testing some code but am encountering an error when building the solution, I have a variant of this code running under Revit 2022.&lt;BR /&gt;The error I'm getting is&lt;BR /&gt;C:\ProgramData\Autodesk\Revit\Macros\2025\Revit\AppHookup\Project_FilePath\Source\Project_FilePath\&lt;BR /&gt;ThisApplication.cs(36,5): error CS0127: Since 'ThisApplication.DocumentOpenedHandler(object?, Docum&lt;BR /&gt;entOpenedEventArgs)' returns void, a return keyword must not be followed by an object expression [C&lt;BR /&gt;:\ProgramData\Autodesk\Revit\Macros\2025\Revit\AppHookup\Project_FilePath\Source\Project_FilePath\P&lt;BR /&gt;roject_FilePath.csproj]&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI.Selection;

namespace Project_FilePath
{
   [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
   [Autodesk.Revit.DB.Macros.AddInId("2F4ED035-9D44-4043-B837-7844A9AA861E")]
   public partial class ThisApplication
   {
      private void Module_Startup(object? sender, EventArgs e)
      {
			// Subscribe to the DocumentOpened event
			Application.DocumentOpened += new EventHandler&amp;lt;DocumentOpenedEventArgs&amp;gt;(DocumentOpenedHandler);
		}

      private void Module_Shutdown(object? sender, EventArgs e)
      {
			// Unsubscribe to the DocumentOpened event
			Application.DocumentOpened -= new EventHandler&amp;lt;DocumentOpenedEventArgs&amp;gt;(DocumentOpenedHandler);

		}

      public void DocumentOpenedHandler(object? sender, DocumentOpenedEventArgs e)
		{
			if (e.Status == RevitAPIEventStatus.Succeeded)
			{
			try{
				// Display a message box when a document is opened
				TaskDialog.Show("Test Macro","Revit File Opened");
			}
			catch (Exception) {
				TaskDialog.Show("Error","There was a problem opening the document");

				return Result.Succeeded;
			}
			
			}
		}
   }
}&lt;/LI-CODE&gt;&lt;P&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 05:55:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090024#M2489</guid>
      <dc:creator>Eduardo.SaezDRTV4</dc:creator>
      <dc:date>2024-10-17T05:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2025 and Visual Studio Code DocumentOpened event</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090271#M2490</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10736912"&gt;@Eduardo.SaezDRTV4&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the error you're seeing is due to a return statement in a method that is declared to return &lt;CODE&gt;void&lt;/CODE&gt;.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;public void DocumentOpenedHandler(object? sender, DocumentOpenedEventArgs e)
{
    if (e.Status == RevitAPIEventStatus.Succeeded)
    {
        try
        {
            // Display a message box when a document is opened
            TaskDialog.Show("Test Macro", "Revit File Opened");
        }
        catch (Exception)
        {
            TaskDialog.Show("Error", "There was a problem opening the document");
            // No return is needed since the method is void
        }
    }
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Oct 2024 07:48:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090271#M2490</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2024-10-17T07:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2025 and Visual Studio Code DocumentOpened event</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090280#M2491</link>
      <description>&lt;P&gt;Welcome to C# and the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, the error message says exactly what the problem is. If I pare it down and reformulate it a bit, it says, "your method&amp;nbsp;&lt;SPAN&gt;DocumentOpenedHandler is a void function, so the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;return keyword must &lt;U&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/U&gt; be followed by an object expression&lt;/SPAN&gt;". In other words, you cannot write &lt;CODE&gt;return Result.Succeeded;&lt;/CODE&gt;; you have to leave out the &lt;CODE&gt;Result.Succeeded&lt;/CODE&gt; and write just &lt;CODE&gt;return;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I would also suggest that if you are running into issues like this, it might make sense to play around a bit more with just pure C# in tutorials or online courses before starting to address things in the Revit API, where you will be confronted and confused by the combination of Revit API quirks and C# issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This forum is (mostly) dedicated to discussing the Revit API, and not C# beginner issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and have fun!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 07:55:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13090280#M2491</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-10-17T07:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2025 and Visual Studio Code DocumentOpened event</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13092101#M2492</link>
      <description>&lt;P&gt;Thank you both for your input it's really appreciated.&lt;BR /&gt;Jeremy, I fully intend on running through C# tutorials and or undertake a course to get the fundamentals down.&lt;BR /&gt;This query was for migration of an existing simple macro to C# as we're moving to Revit 2025&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 22:14:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13092101#M2492</guid>
      <dc:creator>Eduardo.SaezDRTV4</dc:creator>
      <dc:date>2024-10-17T22:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2025 and Visual Studio Code DocumentOpened event</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13092800#M2493</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10736912"&gt;@Eduardo.SaezDRTV4&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Small suggestion from my side Before diving in the Revit API kindly refer the below starter kit link for the Revit API to understand the basics concepts of the Revit API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2022/02/getting-started-once-again.html" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2022/02/getting-started-once-again.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will Helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 07:30:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2025-and-visual-studio-code-documentopened-event/m-p/13092800#M2493</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2024-10-18T07:30:30Z</dc:date>
    </item>
  </channel>
</rss>

