<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Eric Brusky</title>
    <description>The latest articles on DEV Community by Eric Brusky (@watchitgo333).</description>
    <link>https://dev.to/watchitgo333</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F852317%2Fe6a62765-6a55-4931-94a4-b6bf136bea29.jpg</url>
      <title>DEV Community: Eric Brusky</title>
      <link>https://dev.to/watchitgo333</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/watchitgo333"/>
    <language>en</language>
    <item>
      <title>Website from Scratch or Wordpress?</title>
      <dc:creator>Eric Brusky</dc:creator>
      <pubDate>Wed, 22 Feb 2023 14:34:34 +0000</pubDate>
      <link>https://dev.to/watchitgo333/website-from-scratch-or-wordpress-2lkf</link>
      <guid>https://dev.to/watchitgo333/website-from-scratch-or-wordpress-2lkf</guid>
      <description>&lt;p&gt;Hello everyone,&lt;br&gt;
Recently I have taken up a few freelance opportunities to build some websites. One is an e-commerce website for a friend to sell their personal art and the other is a static page for another friend to get there name on the web for their profession(an about and contact type of page). I am not planning on charging for the labor but I am going to charge for any cost such as hosting, dns or membership for any tool I use. I have built basic crud apps from ground zero before with MERN, Java and Python stacks. I want to give them the cheapest options in terms of price but I am unsure. I am wondering if it would be more costly for both clients(maybe not the static page) to do it from scratch over using something like Wordpress and Woocommerce. So readers, what do you guys think, is it more cost effective to use Wordpress over coding from square one? Keep in mind I do not plan on charging for any labor, I was just using this for experience purposes. Any input or guidance on this is greatly appreciated!&lt;/p&gt;

</description>
      <category>welcome</category>
    </item>
    <item>
      <title>The Notorious... "Starting a transaction from an external application running outside of API context is not allowed."</title>
      <dc:creator>Eric Brusky</dc:creator>
      <pubDate>Mon, 23 Jan 2023 17:44:47 +0000</pubDate>
      <link>https://dev.to/watchitgo333/the-notorious-starting-a-transaction-from-an-external-application-running-outside-of-api-context-is-not-allowed-53nh</link>
      <guid>https://dev.to/watchitgo333/the-notorious-starting-a-transaction-from-an-external-application-running-outside-of-api-context-is-not-allowed-53nh</guid>
      <description>&lt;p&gt;Image by &lt;a href="https://pixabay.com/users/irina_kukuts-1213707/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2762156" rel="noopener noreferrer"&gt;Irina&lt;/a&gt; from &lt;a href="https://pixabay.com//?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2762156" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Exception&lt;/li&gt;
&lt;li&gt;IExternalEventHandler&lt;/li&gt;
&lt;li&gt;IExternalCommand&lt;/li&gt;
&lt;li&gt;Event.Raise();&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;li&gt;Resources&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Exception &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Chances are if you have tried to create a modeless dialog in Revit without the proper knowledge of &lt;a href="https://www.revitapidocs.com/2022/05089477-4612-35b2-81a2-89c4f44370ea.htm" rel="noopener noreferrer"&gt;ExternalEvent Class&lt;/a&gt; and the &lt;a href="https://www.revitapidocs.com/2022/f265a2c9-8540-9c97-9b37-4f7442becac2.htm" rel="noopener noreferrer"&gt;IExternalEventHandler Interface&lt;/a&gt; you may have run into this error, "Starting a transaction from an external application running outside of API context is not allowed." Now, this message is pretty self explanatory but sometimes in the heat of the moment messages such as these can feel extremely confusing. When creating a modeless WPF window or form we are technically not even in the Revit context and in order to "jump back in" so to speak we have raise an event. I have found that so far anything Transaction based must be done within the Revit API context. In order to preform two of the basic CRUD operations (Create and Update) with Revit's DB we must open a transaction. For my scenario I have been trying to create new family instances in a Revit model(I am using Revit 2022 btw). I first ran into this error when I tried opening and committing a transaction in my xaml.cs code behind. Within this code I was not raising an external event to let Revit know I am trying to operate back in the API context.&lt;/p&gt;

&lt;p&gt;So I create a class that implements the &lt;/p&gt;

&lt;h2&gt;
  
  
  IExternalEventHandler interface &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyEventHandler&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IExternalEventHandler&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ExternalEvent&lt;/span&gt; &lt;span class="nx"&gt;HandlerEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;MyEventHandler&lt;/span&gt; &lt;span class="nx"&gt;Handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nc"&gt;Execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;UIApplication&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Document&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ActiveUIDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;//notifying me of raised event&lt;/span&gt;
            &lt;span class="nx"&gt;Trace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Raised&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nf"&gt;using &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Transaction&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//within this transaction and event handler execute code block &lt;/span&gt;
&lt;span class="c1"&gt;//is where the interaction with Revit is done.&lt;/span&gt;
                    &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Commit&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
             &lt;span class="p"&gt;}&lt;/span&gt;
             &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;//catch whatever exception&lt;/span&gt;
                &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
             &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;InvalidOperationException&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="k"&gt;throw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="nc"&gt;GetName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My Event Handler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nc"&gt;GetData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MechEq&lt;/span&gt; &lt;span class="nx"&gt;mechEq&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mechEq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then in my other class that inherits the IExternalCommand interface, the event and the handler is passed into the MainWindow class of my wpf.&lt;/p&gt;

&lt;h2&gt;
  
  
  IExternalCommand interface &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IExternalCommand&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;Result&lt;/span&gt; &lt;span class="nc"&gt;Execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ExternalCommandData&lt;/span&gt; &lt;span class="nx"&gt;commandData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ElementSet&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;UIDocument&lt;/span&gt; &lt;span class="nx"&gt;uidoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;commandData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ActiveUIDocument&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;Document&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;uidoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;MyEventHandler&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyEventHandler&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nx"&gt;ExternalEvent&lt;/span&gt; &lt;span class="nx"&gt;exEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ExternalEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;MainWindow&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MainWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uidoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;exEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Succeeded&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Exception&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then lastly in my MainWindow, in one of my button events I have my external event being raised.&lt;/p&gt;

&lt;h1&gt;
  
  
  Event.Raise(); &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;MainWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;UIDocument&lt;/span&gt; &lt;span class="nx"&gt;UiDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ExternalEvent&lt;/span&gt; &lt;span class="nx"&gt;exEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MyEventHandler&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;uidoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;UiDoc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;UiDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;InitializeComponent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;m_exEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;exEvent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;myEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;btnImport_Click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RoutedEventArgs&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//raise event to trigger the execute method in MyEventHandler&lt;/span&gt;
    &lt;span class="nx"&gt;m_exEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Raise&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final thoughts &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This is a topic that has been covered in much detail by the Revit community. Jeremy Tammik has several examples covered in such detail on his website &lt;a href="https://thebuildingcoder.typepad.com/" rel="noopener noreferrer"&gt;the building coder&lt;/a&gt; and you can search modeless dialogs in the search bar. The way I found some examples was simply by googling how to make modeless windows in Revit. There are tons of resources and a lot can be found just by googling, searching other peoples code, and the Autodesk Revit API forums. The funny thing is I was trying to understand this before I got the error and was having trouble grasping the concept. My plugin was working just fine but I was not making any transactions yet. Finally once I got to the point in making a transaction, I received the error and it made much more sense on what needed to be done once I received the exception. Anyways, keep truckin and cheers!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Whatever you do, do not create another forum post on the revit api forum with out doing some thorough research on this subject first!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://forums.autodesk.com/t5/revit-api-forum/bd-p/160" rel="noopener noreferrer"&gt;Revit API forum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.autodesk.com/developer-network/platform-technologies/revit" rel="noopener noreferrer"&gt;Autodesk Developer Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jeremytammik/RevitSdkSamples" rel="noopener noreferrer"&gt;Revit SDK Samples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>community</category>
      <category>productivity</category>
    </item>
    <item>
      <title>First experience with EPPlus and WPF</title>
      <dc:creator>Eric Brusky</dc:creator>
      <pubDate>Thu, 12 Jan 2023 15:27:10 +0000</pubDate>
      <link>https://dev.to/watchitgo333/first-experience-with-epplus-and-wpf-2l34</link>
      <guid>https://dev.to/watchitgo333/first-experience-with-epplus-and-wpf-2l34</guid>
      <description>&lt;p&gt;Hello everyone,&lt;br&gt;
Recently I have been trying to make a basic C# WPF app that will read from an Excel spreadsheet and display the info in a DataTable. I am about a year into programming at this point and I just started learning C# and WPF by YouTube videos, a udemy course and breaking my application. Anyways, I have been toying with various NuGet packages such as the ExcelDataReader(I used this &lt;a href="https://www.youtube.com/watch?v=5U2qf52PTTY" rel="noopener noreferrer"&gt;tutorial by Fox Learn&lt;/a&gt;).&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/5U2qf52PTTY"&gt;
&lt;/iframe&gt;
I however did the tutorial with WPF instead of Forms, and with some struggle I had success with displaying the info in a DataTable. I have been trying to integrate this in a Revit plugin as a part of a bigger application. In Excel, one can display a sort of pulldown or combo box that includes more choices of data for a cell. I want to be able to replicate that in my window and I am just not sure how yet. So I went to my new friend ChatGPT and started asking it some questions about different NuGet packages for reading, writing, and creating Excel spreadsheets. I further researched and found most people liked EPPlus. So I have been using that, it is well documented and the tutorials are easy to follow. I ran into an issue, I was trying to store the worksheets in a method that returned the sheets and pass them around my application but I had kept receiving a NullReferenceException.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public ExcelWorksheets getSheets()
  {
    string fileName = txtFilename.Text;
    using (var package = new ExcelPackage(fileName))
      {
        ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
        ExcelWorksheets Sheets = package.Workbook.Worksheets;
        return Sheets;
    }
 }

ExcelWorksheets sheets = getSheets();
addSheetsToComboBox(sheets);

public void addSheetsToComboBox(ExcelWorksheets sheets)
    {
//NullReferenceException thrown here
      foreach(sheet in sheets)
        cboSheet.Items.Add(sheet)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This had me banging my head against wall for a good part of my day. I have since refactored this a bit to where I have the data displaying in the DataTable now and I am not getting the Exception. I ended up using the 'using()' statement wherever I needed, just to move on which actually ended up working pretty well in the end. Another issue was getting the cell data to display properly and dynamically in for the DataTable. Which is what I am still tinkering with now. I was receiving several errors when trying to get the data from the cells into the DataTable.&lt;br&gt;
See below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using (var package = new ExcelPackage(fileName))
  {
    ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
    Trace.WriteLine(cboSheet.SelectedIndex);
    ExcelWorksheet Sheet = 
    package.Workbook.Worksheets[cboSheet.SelectedIndex];
//I receive an InvalidOperationException from the below code, 'First row contains an empty cell at index 3'
    var cells = Sheet.Cells.ToDataTable();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This did not work, the package required me to use a specific range for the data table.&lt;br&gt;
Like below:&lt;br&gt;
&lt;code&gt;var cells = Sheet.Cells["A1:C2"].ToDataTable();&lt;/code&gt;&lt;br&gt;
This worked like a charm but, the issue is I am providing the option to select different sheets from the workbook. So if the above code is provided then I am out of luck and same if I choose another workbook. So I dynamically need a way to get the cells from each sheet to a DataTable. So I found a way to get all of the cells I need to a dictionary(via stackoverflow, which introduced me to LINQ).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var cells = Sheet.Cells;
var dict = cells
   .GroupBy(c =&amp;gt; new { c.Start.Row, c.Start.Column })
   .ToDictionary(
         rcg =&amp;gt; new KeyValuePair&amp;lt;int, int&amp;gt;(rcg.Key.Row, rcg.Key.Column),
         rcg =&amp;gt; cells[rcg.Key.Row, rcg.Key.Column].Value);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I needed a way to get the dictionary to a DataTable(via stackoverflow, which introduced the different methods for creating a new DataTable).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DataTable dt = new DataTable();
dt.Columns.Add("Key", typeof(int));
dt.Columns.Add("Val", typeof(int));
dt.Columns.Add("Obj", typeof(string));
foreach (var item in dict)
  {
    DataRow dr = dt.NewRow();
    dr["Key"] = item.Key.Key;
    dr["Val"] = item.Key.Value;
    dr["Obj"] = item.Value;
    dt.Rows.Add(dr);
 }                  

dataGrid1.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = dt });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This has been both frustrating and loads of fun. I am learning a lot. The code feels like a bit of a mess which is something else I would like to fix as well. As I was writing this, I started wondering about the possibilities on how this could be done better. Anyways, if you read through this comments or feedback is always appreciated!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>The Journey thus far...</title>
      <dc:creator>Eric Brusky</dc:creator>
      <pubDate>Tue, 19 Jul 2022 15:04:36 +0000</pubDate>
      <link>https://dev.to/watchitgo333/the-journey-thus-far-46m8</link>
      <guid>https://dev.to/watchitgo333/the-journey-thus-far-46m8</guid>
      <description>&lt;p&gt;Ask me 10 years ago if I'd be writing a blog post on a developer website, and I would have probably wanted some of what you were smoking cause it sounds really good. What is my point? Well life is a journey full of smaller journeys, and last fall (2021) I embarked on an adventure to learn computer programming. It began with a intro to computer science course that sparked my interest. As a result, I joined a bootcamp. I hear plenty of controversy on bootcamps and I honestly couldn't tell you if it was a better option than sticking out 2 to 3 more years of college or learning on my own. Once I weighed out my options, I made the decision to go the bootcamp route. I started my bootcamp in February of this year and I am set to complete in October. We are currently learning React. So far, I have been loving my decision and I have learned so much. I have built full stack web applications through both python and java. I even had the opportunity to participate in a Chainlink hackathon.&lt;/p&gt;

&lt;p&gt;Though there have been successes, there have also been plenty of struggles. I experience tons of doubt in myself and sometimes believe I am not capable of any of this. I experienced a lot of fear on whether or not this was a good decision for me and frustration when I can't figure something out or grasp a concept. One of my biggest weaknesses is asking for help from my peers and the community. I understand how important it is to ask for help in this field and it is something I need to work on. Lately, I have been struggling staying proactive and consistent with learning new material.&lt;/p&gt;

&lt;p&gt;I write this post because It has been on my heart for some time, I had never written a blog post before and I thought I would try something new. Also, I wanted to reach out to the community to say hello I am here, I exist, I am human. I am over joyed to be apart of this community. If you're reading this and you feel some of the same things I have, I hope you continue to press on in your own journey with software development I am rooting for you!&lt;/p&gt;

&lt;p&gt;The meme above describes how I feel most of the time. I either feel overzealous about solving a problem or like a complete idiot for not understanding something. I love it though, I'm grateful to have finally found my passion. Recently, I have been trying to wrap my head around useReducer in React. I read something for my bootcamp about it yesterday and had no idea what I just read. I have found though, that just trying stuff in my code and getting my hands dirty is where I learn the most, especially when It breaks!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
