<?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: Symon  Kipkemei</title>
    <description>The latest articles on DEV Community by Symon  Kipkemei (@symonkipkemei).</description>
    <link>https://dev.to/symonkipkemei</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886349%2F5679f77a-fe34-48a2-a252-b360b764fd57.jpeg</url>
      <title>DEV Community: Symon  Kipkemei</title>
      <link>https://dev.to/symonkipkemei</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/symonkipkemei"/>
    <language>en</language>
    <item>
      <title>A Gathering of revit files</title>
      <dc:creator>Symon  Kipkemei</dc:creator>
      <pubDate>Sun, 02 Apr 2023 11:32:14 +0000</pubDate>
      <link>https://dev.to/symonkipkemei/a-gathering-of-revit-files-1dnh</link>
      <guid>https://dev.to/symonkipkemei/a-gathering-of-revit-files-1dnh</guid>
      <description>&lt;h1&gt;
  
  
  Problem
&lt;/h1&gt;

&lt;p&gt;I wanted to  update my Revit template based on all the Revit projects I have done previously in the past.&lt;/p&gt;

&lt;p&gt;The challenge I encountered was that the Revit files were scattered in several folders of sub folders of subfolders. Retrieving them would be a lot harder and a tedious work.&lt;/p&gt;

&lt;p&gt;Besides that, Some Revit files  are back-up files that are currently consuming  unnecessary storage space. Filtering through to get the latest native Revit files would be a lot harder.&lt;/p&gt;

&lt;p&gt;Below is a script that I developed that would assist gather all Revit files in a project directory&lt;/p&gt;

&lt;h3&gt;
  
  
  Scripting process
&lt;/h3&gt;

&lt;p&gt;Import pathlib module&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pathlib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Establish the project directory. In this case a project directory is the root folder for all your architectural projects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# path to my desktop
start_path = "/mnt/d/New folder"
start_path_obj = pathlib.Path(start_path)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new directory where you would like to store your revit files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# create new folder
new_path = pathlib.Path(f"{start_path}/Revit-bastards")
new_path.mkdir(exist_ok=True )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defining a function that would establish if a file is a revit file, if it is a revit file will be moved to a new directory/ folder specified above&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def check_move_files(path,new_path) -&amp;gt; None:
    """check if file is  png it then moves to a separate folder

    Args:
        path (Path): path of the current folder/file/directory

    """

    if path.suffix == ".rvt" or path.suffix == ".txt":
        # create a new path for the level_1 
       new_filepath = new_path.joinpath(path.name)

       #move files
       path.replace(new_filepath)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can start scanning across for the revit files,incase we encounter a folder, we will open the folder and check for the revit files level 1....level 2....level 3&lt;/p&gt;

&lt;p&gt;We can scan for files until the script is done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# starting level
for level_1 in start_path_obj.iterdir():
    if level_1.is_file():
        check_move_files(level_1,new_path)

    # level 1
    else:
        level_1_path = start_path_obj.joinpath(level_1)
        for level_2 in level_1_path.iterdir():
            if level_2.is_file():
                check_move_files(level_2,new_path)
            #level 2
            else:
                level_2_path = level_1_path.joinpath(level_2)
                for level_3 in level_2_path.iterdir():
                    if level_2.is_file():
                        check_move_files(level_3,new_path)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check the full script, checkout :&lt;br&gt;
&lt;a href="https://github.com/symonkipkemei/mover"&gt;https://github.com/symonkipkemei/mover&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if you encounter any challenges, feel free to leave an issue:&lt;br&gt;
&lt;a href="https://github.com/symonkipkemei/mover/issues"&gt;https://github.com/symonkipkemei/mover/issues&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you!!&lt;/p&gt;

</description>
      <category>revitapi</category>
      <category>pathlib</category>
      <category>beginners</category>
    </item>
    <item>
      <title>command line game</title>
      <dc:creator>Symon  Kipkemei</dc:creator>
      <pubDate>Sun, 02 Apr 2023 07:59:54 +0000</pubDate>
      <link>https://dev.to/symonkipkemei/command-line-game-813</link>
      <guid>https://dev.to/symonkipkemei/command-line-game-813</guid>
      <description>&lt;p&gt;Dive into a gameplay like never before.&lt;/p&gt;

&lt;h3&gt;
  
  
  summary
&lt;/h3&gt;

&lt;p&gt;The game is about akin to dungeons and dragons. There are two doors; the left door and the right door. One of the rooms/caves is empty. If you search further/look around you will encounter a sword.&lt;/p&gt;

&lt;p&gt;The other room contains a dragon .If you choose to fight the dragon without a sword , chances of defeat are high.&lt;/p&gt;

&lt;h3&gt;
  
  
  Give it a try
&lt;/h3&gt;

&lt;p&gt;Would you like to give it a try?&lt;br&gt;
&lt;a href="https://github.com/symonkipkemei/command-line-game"&gt;https://github.com/symonkipkemei/command-line-game&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pseudocode breakdown
&lt;/h3&gt;

&lt;p&gt;Here is a sum of pseudocodes of how the game play works. I will go into the details later on.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;get the player name&lt;/li&gt;
&lt;li&gt;display message &lt;/li&gt;
&lt;li&gt;present them with two doors&lt;/li&gt;
&lt;li&gt;if they choose the left door, they'll see an empty room, they can choose to look around, If they do so, they will find a sword. They can choose to take it or leave it.&lt;/li&gt;
&lt;li&gt;if they choose the right door, they'll encounter a dragon,  they have the choice to fight it. If they have the sword from the other room, then they will be able to defeat it and win the game.&lt;/li&gt;
&lt;li&gt;In both options they have an option to return to the previous room.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>games</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
