<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[summon idea]]></title><description><![CDATA[Tech ideas for the AEC industry]]></description><link>https://www.summonidea.com/</link><image><url>https://www.summonidea.com/favicon.png</url><title>summon idea</title><link>https://www.summonidea.com/</link></image><generator>Ghost 3.42</generator><lastBuildDate>Tue, 31 Mar 2026 13:41:21 GMT</lastBuildDate><atom:link href="https://www.summonidea.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Export a json file from a MongoDB Collection]]></title><description><![CDATA[Using node.js and the mongoose package to read a MongoDB atlas collection and export it to a json file]]></description><link>https://www.summonidea.com/export-a-json-file-from-a-mongodb-collection/</link><guid isPermaLink="false">62731f26f7ad07586aae7e7b</guid><category><![CDATA[nodejs]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Thu, 05 May 2022 01:50:27 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1529078155058-5d716f45d604?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDUwfHxleHBvcnQlMjBkYXRhfGVufDB8fHx8MTY1MTcxNTY5MQ&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1529078155058-5d716f45d604?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDUwfHxleHBvcnQlMjBkYXRhfGVufDB8fHx8MTY1MTcxNTY5MQ&ixlib=rb-1.2.1&q=80&w=2000" alt="Export a json file from a MongoDB Collection"><p>IT did not authorized me to download MongoDB Compass fast enough, so I decided to use the tools available to export a collection. Node.js was authorized, installed and ready for the rescue.</p><p>I slightly modified a stackoverflow answer and I was in business really quick.</p><p>I put some effort into documenting the parts and pieces of the MongoDB string connection to be aware of the fields/variables that I need to update next time.</p><p>Check the repo out...</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/mongodb-export-to-json"><div class="kg-bookmark-content"><div class="kg-bookmark-title">GitHub - summonidea/mongodb-export-to-json: Using node.js and mongoose package to read a mongo atlas collection and export it to a json file</div><div class="kg-bookmark-description">Using node.js and mongoose package to read a mongo atlas collection and export it to a json file - GitHub - summonidea/mongodb-export-to-json: Using node.js and mongoose package to read a mongo atl...</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Export a json file from a MongoDB Collection"><span class="kg-bookmark-author">GitHub</span><span class="kg-bookmark-publisher">summonidea</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://opengraph.githubassets.com/4d622df1e2d0c328aa9cd8598fed8871db7045f04becd38ca5759dae6c8c2a3b/summonidea/mongodb-export-to-json" alt="Export a json file from a MongoDB Collection"></div></a></figure><p><strong>Reference</strong></p><!--kg-card-begin: markdown--><p><a href="http://">https://stackoverflow.com/questions/5794834/how-to-access-a-preexisting-collection-with-mongoose</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Summon Revit Family Browser]]></title><description><![CDATA[Batch Revit Family Exporter that feeds a Family web browser outside the Revit environment.]]></description><link>https://www.summonidea.com/summon-family-browser/</link><guid isPermaLink="false">611b4782fe730611f77b8cac</guid><category><![CDATA[dynamoBIM]]></category><category><![CDATA[html]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Tue, 17 Aug 2021 06:21:28 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2021/08/summonfamilybrowser.PNG" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2021/08/summonfamilybrowser.PNG" alt="Summon Revit Family Browser"><p>The following process has 2 parts: </p><ul><li>Export family data with DynamoBIM </li><li>Read exported family data from a Website</li></ul><p>First, a DynamoBIM script batch opens Revit families in a directory to export FBX models, 3D Views as images, and a JSON with parameter information.</p><p>Second, we used vanilla HTML and JavaScript to read all output coming from Revit and organize it in a web page. We made it as simple as possible without using any frameworks or servers. In fact, the site does not look very pretty for the same reason. <a href="https://summonidea.github.io/summon-family-browser/">Check out the website here.</a></p><!--kg-card-begin: html--><iframe src="https://gfycat.com/ifr/AssuredElasticGreathornedowl" frameborder="0" scrolling="no" allowfullscreen width="720" height="480"></iframe><!--kg-card-end: html--><p>There are many use cases for this. The main intention is to avoid opening Revit to review families. From this work, other ideas can derive such as, creating a family browser of the OOTB Revit content per release. Also, the same can apply to your company's family library. </p><p>The script, "<a href="https://github.com/summonidea/summon-family-browser/blob/master/dyn/ExtractFamilyDataFromDirectory.dyn">ExtractFamilyDataFromDirectory.dyn</a>" has been tested in Revit 2020 and DynamoBIM 2.3. There is one python node that does most of the heavy lifting to avoid custom packages. The main idea is to loop through a directory of families to batch open them and while opened perform a series of tasks in the family editor programmatically. Those series of tasks can be exporting alphanumeric or geometry data as well as adding new parameters to the family. </p><p>This experiment has not been tested extensively and you should used it with care and under your own risk. For instance, it may not work with 2D families. If all of that is fine with you, clone the repo below and have fun. </p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/summon-family-browser"><div class="kg-bookmark-content"><div class="kg-bookmark-title">GitHub - summonidea/summon-family-browser</div><div class="kg-bookmark-description">Contribute to summonidea/summon-family-browser development by creating an account on GitHub.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Summon Revit Family Browser"><span class="kg-bookmark-author">GitHub</span><span class="kg-bookmark-publisher">summonidea</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://opengraph.githubassets.com/95b01b75a03a0477ee390cbe99e486a344d77d90312aad130dcca4a0ad6df778/summonidea/summon-family-browser" alt="Summon Revit Family Browser"></div></a></figure><p>Notes: Delete the content under the "output_families" folder and feel free to add new family files to the "input_families" folder. Also, in Dynamo, directory paths will need to be updated to be in the context of your local machine. Finally, use VSCode to run "index.html" via <a href="https://www.freecodecamp.org/news/vscode-live-server-auto-refresh-browser/">Open with live Server</a>.</p>]]></content:encoded></item><item><title><![CDATA[Revit: Dimension Pipes to Grid lines using DynamoBIM]]></title><description><![CDATA[Dimensions Pipes to closest Grid Lines using DynamoBIM]]></description><link>https://www.summonidea.com/revit-dimension-pipes-to-grid-using-dynamobim/</link><guid isPermaLink="false">60a4a997fe730611f77b8c1c</guid><category><![CDATA[dynamoBIM]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Wed, 19 May 2021 07:15:51 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2021/05/summon_DimensionPipeToClosestGridLines_Sample.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2021/05/summon_DimensionPipeToClosestGridLines_Sample.png" alt="Revit: Dimension Pipes to Grid lines using DynamoBIM"><p>Design coordination requires high efficacy at problem solving, modeling, and communications. Turnaround times are short and constrained. One example is delivering slab penetrations before pouring the next level. In the following post, we will share a DynamoBIM script to dimension Plumbing Raisers (Pipes) to the closest 2 grid lines in the 2d view.</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2021/05/summon_DimensionPipeToClosestGridLines.png" class="kg-image" alt="Revit: Dimension Pipes to Grid lines using DynamoBIM" srcset="https://www.summonidea.com/content/images/size/w600/2021/05/summon_DimensionPipeToClosestGridLines.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/05/summon_DimensionPipeToClosestGridLines.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/05/summon_DimensionPipeToClosestGridLines.png 1600w, https://www.summonidea.com/content/images/size/w2400/2021/05/summon_DimensionPipeToClosestGridLines.png 2400w" sizes="(min-width: 720px) 720px"></figure><p>As you can tell from the image above, the script is small. The strategy was to:</p><ul><li>Select model elements of desired category, pipes, in this case. Then, find the X, Y location of the model elements filtered.</li><li>Find the points of intersection formed by the grid lines itself to calculate the closest intersection to each model element (Pipe).</li><li> Pair each model element with the two closest grid lines. Points of intersection help to map the two grid lines that make up for the intersection.</li></ul><p>Download the script and sample Revit file from the Github repository.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/dimension-pipe-to-closest-grid-lines"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/dimension-pipe-to-closest-grid-lines</div><div class="kg-bookmark-description">Dimensions Pipes to Grid lines using DynamoBIM. Contribute to summonidea/dimension-pipe-to-closest-grid-lines development by creating an account on GitHub.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Revit: Dimension Pipes to Grid lines using DynamoBIM"><span class="kg-bookmark-author">GitHub</span><span class="kg-bookmark-publisher">summonidea</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://opengraph.githubassets.com/6a4f0d43c34e3e917d68629ca5d0127616e70384b41fe5aef6728d3ea76e4691/summonidea/dimension-pipe-to-closest-grid-lines" alt="Revit: Dimension Pipes to Grid lines using DynamoBIM"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Create Spot Elevations on Revit Pipes using DynamoBIM]]></title><description><![CDATA[Create spot elevations at the highest point of pipe]]></description><link>https://www.summonidea.com/create-spot-elevations-on-revit-pipes/</link><guid isPermaLink="false">608104b71638673eca650263</guid><category><![CDATA[dynamoBIM]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Thu, 22 Apr 2021 05:30:21 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1543674892-7d64d45df18b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDMyfHxwaXBlfGVufDB8fHx8MTYxOTA2ODEyNw&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1543674892-7d64d45df18b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDMyfHxwaXBlfGVufDB8fHx8MTYxOTA2ODEyNw&ixlib=rb-1.2.1&q=80&w=2000" alt="Create Spot Elevations on Revit Pipes using DynamoBIM"><p>This script creates spot elevations on pipes using DynamoBIM. First, it collects all pipes from the active view and place a spot elevation at the highest point of the pipe. The location of dimension text is relative to the point. Clockwork package is used to get curves from pipes and create the spot elevation.</p><figure class="kg-card kg-image-card kg-width-full"><img src="https://www.summonidea.com/content/images/2021/04/AddSpotElevationOnPipe.png" class="kg-image" alt="Create Spot Elevations on Revit Pipes using DynamoBIM" srcset="https://www.summonidea.com/content/images/size/w600/2021/04/AddSpotElevationOnPipe.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/04/AddSpotElevationOnPipe.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/04/AddSpotElevationOnPipe.png 1600w, https://www.summonidea.com/content/images/size/w2400/2021/04/AddSpotElevationOnPipe.png 2400w"></figure><p>Clone the repository below to download DynamoBIM script.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/create-spot-elevation-on-pipe"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/create-spot-elevation-on-pipe</div><div class="kg-bookmark-description">Create spot elevation at the highest point of pipes - summonidea/create-spot-elevation-on-pipe</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Create Spot Elevations on Revit Pipes using DynamoBIM"><span class="kg-bookmark-author">GitHub</span><span class="kg-bookmark-publisher">summonidea</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://opengraph.githubassets.com/2e9e19151d29c7e9c0054d56ca48560031a5d703dc29cb269afb8377b2177959/summonidea/create-spot-elevation-on-pipe" alt="Create Spot Elevations on Revit Pipes using DynamoBIM"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Controlled Rotational randomness]]></title><description><![CDATA[placing rotated rectangles on an i by j grid]]></description><link>https://www.summonidea.com/controlled-rotational-randomness/</link><guid isPermaLink="false">6049abaa1638673eca650236</guid><category><![CDATA[P5.js]]></category><category><![CDATA[Processing]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Thu, 11 Mar 2021 05:39:04 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2021/03/summonidea_sketch0-2.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2021/03/summonidea_sketch0-2.png" alt="Controlled Rotational randomness"><p>Just a little experiment placing rotated rectangles on an i by j grid. Rotation and color of the rectangle fill is influenced to the location (i, j) on the grid.</p><p>Code available in the link below. Enjoy!</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://editor.p5js.org/summonidea/sketches/K1RTvJ0KR"><div class="kg-bookmark-content"><div class="kg-bookmark-title">p5.js Web Editor</div><div class="kg-bookmark-description">A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://raw.githubusercontent.com/processing/p5.js-website-OLD/master/favicon.ico" alt="Controlled Rotational randomness"></div></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Tri-secting angle between two vectors]]></title><description><![CDATA[Trisecting angle between two vectors]]></description><link>https://www.summonidea.com/tri-secting-angle-between-two-vectors/</link><guid isPermaLink="false">603756fb1638673eca650205</guid><category><![CDATA[P5.js]]></category><category><![CDATA[creative-coding]]></category><category><![CDATA[vectors]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Thu, 25 Feb 2021 08:10:53 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1473014294925-f0aebcb8e6da?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MXwxMTc3M3wwfDF8c2VhcmNofDZ8fGFuZ2xlfGVufDB8fHw&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1473014294925-f0aebcb8e6da?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxMTc3M3wwfDF8c2VhcmNofDZ8fGFuZ2xlfGVufDB8fHw&ixlib=rb-1.2.1&q=80&w=2000" alt="Tri-secting angle between two vectors"><p>Coding a little portion of a corner case on mesh generation algorithm.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://editor.p5js.org/summonidea/sketches/NDSlvXBGI"><div class="kg-bookmark-content"><div class="kg-bookmark-title">p5.js Web Editor</div><div class="kg-bookmark-description">A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://raw.githubusercontent.com/processing/p5.js-website-OLD/master/favicon.ico" alt="Tri-secting angle between two vectors"></div></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Calculating the signed angle between two vectors]]></title><description><![CDATA[Using the cross product to determine the signed angle between two vectors. ]]></description><link>https://www.summonidea.com/signed-angle-between-two-vectors/</link><guid isPermaLink="false">60180161e3710c0470246288</guid><category><![CDATA[P5.js]]></category><category><![CDATA[vectors]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Wed, 03 Feb 2021 04:36:02 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1525011268546-bf3f9b007f6a?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MXwxMTc3M3wwfDF8c2VhcmNofDF8fGFycm93fGVufDB8fHw&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1525011268546-bf3f9b007f6a?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxMTc3M3wwfDF8c2VhcmNofDF8fGFycm93fGVufDB8fHw&ixlib=rb-1.2.1&q=80&w=2000" alt="Calculating the signed angle between two vectors"><p>The most common answer in the internet refers to the calculation of the acute angle between two vectors using the formula below:</p><p>\( \cos \theta=  \dfrac{u \centerdot v}{\text{\textbardbl}u\text{\textbardbl} \text{\textbardbl}v\text{\textbardbl}}\)</p><p>This calculation does not provide with the sign of the angle between two vectors. For instance, you could be interested in calculating the angle measured only in the clockwise direction. Also, this can be adapted to get the angle from 0 to 360 degrees. </p><!--kg-card-begin: html--><iframe src="https://editor.p5js.org/summonidea/embed/QfjMQaJoe"></iframe><!--kg-card-end: html--><p>Play with the code here:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://editor.p5js.org/summonidea/sketches/QfjMQaJoe"><div class="kg-bookmark-content"><div class="kg-bookmark-title">p5.js Web Editor</div><div class="kg-bookmark-description">A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://raw.githubusercontent.com/processing/p5.js-website-OLD/master/favicon.ico" alt="Calculating the signed angle between two vectors"></div></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Linear Equation]]></title><description><![CDATA[Drawing a line from 2 points and generating the linear equation.]]></description><link>https://www.summonidea.com/linear-equation/</link><guid isPermaLink="false">5ffc7a5a1339a05a6f94c6f1</guid><category><![CDATA[P5.js]]></category><category><![CDATA[creative-coding]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Mon, 11 Jan 2021 16:31:58 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1536121669036-cb96c328d389?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MXwxMTc3M3wwfDF8c2VhcmNofDI4fHxsaW5lfGVufDB8fHw&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1536121669036-cb96c328d389?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxMTc3M3wwfDF8c2VhcmNofDI4fHxsaW5lfGVufDB8fHw&ixlib=rb-1.2.1&q=80&w=2000" alt="Linear Equation"><p>This is a little P5.js drawing that generates a linear equation from 2 known points. The sliders at the bottom modify the X and Y values for each point. A line is formed between the 2 points. The linear equation is available in the top left corner of the canvas.</p><p>Spoiler alert: It does not work when X1 == X2 because we cannot divide by zero when calculating the slope, m.</p><!--kg-card-begin: html--><div>
<span style="width:100%; height:500px">
<iframe src="https://editor.p5js.org/summonidea/embed/_M3ACeqNG"></iframe>
</span>
</div><!--kg-card-end: html--><p>Click on the link below and try the code yourself.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://editor.p5js.org/summonidea/sketches/_M3ACeqNG"><div class="kg-bookmark-content"><div class="kg-bookmark-title">p5.js Web Editor</div><div class="kg-bookmark-description">A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://raw.githubusercontent.com/processing/p5.js-website-OLD/master/favicon.ico" alt="Linear Equation"></div></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Bi(Dyn)nomial Distribution]]></title><description><![CDATA[Modeling binomial distributions and giving Dynamo a hard time.]]></description><link>https://www.summonidea.com/bi-dyn-nomial-distribution/</link><guid isPermaLink="false">5ffbeb861339a05a6f94c6d4</guid><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Mon, 11 Jan 2021 06:12:52 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2021/01/geogebra-export-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2021/01/geogebra-export-1.png" alt="Bi(Dyn)nomial Distribution"><p>Problem statement: <em>2 out of 5 times I run a complex Dynamo graph, the program crashes.</em></p><!--kg-card-begin: markdown--><blockquote>
<p><strong>The probability of getting exactly k successes in n independent Bernoulli trials</strong> is given by the probability mass function:</p>
</blockquote>
<!--kg-card-end: markdown--><p>\( P(x) = \begin{pmatrix} n\\ x \end{pmatrix} p^xq^{n-x}\\ P(x) = binomial\ probability\\ x = number\ of\ times\ for\ a\ specific\ outcome\\ n = number\ of\ trials\\ p = probability\ of\ success\ on\ a\ single\ trial\\ q = probability\ of\ failure\ on\ a\ single\ trial\\ \)</p><p><strong>What is the probability of crashing the program twice in the next 3 runs?</strong></p><p>\( P(X=2) =  \begin{pmatrix} 3\\ 2 \end{pmatrix} 0.4^2 {(0.6)}^{3-2} = 0.288 = 28.8\% \)</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2021/01/image-4.png" class="kg-image" alt="Bi(Dyn)nomial Distribution" srcset="https://www.summonidea.com/content/images/size/w600/2021/01/image-4.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/01/image-4.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/01/image-4.png 1600w, https://www.summonidea.com/content/images/2021/01/image-4.png 2007w" sizes="(min-width: 720px) 720px"></figure><p><strong>What is the probability of NOT crashing the program in the next 3 attempts?</strong></p><p>Come on! It's not a miracle. It's definitely more than that.</p><p>\( P(X=0) =  \begin{pmatrix} 3\\ 0 \end{pmatrix} 0.4^0 {(1-0.4)}^{3-0} = 0.216 = 21.6\% \) </p><p>It can also be interpreted as: probability of NOT crashing the program at any of the 3 trials</p><p>\( P(X=0) = 0.6 * 0.6 * 0.6 = 0.216 = 21.6\% \)</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2021/01/geogebra-export.png" class="kg-image" alt="Bi(Dyn)nomial Distribution" srcset="https://www.summonidea.com/content/images/size/w600/2021/01/geogebra-export.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/01/geogebra-export.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/01/geogebra-export.png 1600w, https://www.summonidea.com/content/images/size/w2400/2021/01/geogebra-export.png 2400w" sizes="(min-width: 720px) 720px"></figure><p><strong>What is the probability of crashing the program at least once in the next 3 runs?</strong></p><p>It could be seen as the probability of crashing the program 1, 2 OR 3 times.</p><p>\( P(X=1) =  \begin{pmatrix} 3\\ 1 \end{pmatrix} 0.4^1 {(0.6)}^{3-1} = 0.432 = 43.2\% \) </p><p>\( P(X=2) =  \begin{pmatrix} 3\\ 2 \end{pmatrix} 0.4^2 {(0.6)}^{3-2} = 0.288 = 28.8\% \) </p><p>\( P(X=3) =  \begin{pmatrix} 3\\ 3 \end{pmatrix} 0.4^3 {(0.6)}^{3-3} = 0.064 = 6.4\% \) </p><p>And, add them up:</p><p>\( P(X\ge1) = 0.432 + 0.288 + 0.064 = 0.784 = 78.4\% \)</p><p>Also, more elegantly, it can be interpreted as: 1 minus the probability of NOT crashing the program at any of the 3 trials. Trial 1: does not crash, Trial 2: does not crash Trial 3: does not crash.</p><p>\( P(X\ge1) = 1 - (0.6 * 0.6 * 0.6) = 1 - 0.216 = 0.784 = 78.4\% \)</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2021/01/image-2.png" class="kg-image" alt="Bi(Dyn)nomial Distribution" srcset="https://www.summonidea.com/content/images/size/w600/2021/01/image-2.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/01/image-2.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/01/image-2.png 1600w, https://www.summonidea.com/content/images/2021/01/image-2.png 2007w" sizes="(min-width: 720px) 720px"></figure><p><strong>What is the probability of crashing the program at least twice in the next 3 runs?</strong></p><p>It is the probability of crashing 2 OR 3 times</p><p>\( P(X=2) =  \begin{pmatrix} 3\\ 2 \end{pmatrix} 0.4^2 {(0.6)}^{3-2} = 0.288 = 28.8\% \)</p><p>\( P(X=3) =  \begin{pmatrix} 3\\ 3 \end{pmatrix} 0.4^3 {(0.6)}^{3-3} = 0.064 = 6.4\% \) </p><p>Adding them up:</p><p>\( P(X\ge2) =  0.288 + 0.064 = 0.352 = 35.2\% \)</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2021/01/image-3.png" class="kg-image" alt="Bi(Dyn)nomial Distribution" srcset="https://www.summonidea.com/content/images/size/w600/2021/01/image-3.png 600w, https://www.summonidea.com/content/images/size/w1000/2021/01/image-3.png 1000w, https://www.summonidea.com/content/images/size/w1600/2021/01/image-3.png 1600w, https://www.summonidea.com/content/images/2021/01/image-3.png 2007w" sizes="(min-width: 720px) 720px"></figure><p>I found a very nice Binomial distribution calculator based on GeoGebra. Check the link below:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://www.geogebra.org/m/hMuamz5w"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Binomial Distribution Image Generator</div><div class="kg-bookmark-description">Binomial Distribution Image Generator</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://www.geogebra.org/favicon.ico" alt="Bi(Dyn)nomial Distribution"><span class="kg-bookmark-author">/u/michael+borcherds</span><span class="kg-bookmark-publisher">GeoGebra</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://www.geogebra.org/resource/EHw2czm5/zM8xPbBxZ5p3Bdsr/material-EHw2czm5-thumb@l.png" alt="Bi(Dyn)nomial Distribution"></div></a></figure><p>Adding KaTeX to a blog post:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://www.naut.ca/blog/2019/04/01/quickly-add-latex-math-rendering-to-a-ghost-blog/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Easily Add LaTex Math to a Ghost Blog</div><div class="kg-bookmark-description">This is a guide to get LaTex math to work on a Ghost Blog. I chose a fast JavaScript Library developed by Khan Academy called KaTex. To see it in action, check my previous blog post on P-NP. Here are the steps to get it working: Login to the Ghost</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://www.naut.ca/blog/2019/04/01/quickly-add-latex-math-rendering-to-a-ghost-blog/index.html" alt="Bi(Dyn)nomial Distribution"><span class="kg-bookmark-author">Yoonsik Park</span><span class="kg-bookmark-publisher">Yoon's Blog</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://www.naut.ca/blog/content/images/2019/03/ghostsettings-1.png" alt="Bi(Dyn)nomial Distribution"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Getting started with P5.js]]></title><description><![CDATA[How did I get started with Processing?]]></description><link>https://www.summonidea.com/getting-started-with-p5-js/</link><guid isPermaLink="false">5ff47d221339a05a6f94c4ab</guid><category><![CDATA[creative-coding]]></category><category><![CDATA[Processing]]></category><category><![CDATA[P5.js]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Tue, 05 Jan 2021 15:49:00 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1554188248-986adbb73be4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MXwxMTc3M3wwfDF8c2VhcmNofDZ8fGFydHxlbnwwfHx8&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1554188248-986adbb73be4?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxMTc3M3wwfDF8c2VhcmNofDZ8fGFydHxlbnwwfHx8&ixlib=rb-1.2.1&q=80&w=2000" alt="Getting started with P5.js"><p>I have been playing with <a href="https://www.summonidea.com/p/4ced4cb6-f10d-40f6-aca4-d8d8ef64622f/processing.org">Processing</a> and it is a lot of fun! There are a lot of resources and inspiration available if you search for creative coding or generative art. Most of the examples are made with Processing or its alternative for the web, <a href="https://www.summonidea.com/p/4ced4cb6-f10d-40f6-aca4-d8d8ef64622f/p5js.org">P5.js</a>.</p><p>I skimmed through Casey Reas and Ben Fry's book, <strong><a href="https://www.amazon.com/Processing-Programming-Handbook-Designers-Artists/dp/026202828X/ref=sr_1_6?s=books&amp;ie=UTF8&amp;qid=1406934187&amp;sr=1-6&amp;keywords=processing">Processing: A Programming Handbook for Visual Designers, Second Edition</a></strong>. I thought I bought it, but by mistake I actually ended up renting it out. So, I just returned it. This book helped me to understand the basic and advanced features of the software. Once I get an idea of what the possibilities are, I find it easier to create.</p><p>After playing with Processing for a short period of time, I wanted to start posting some outputs. Even-though it is possible to export outputs as images, videos or the application itself for Windows and Linux, I wanted it to be more web friendly. P5.js is an open-sourced JavaScript library for creative coding that is based on Processing and backed by the same community. This sketching library allows to play on your the browser.</p><p>Finally, I hope that I can share below the code and output by using Ghost's OBO snippets to embed content. (That was the entire reason to switch from Processing to P5 and I am about to test it)</p><p>Performance Note: Processing beats P5.js at rendering and keeping up with the frame rate</p><!--kg-card-begin: html-->
<div>
<span style="float:right; width:400px; height:400px">
<iframe src="https://editor.p5js.org/summonidea/embed/KvmiCyDVC"></iframe>
</span>
</div><!--kg-card-end: html--><pre><code class="language-javascript">var p = 0;

function setup() {
  createCanvas(400, 400);
  
}

function draw() {
  //background(220);
  //noFill();
  
  rect(0, 0, p * width, p * height);
  rect(p * width, p * height, (1 - 2 * p) * width, (1 - 2 * p) * height);
  rect(width - (p * width), height - (p * height), p * width, p * height);
  
  //p = p * 1.01;
  p = p + 0.01;
  if (p &gt; 1){
    p = 0;
  }
}</code></pre><p>Click the link below to try the code yourself </p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://editor.p5js.org/summonidea/sketches/KvmiCyDVC"><div class="kg-bookmark-content"><div class="kg-bookmark-title">p5.js Web Editor</div><div class="kg-bookmark-description">A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://raw.githubusercontent.com/processing/p5.js-website-OLD/master/favicon.ico" alt="Getting started with P5.js"></div></div></a></figure><p>This post saved me from getting disappointed: <a href="https://ghost-o-matic.com/iframes-side-by-side/">https://ghost-o-matic.com/iframes-side-by-side/</a></p>]]></content:encoded></item><item><title><![CDATA[Summon Raised Access Flooring]]></title><description><![CDATA[This is a DynamoBIM script that generates raised access flooring from a polygon. Inserts family instances in Revit for geometry representation.]]></description><link>https://www.summonidea.com/summon-raised-floors/</link><guid isPermaLink="false">5fb42d831339a05a6f94c403</guid><category><![CDATA[dynamoBIM]]></category><category><![CDATA[parametric]]></category><category><![CDATA[raised access flooring]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Wed, 18 Nov 2020 03:47:00 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2020/11/Raised-Access-Floor-revit.PNG" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2020/11/Raised-Access-Floor-revit.PNG" alt="Summon Raised Access Flooring"><p>This is a DynamoBIM script that generates raised access flooring from a polygon. The first 2x2 ft. flooring panel aligns to the longest side of the polygon. From that point, it generates a grid of 2x2ft that covers the polygon entirely getting the number of panels required and the layout of the ones that need to be cut.</p><p>Because the vertices of the grid are known, they serve as reference points for pedestals. By offsetting those points in the z-axis, we get the height of pedestals. Also, the sides of the 2x2 ft. panels can work as a reference lines for stringers.</p><p>We used the offset points to place a line based family as pedestals in Revit. A floor family was used for the panels. I am not sure if having hundreds of floating floors is the best way to represent panels, but it can be swapped by other family category. Stringers are not yet considered in the model creation.</p><p> More design rules need to be implemented to warrantee the constructability of the raised floor generated output, for instance, minimum size for panels, minimum distance between pedestals, edge pedestals vs edge profiles.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://www.summonidea.com/content/images/2020/11/Raised-Access-Floor-1.PNG" class="kg-image" alt="Summon Raised Access Flooring" srcset="https://www.summonidea.com/content/images/size/w600/2020/11/Raised-Access-Floor-1.PNG 600w, https://www.summonidea.com/content/images/size/w1000/2020/11/Raised-Access-Floor-1.PNG 1000w, https://www.summonidea.com/content/images/2020/11/Raised-Access-Floor-1.PNG 1365w" sizes="(min-width: 720px) 720px"><figcaption>DynamoBIM raised floor geometry</figcaption></figure><!--kg-card-begin: markdown--><h2 id="linktogithubrepo">Link to Github repo</h2>
<!--kg-card-end: markdown--><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/summon-raised-access-flooring"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/summon-raised-access-flooring</div><div class="kg-bookmark-description">This is a DynamoBIM script that generates raised access flooring from a polygon - summonidea/summon-raised-access-flooring</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Summon Raised Access Flooring"><span class="kg-bookmark-author">summonidea</span><span class="kg-bookmark-publisher">GitHub</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://avatars1.githubusercontent.com/u/69179455?s=400&amp;v=4" alt="Summon Raised Access Flooring"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[WIP: Parametric Drive-Thru]]></title><description><![CDATA[Dynamo definition of a simple corner case for a drive-thru.]]></description><link>https://www.summonidea.com/parametric-drive-thru/</link><guid isPermaLink="false">5f652f711339a05a6f94c39c</guid><category><![CDATA[parametric]]></category><category><![CDATA[dynamoBIM]]></category><category><![CDATA[drive-thru]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Fri, 18 Sep 2020 22:21:54 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2020/09/parametric_drive_thru.PNG" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2020/09/parametric_drive_thru.PNG" alt="WIP: Parametric Drive-Thru"><p>I like to play with parametric models  in DynamoBIM from time to time. When I stop doing them I miss them. But, when I work on them too much, I dislike how easily we can get a bad case of over-constrainpation. Then, what is left to do for Refinery? ;)</p><p>This is a work in progress. I worked on it because I was crunching numbers for a real estate investment and I thought it would be good to have a Dynamo definition of a simple corner case for a drive-thru.</p><p>Clone the repository from GitHub</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/parametric-drive-thru"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/parametric-drive-thru</div><div class="kg-bookmark-description">This is sample parametric model for a drive-thru development - corner option made with Dynamo Core 2.0.4.0 - summonidea/parametric-drive-thru</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="WIP: Parametric Drive-Thru"><span class="kg-bookmark-author">summonidea</span><span class="kg-bookmark-publisher">GitHub</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://avatars1.githubusercontent.com/u/69179455?s=400&amp;v=4" alt="WIP: Parametric Drive-Thru"></div></a></figure><!--kg-card-begin: html--><iframe src="https://gfycat.com/ifr/IdioticBlackGnu" frameborder="0" scrolling="no" allowfullscreen width="640" height="695"></iframe><!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[WIP - WPF App that extracts Part Atom XML from Revit Families]]></title><description><![CDATA[WPF app that extracts Part Atom XML from Revit Families. I am calling it Summon Family.]]></description><link>https://www.summonidea.com/wip-summon-family/</link><guid isPermaLink="false">5f60ca881339a05a6f94c2d0</guid><category><![CDATA[XML]]></category><category><![CDATA[WPF]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Tue, 15 Sep 2020 15:31:36 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2020/09/wpf_summonfamily.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2020/09/wpf_summonfamily.png" alt="WIP - WPF App that extracts Part Atom XML from Revit Families"><p>In the previous blog post, we created a <a href="https://www.summonidea.com/extracting-atomxml-from-revit-family/">console application that extracts the Part Atom XML</a> from a Revit family. This XML contains information from the family such as, name, category, update date, and active type parameters. Some Commercial content management software have a way around this to show all parameters. This is not really important in the context of this experiment.</p><p>I tried to convert the console app into a WPF app manually without any luck, but I found out the hard way that it is easier to start a WPF application from scratch and copy the functions over the new solution/project. After just a couple of tweaks, I was back in business.</p><p>Quickly enough I had to get used to data binding in order to present XML content on the UI form. My first test was just to get the XML and bind it to a text block in the form.</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2020/09/image-1.png" class="kg-image" alt="WIP - WPF App that extracts Part Atom XML from Revit Families" srcset="https://www.summonidea.com/content/images/size/w600/2020/09/image-1.png 600w, https://www.summonidea.com/content/images/2020/09/image-1.png 789w" sizes="(min-width: 720px) 720px"></figure><p>We are going to try to keep learning and building this up to show family types and its parameters.</p><p>Follow the development from the <a href="https://github.com/summonidea/summon-family">Repo</a>.</p><!--kg-card-begin: markdown--><h2 id="links">Links</h2>
<!--kg-card-end: markdown--><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/summon-family"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/summon-family</div><div class="kg-bookmark-description">WPF application that reads the Part Atom XML from a Revit family - summonidea/summon-family</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="WIP - WPF App that extracts Part Atom XML from Revit Families"><span class="kg-bookmark-author">summonidea</span><span class="kg-bookmark-publisher">GitHub</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://avatars1.githubusercontent.com/u/69179455?s=400&amp;v=4" alt="WIP - WPF App that extracts Part Atom XML from Revit Families"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Extracting PartAtom XML from a Revit Family]]></title><description><![CDATA[Console app that reads PartAtom XML file of Revit family files.]]></description><link>https://www.summonidea.com/extracting-atomxml-from-revit-family/</link><guid isPermaLink="false">5f3feea61339a05a6f94c1ce</guid><category><![CDATA[XML]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Fri, 21 Aug 2020 17:44:45 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2020/09/xmlcontent-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.summonidea.com/content/images/2020/09/xmlcontent-1.png" alt="Extracting PartAtom XML from a Revit Family"><p>The first time I was introduced to UNIFI labs, the family parameter extraction and category classification feature caught my attention. Just recently, I saw a post that suggested that we can unzip a Revit file (family or model) with 7-zip. See image below. Then, it was easier to explore and understand how Revit files are packaged. Later, as I kept reading about the topic, I found out that <a href="https://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html">The Building Coder</a> had discussed this topic 10 years ago! There are a couple of examples on Github for Revit plugins to read informational data from Revit content. </p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://www.summonidea.com/content/images/2020/08/image-11.png" class="kg-image" alt="Extracting PartAtom XML from a Revit Family"><figcaption>Extracted Revit Family</figcaption></figure><p>The example below is console app in C# that does not run on top of Revit. It reads a Revit family line by line until if finds the beginning and the end of the PartAtom XML that contains the family information. There are other ways to extract that XML string, but this was the most efficient I found. It finally console prints family information.</p><pre><code class="language-csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Program
{

    class Program
    {  

        static void Main(string[] args)
        {
            //excecution time start
            var watch = new System.Diagnostics.Stopwatch();
            watch.Start();

            string path = @"C:\familyName.rfa";
            //Extract AtomXml from Rfa
            string atomXml = ExtractAtomXmlFromRfa(path);
            //Console.WriteLine(atomXml);
            
            //initialize XML document class from string
            XmlDocument xmlDoc = new XmlDocument();
            //load XML
            xmlDoc.LoadXml(atomXml);
            //rfa &lt;entry&gt; element
            XmlNode root = xmlDoc.DocumentElement;

            //Display the contents of the child nodes.
            PrintXmlNodes(xmlDoc);

            //dynamic jsonText = JsonConvert.SerializeXmlNode(xmlDoc);
            //JObject json = JsonConvert.DeserializeObject&lt;JObject&gt;(jsonText);

            //foreach (JProperty property in json.Properties())
            //{
            //    property.Children();
            //    Console.WriteLine(property.Name + " - " + property.Value);
            //}

            //excecution time stop
            watch.Stop();
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");

            Console.ReadKey();
        }


        /// &lt;summary&gt;
        /// Reads line by line and Extracts AtomXML from revit family file
        /// &lt;/summary&gt;
        /// &lt;param name="path"&gt;&lt;/param&gt;
        /// &lt;returns&gt;string&lt;/returns&gt;
        static string ExtractAtomXmlFromRfa(string path)
        {        
            //define variables
            string startString = "&lt;?xml";
            string endString = "&lt;/entry&gt;";
            string chunks = "";
            string xml = "";
            bool startStringFound = false;
            bool endStringFound = false;

            StreamReader streamReader = File.OpenText(path);

            while ((!startStringFound || !endStringFound) &amp;&amp; !streamReader.EndOfStream)
            {
                string line = streamReader.ReadLine();
                Byte[] lineByte = Encoding.ASCII.GetBytes(line);
                string lineEncoded = Encoding.ASCII.GetString(lineByte);
                //Console.WriteLine(lineEncoded);
                if (lineEncoded.Contains(startString))
                {
                    //Console.WriteLine("start string {0} found in the following line:\n{1}", startString, lineEncoded);
                    startStringFound = true;
                }
                if (startStringFound)
                {
                    chunks += lineEncoded;
                    if (lineEncoded.Contains(endString))
                    {
                        //Console.WriteLine("end string {0} found in the following line:\n{1}", endString, lineEncoded);
                        int startIndex = chunks.IndexOf(startString);
                        int endIndex = chunks.IndexOf(endString);
                        xml = chunks.Substring(startIndex, endIndex + endString.Length - startIndex);
                        //Console.WriteLine(xml);
                        endStringFound = true;
                    }
                }
            }
            //XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.LoadXml(xml);
            return xml;
        }
                
        /// &lt;summary&gt;
        /// Prints in console Xml elements and Inner text
        /// &lt;/summary&gt;
        /// &lt;param name="node"&gt;&lt;/param&gt;
        static void PrintXmlNodes(XmlNode node)
        {            
            if (node.HasChildNodes)
            {
                for (int i = 0; i &lt; node.ChildNodes.Count; i++)
                {
                    XmlNode inode = node.ChildNodes[i];
                    if (node.ChildNodes[i].FirstChild != null)
                    {
                        if (node.ChildNodes[i].NodeType == XmlNodeType.Element &amp;&amp; node.ChildNodes[i].FirstChild.NodeType == XmlNodeType.Element)
                        {                            
                            int parentCount = NodeParentCount(node.ChildNodes[i], 0);
                            Console.WriteLine(new String('=',parentCount) + " " + node.ChildNodes[i].LocalName);
                            PrintXmlNodes(node.ChildNodes[i]);
                        }
                        if (node.ChildNodes[i].NodeType == XmlNodeType.Element &amp;&amp; node.ChildNodes[i].FirstChild.NodeType == XmlNodeType.Text)
                        {
                            int parentCount = NodeParentCount(node.ChildNodes[i], 0);                           
                            Console.WriteLine(new String('=', parentCount) + " " + node.ChildNodes[i].LocalName + " : " + node.ChildNodes[i].InnerText);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("ELSE");
            }
        }

        /// &lt;summary&gt;
        /// Counts the number of parents that a XML node is nested in
        /// &lt;/summary&gt;
        /// &lt;param name="node"&gt;XmlNode&lt;/param&gt;
        /// &lt;param name="count"&gt;int initial counter. Usually, 0&lt;/param&gt;
        /// &lt;returns&gt;int&lt;/returns&gt;
        static int NodeParentCount(XmlNode node, int count)
        {            
            if (node.ParentNode != null)
            {
                count++;                
                return NodeParentCount(node.ParentNode, count);                
            }
            else
            {
                return count;
            }
        }
    }
}</code></pre><p>You will see a commented snippet where I try to convert XML to JSON. I found out the execution time was slower when doing the conversion. </p><p>I created a github repository that may evolve in the future:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/rfa-atomxml-reader"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/rfa-atomxml-reader</div><div class="kg-bookmark-description">Console app that reads AtomXML file of Revit family files. - summonidea/rfa-atomxml-reader</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="Extracting PartAtom XML from a Revit Family"><span class="kg-bookmark-author">summonidea</span><span class="kg-bookmark-publisher">GitHub</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://avatars1.githubusercontent.com/u/69179455?s=400&amp;v=4" alt="Extracting PartAtom XML from a Revit Family"></div></a></figure><p>Enjoy!</p><!--kg-card-begin: markdown--><h2 id="links">Links</h2>
<p><a href="https://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html">https://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[How to create a Node.js server and execute a cmd command from a POST request]]></title><description><![CDATA[<!--kg-card-begin: markdown--><h2 id="settinguptheworkenvironment">Setting up the work environment</h2>
<!--kg-card-end: markdown--><p>To be honest, the world does not really lack of node-express-mongo tutorials. This is just a simple exploration to setup a server, listen to a request, save a record to a database, and trigger an action. </p><p>Assuming that Node.js has already been installed (if</p>]]></description><link>https://www.summonidea.com/how-to-create-a-nodejs-server-and/</link><guid isPermaLink="false">5f29607c1339a05a6f94bf50</guid><category><![CDATA[nodejs]]></category><dc:creator><![CDATA[Summon Admin]]></dc:creator><pubDate>Wed, 05 Aug 2020 02:15:36 GMT</pubDate><media:content url="https://www.summonidea.com/content/images/2020/08/summonaserver.PNG" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><h2 id="settinguptheworkenvironment">Setting up the work environment</h2>
<!--kg-card-end: markdown--><img src="https://www.summonidea.com/content/images/2020/08/summonaserver.PNG" alt="How to create a Node.js server and execute a cmd command from a POST request"><p>To be honest, the world does not really lack of node-express-mongo tutorials. This is just a simple exploration to setup a server, listen to a request, save a record to a database, and trigger an action. </p><p>Assuming that Node.js has already been installed (if not, <a href="https://nodejs.org/en/download/">download and install</a>), first, we need to set up a folder for our little experiment. Next, we need to initiate <strong>npm</strong> inside that directory.</p><pre><code>npm init</code></pre><p>That '<em>init'</em> command will help you to configure the project.  When you see the prompt, 'entry point', it refers to the name of the file that you will call later to run the server. We can enter <strong>index.js</strong>(or any other name) or just press enter if <strong>index.js</strong> is already the default suggestion. </p><pre><code>entry point: (index.js)</code></pre><p>When the project is created, after going through the prompts, there will be a <strong>package.json</strong> file in the project directory. That file contains the information that you just entered. It will also record the libraries we will install later, it will define how we run our application depending on the environment and more. But, we do not have to worry about that for now.</p><p>Let's install <a href="https://expressjs.com/">Express.js</a>, the library that will help us to create our app listening to a port for external requests.</p><pre><code>npm install express</code></pre><p>This action will get recorded in the <strong>package.json</strong> file under dependencies. </p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://www.summonidea.com/content/images/2020/08/image.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request"><figcaption>Captured from package.json</figcaption></figure><p>Also, there will be a new folder in our directory called <strong>node_modules</strong> where, from now on, the libraries we install will get downloaded to.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://www.summonidea.com/content/images/2020/08/image-1.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request"><figcaption>"node_modules" folder</figcaption></figure><!--kg-card-begin: markdown--><h2 id="creatinganexpressapp">Creating an Express app</h2>
<!--kg-card-end: markdown--><p>Create a new file called <strong>index.js</strong> in your project directory</p><p>Copy and paste the code below. This is the <a href="https://expressjs.com/en/starter/hello-world.html">Expressjs hello world example</a>:</p><pre><code class="language-javascript">//import libraries
const express = require('express')

const app = express()
const port = 3000

//routing
app.get('/', (req, res) =&gt; {
  res.send('Hello World!')
})

//listening to port
app.listen(port, () =&gt; {
  console.log(`Example app listening at http://localhost:${port}`)
})</code></pre><p>Save the file and using the command line run your server by executing the following command.</p><pre><code class="language-node">node index.js</code></pre><p>If you type <a href="http://localhost:3000/">http://localhost:3000/</a>, in your web browser, you will see the <em>Hello World! </em>response. Also, the console will show: <em>Example app listening at <a href="http://localhost:3000/">http://localhost:3000/</a></em></p><p>Now, we know how to respond to the client when they go a certain route in the app. In this case, the route is <strong>'/'</strong>. This usually translates to render HTML on the client side or send back data in a different shape. </p><p>Next, we will learn how to receive a data from the client side.</p><!--kg-card-begin: markdown--><h2 id="receivingdatafromtheclient">Receiving data from the client</h2>
<!--kg-card-end: markdown--><p>It is very common for a user to submit data through forms. Those forms usually have a submit button and that button is probably sending a <a href="https://expressjs.com/en/starter/basic-routing.html3">POST request</a> to the server. Thus, we will add a route to resolve POST requests for the root route <strong>'/'.</strong></p><pre><code class="language-javascript">app.post('/', function (req, res) {
  res.send('Got a POST request')
})</code></pre><!--kg-card-begin: html--><iframe src="https://gfycat.com/ifr/SoulfulClearAmoeba" frameborder="0" scrolling="no" allowfullscreen width="640" height="261"></iframe><!--kg-card-end: html--><p>The argument <em>'req'</em> is the one receiving data inside its body. If I try to <em>console.log(req.body)</em> the payload that the client sent to the server, we get an <em>"undefined"</em> meaning that <strong>Node.js</strong> needs to translate it.</p><pre><code class="language-javascript">app.post('/', function (req, res) {
  console.log(req.body)
  res.send('Got a POST request')
})</code></pre><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2020/08/image-2.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request" srcset="https://www.summonidea.com/content/images/size/w600/2020/08/image-2.png 600w, https://www.summonidea.com/content/images/2020/08/image-2.png 921w" sizes="(min-width: 720px) 720px"></figure><p>To parse it, we can use: <em>express.json()</em></p><pre><code class="language-javascript">app.use(express.json())</code></pre><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2020/08/image-7.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request" srcset="https://www.summonidea.com/content/images/size/w600/2020/08/image-7.png 600w, https://www.summonidea.com/content/images/2020/08/image-7.png 932w" sizes="(min-width: 720px) 720px"></figure><p><a href="https://stackoverflow.com/questions/47232187/express-json-vs-bodyparser-json">express.json vs bodyParser.json</a></p><!--kg-card-begin: markdown--><h2 id="savingtoadatabase">Saving to a database</h2>
<!--kg-card-end: markdown--><p>We are going to use MongoDB to create a database, a collection and save as document. <a href="https://docs.mongodb.com/manual/installation/">Install MongoDB</a>. Also, we will need to install the <a href="https://mongoosejs.com/docs/">Mongoose library</a>.</p><pre><code class="language-npm">npm install mongoose</code></pre><p>Import Mongoose to your code and connect to the local database.</p><pre><code class="language-javascript">const mongoose = require('mongoose');</code></pre><p>Connect to DB</p><pre><code class="language-javascript">//Connect to DB
mongoose.connect('mongodb://localhost/test', {
    useNewUrlParser: true, 
    useUnifiedTopology: true});
const db = mongoose.connection;</code></pre><p>Create an schema</p><pre><code class="language-javascript">//Schema constructor
const mySchema = new mongoose.Schema({
  key: String,
  property: String
});</code></pre><p>Create a model</p><pre><code class="language-javascript">//Create a model
const myModel = mongoose.model('my-collection', mySchema);</code></pre><p>Pass the data from the client and save it to the DB.</p><pre><code class="language-javascript">app.post('/', function (req, res) {
  const doc = new myModel(req.body)
  doc.save()
  res.send('Got a POST request')
})</code></pre><p>Now, if we send a POST request, it will send the body below and save it to the DB.</p><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2020/08/image-9.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request" srcset="https://www.summonidea.com/content/images/size/w600/2020/08/image-9.png 600w, https://www.summonidea.com/content/images/2020/08/image-9.png 784w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://www.summonidea.com/content/images/2020/08/image-8.png" class="kg-image" alt="How to create a Node.js server and execute a cmd command from a POST request"></figure><p>By sending a POST request, an action has been triggered, saving a document to a DB, but we can add more after that one inside <em>app.post. </em></p><!--kg-card-begin: markdown--><h2 id="executeacommand">Execute a command</h2>
<!--kg-card-end: markdown--><p>The command will execute a desktop program (Notepad) using the 'child_process' library</p><pre><code class="language-cmd">npm install child-process</code></pre><!--kg-card-begin: markdown--><h2 id="githubrepo">Github Repo</h2>
<!--kg-card-end: markdown--><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://github.com/summonidea/rvtmodel-collab-server"><div class="kg-bookmark-content"><div class="kg-bookmark-title">summonidea/rvtmodel-collab-server</div><div class="kg-bookmark-description">Setup of a server to listen to a POST request, save a record to a database, and trigger an action - summonidea/rvtmodel-collab-server</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://github.githubassets.com/favicons/favicon.svg" alt="How to create a Node.js server and execute a cmd command from a POST request"><span class="kg-bookmark-author">summonidea</span><span class="kg-bookmark-publisher">GitHub</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://avatars1.githubusercontent.com/u/69179455?s=400&amp;v=4" alt="How to create a Node.js server and execute a cmd command from a POST request"></div></a></figure><!--kg-card-begin: markdown--><h2 id="links">Links</h2>
<p><a href="https://expressjs.com/en/starter/installing.html">https://expressjs.com/en/starter/installing.html</a><br>
<a href="https://expressjs.com/en/starter/hello-world.html">https://expressjs.com/en/starter/hello-world.html</a><br>
<a href="https://expressjs.com/en/starter/basic-routing.html">https://expressjs.com/en/starter/basic-routing.html</a><br>
<a href="http://expressjs.com/en/api.html#express.json">http://expressjs.com/en/api.html#express.json</a><br>
<a href="https://mongoosejs.com/docs/">https://mongoosejs.com/docs/</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>