0:02 hi everybody Welcome to the fourth
0:04 lesson of learn ravit API course we're
0:06 actually this close to actually dive
0:08 into ravit API code but before we do
0:10 that we need to set up your development
0:12 environment and it's not a complicated
0:14 process we will need to install a few
0:16 Revit addin that are necessary for any
0:19 ravit API developer and we need to set
0:21 up your IDE which stands for code editor
0:23 with a lot of useful features we'll
0:25 install two of the most popular code
0:27 editors which is pie charm and visual
0:30 studio code and we will set up right a
0:32 autocomplete in both of them and I
0:33 actually recommend you to have both of
0:35 them set up so in case one of them would
0:37 give you any errors or stop working you
0:39 can quickly jump to another and continue
0:41 your work with the code instead of
0:43 losing focus and spending time on
0:45 solving a bu all right and without
0:47 further Ado let's actually prepare your
0:49 development environment first of all
0:51 we're going to install a few addings the
0:53 first one is going to be ravit lookup
0:55 and we can get it on the GitHub just
0:57 type ravit lookup GitHub and then look
0:59 for repository from Jeremy tamic then in
1:01 here here you can scroll through and
1:02 read a little bit information for
1:03 example here's the difference between
1:06 single and multiple users and then when
1:08 you're ready come here and on the right
1:10 side look for releases I'm going to
1:12 click here here's the latest version at
1:14 the moment of the recording and I'm
1:16 going to scroll down to the assets
1:17 you'll notice that there are
1:20 installations for different versions in
1:22 my case I use 2023 so I'm going to
1:24 download this version right here
1:26 2023 then once it downloaded install it
1:28 like any other plugin you would do you
1:30 might see this message about Windows
1:32 protected on your PC then click here on
1:35 more info and run it anyway also if
1:36 you're interested this is made by the
1:38 Jeremy tamic who is part of Autodesk
1:40 development team so I'm pretty sure it's
1:43 very safe to use this then here's where
1:44 it's going to be installed click next
1:47 next and install and now it's complete
1:49 now the second plugin we need to install
1:50 is Revit python shell and it's kind of
1:52 optional and it's up to you first of all
1:54 let's find it and then I'm going to talk
1:55 more about it I'm going to look for
1:58 ravit python shell GitHub and I need
1:59 this architecture building system
2:01 environment right here let's click on
2:03 that this plugin was developed by Darren
2:06 Thomas and it's also the plugin on which
2:09 pyit was built on also you should know
2:10 that I don't think this plugin is
2:12 maintained anymore so there's a good
2:15 chance it's never will work on Ry 2025
2:16 and all the further versions so keep
2:20 that in mind but if you use 2023 2024 it
2:22 might be quite useful for debugging and
2:24 testing small Snippets so I'm going to
2:26 scroll down right here and have a look
2:28 here installers for all the older
2:31 versions and if you want to for 2023 and
2:33 probably 2024 but I'm not sure we can
2:35 get it right here all right and once
2:37 it's downloaded just install it as usual
2:39 and again remember this is an optional
2:41 plugin I will be using it once in a
2:43 while but in majority cases that's not
2:45 necessary all right we have the ravit
2:47 addins and that's all the next we going
2:49 to actually install our IDs and set up
2:51 your development environment for that
2:53 we're going to look for pie
2:55 charm and we're also going to look for
2:58 visual studio
3:00 code for visual Studio code we can
3:02 download it from this website let's
3:03 click here and then click on download
3:06 for Windows it takes you to thank you
3:08 page and it started downloading then
3:10 let's go here and Pie charm is made by
3:11 the jet brains so we're going to go to
3:13 their website and in here we're going to
3:15 download it and listen every time I make
3:17 tutorial about py charm they change
3:18 their landing page so it's very likely
3:21 it's going to change again very soon but
3:22 either way just go to the website and
3:23 look for the download button and make
3:25 sure you download the free community
3:27 version and not the professional one cuz
3:28 sometimes they make it very confusing
3:30 which one you download
3:32 and then in here this is py charm
3:34 professional and if I scroll down here
3:36 is py charm Community version edition
3:38 we're going to download that one all
3:40 right while we downloading the py charm
3:41 we're going to start installing the
3:43 visual studio code let's click on the
3:45 installer and in here we're going to
3:47 accept with the agreement then check
3:48 where you save it but I don't think it's
3:52 really relevant and just next next next
3:54 in here you might want to create desktop
3:56 icon then you want to click on those
3:57 ones so when you right click on the
3:59 python file or on the folder you can
4:02 open it inside of Visual Studio
4:04 code I'm not going to register it as my
4:06 main editor because I'm going to use py
4:08 charm as my main editor but if you
4:09 prefer Visual Studio code you can leave
4:12 it on and also going to add to path this
4:16 is Okay click on next and install all
4:17 right we finished installation of the
4:19 visual studio code let's click on finish
4:21 and it's going to open it and Meanwhile
4:22 we're also going to install the py charm
4:25 Community version let's click on next
4:27 next in here it's pretty much the same
4:29 options we want to add here open folder
4:31 project we want to add Community Edition
4:32 and in here I want to create
4:34 associations because I'm going to use py
4:37 charm as my main ID now click on next
4:39 and install
4:41 it all right by now we have installed
4:43 Visual Studio code in py charm it ask
4:45 you to restart your computer and you can
4:47 do that or you can do it later it's not
4:49 going to be an issue but before going to
4:51 configure them we need to download ravit
4:53 API stops so we can use them inside the
4:55 references to get the auto complete to
4:57 do that I'm going to go to learn rate
4:59 API blog and then there is one of the
5:02 Articles how to create R API stabs for
5:04 autocomplete in here there's going to be
5:06 a video in case you're interested how
5:09 you can create stabs yourself with pyit
5:10 but we don't want to do that right now
5:11 I'm just going to scroll down and
5:13 download it here or if you watch inside
5:15 of my course platform they're going to
5:17 be download links under the video now
5:20 I'm going to download 2023 and maybe
5:23 like 2021 just to show you two different
5:25 examples all right I downloaded them
5:28 here let's open both of
5:31 them and here here they are here is 2021
5:32 and here is
5:34 2023 first of all we want to find a
5:36 location where we're going to place them
5:38 I'm going to go to the upd
5:40 data and this is a really good place to
5:42 place them so you never delete them
5:44 accidentally in here I'm going to create
5:46 something like pie charm vs which stands
5:48 for virtual environment and I'm going to
5:50 explain what it means in a moment and in
5:52 here as you can see I already provided
5:55 here ravit API 2023 and ravit API
5:57 2024 normally you would just grab
5:59 whatever you downloaded and paste it
6:01 here here or anywhere else on your
6:03 computer doesn't matter where it's
6:05 located all right and now once you
6:07 downloaded your ravit API stabs we are
6:08 ready to configure your Visual Studio
6:10 code and Pie charm and it's not that
6:12 complicated we're going to start with
6:14 the visual studio code and let's open it
6:16 and have a look when you're going to
6:17 open it you're going to see this kind of
6:18 welcome page and in here you're going to
6:21 have your Explorer now in here you have
6:23 your Explorer you have your search bar
6:25 Source control this is for using the
6:27 GitHub then for running and debugging
6:28 and right here have a tab for the
6:31 extensions go to the extensions Tab and
6:33 have a look for the python then once
6:35 you're going to find the python right
6:37 here you can see it has 130 Millions
6:39 installations and click on the install
6:40 button right
6:43 here okay it tells me that it was
6:45 installed let's actually make it a
6:47 little bit bigger so we can see
6:49 more and now we're going to go to
6:51 explore then click on file and click new
6:54 file I'm going to call it script.py and
6:55 it doesn't matter where you place it for
6:56 now I'm just going to drop it on the
6:58 desktop later on you will be able to
7:00 open your fold the
7:03 structure then let's close the Explorer
7:04 we just want to test if the regular
7:06 python autocomplete already works you
7:09 can write something like import OS and
7:12 then let's write OS path join and you
7:14 can see every single thing that I write
7:16 I get some kind of suggestions get the
7:18 references to documentations and so on
7:19 so not that regular autocomplete for
7:22 python works this is already great now
7:23 the next thing we want to do is to
7:25 connected to ravit API autocomplete and
7:26 to do that you're going to go to
7:28 extensions find the python that you've
7:30 just installed and and right click and
7:31 there's going to be extension settings
7:34 right here then you will see here python
7:36 autocomplete extra paths this is where
7:38 you want to click edit in settings
7:41 Json I already have it set up and I'm
7:42 going to provide you all this code that
7:44 you can see on my screen in here you'll
7:47 see python. analysis. extra paths and
7:49 inside you need to provide a few paths
7:51 the first one already provided for Ravid
7:52 API stops and this is where you placed
7:55 it I placed first one right here and
7:56 actually let's change the path I'm going
7:58 to paste it
8:00 here and then make make sure that you go
8:02 inside of this path of whatever version
8:03 you're going to use in my case I want to use
8:05 use
8:07 2023 also make sure that you have double
8:09 slashes everywhere because sometimes
8:11 slash and a letter have special syntax
8:14 in the code so this way you're going to
8:16 set up your rabit API autocomplete
8:18 secondly you also want to connect your
8:21 pyit Masters folder library to do that
8:22 you need to find where your pyit is
8:24 installed usually if you're going to go
8:27 to up data like this then click on P or
8:29 scroll until you can find your Pit Master
8:30 Master
8:32 and inside there's going to be this pyit
8:34 library in here you can see py RIT RPV
8:38 and all of that copy this path and paste
8:40 it right here and also make sure you
8:42 have all your slashes two times so you
8:45 don't have this red highlight and this
8:46 library is Ed for whenever you're going
8:48 to write from py import forms forms
8:50 alert and so on it also going to give
8:53 you all the auto suggestions now save it
8:56 just to be sure that it works and now
8:58 let's go and try it again I'm going to
9:00 go to the script.py file
9:01 and then we're going to come here and
9:03 test it I'm going to write from Autodesk
9:05 ravy DB import everything and then we're
9:06 going to try to create some kind of
9:08 collector I'm going to try to use
9:10 filtered element collector class and it
9:11 doesn't give me any auto suggestions
9:13 which is a bit weird so I'm going to
9:17 close it and reopen it
9:19 again and now this time let's try again
9:21 and this time when I'm going to type
9:22 filtered element collector you can see
9:24 all the auto suggestions for example
9:26 here has to be a document and I can
9:29 write off class class of w type and so
9:30 on so on and so on now we know that
9:32 autocomplete works all right
9:35 autocomplete is complete now next is
9:36 really important let's go to the file
9:38 preferences and change one of the
9:41 settings let's go here to settings I'm
9:42 going to look for the
9:45 zoom and I love to have this mouse wheel
9:47 Zoom activated this way you can always
9:49 kind of hold control and kind of zoom in
9:51 zoom out to the code snippet depending
9:53 on whatever you're doing this is really
9:54 useful and also if you want to you can
9:56 search for different themes inside a
9:58 visual studio code editor so you can
10:00 choose how it looks maybe you prefer
10:02 some different colors and so on high
10:04 contrast and so on and you can choose
10:06 whatever color theme you prefer for your
10:08 code all right we've configured our
10:09 Visual Studio code and now let's
10:11 configure your py charm and to do that
10:13 you also need to install the python
10:14 version and the best way to find what
10:16 kind of python version do you need is to
10:19 actually open ravit go to py RIT and
10:21 right here you can click on the about
10:23 page once you do that you will see that
10:25 here is the version of py that you use
10:26 and it's going to tell you it's running
10:29 on the RN python 2.7.1
10:33 and it uses 3.8.5 for the cpython also
10:34 it's not that important which python
10:36 version you're going to install for your
10:38 py charm because in the end of the day
10:39 we going to write code and visual studio
10:41 code in pie charm but we never will
10:43 execute it inside of these code editors
10:45 because it will always tell you that
10:46 there are not enough references there
10:48 are issues because it cannot be
10:50 connected to the Revit we use the these
10:52 code editors to make it easier for us to
10:54 write with all the autocomplete with all
10:56 the features for selection refactoring
10:58 and so on and then we kind of take this
11:00 code put it in P Revit extension and
11:01 then we're going to go to Revit and
11:03 click on the button to actually run it
11:05 so keep this in mind you never run Revit
11:08 API code from Visual Studio code or py
11:10 Charm or any other ID you use it for
11:12 writing the code and then you're going
11:14 to run it with the py rabit engine or
11:16 with Dynamo engine or with Ravid python shell
11:17 shell
11:20 engine all right so let's go and install
11:21 python version
11:23 2711 and it's also not necessary to
11:26 install the Ron python version because
11:28 py charm and many other IDs they don't
11:30 always have the support for old versions
11:32 of RN python so therefore we can look
11:38 2.7.1 right here is the official python
11:40 website just scroll down and load here
11:42 one of the installers First Look the
11:44 operating system look for the windows
11:46 and I want to get my MCI installer this
11:55 fine all right once you're going to
11:56 download it we can just run and install
11:59 it I'm going to install it for all users
12:00 click on
12:02 next then in here is location where it's
12:04 going to be installed in my case it says
12:07 cpython 27 you can click on next in my
12:09 case I already have it installed so I'm
12:10 not going to override it I'm just going
12:14 to write here 2711 and click on next but
12:15 you just leave whatever is there if you
12:18 don't have it yet now in here you
12:19 probably don't want to touch anything
12:20 just click on next and you're going to
12:22 install it as usual now I'm going to
12:23 cancel it because as I said I already
12:26 have it installed and once you installed
12:27 it let's just go and open the pie charm
12:31 so we can also configure this
12:33 here is how it looks it also ask me if I
12:34 want to import settings from the visual
12:36 studio code and I don't want to do that
12:38 I want to have the default version of
12:40 the py charm because I want to have py
12:42 charm shortcuts and if you're going to
12:43 follow my tutorials with py charm you
12:46 probably also want to keep it this
12:48 way and this is the welcome screen of py
12:50 charm you can customize how it looks
12:51 already here some plugins and so on but
12:52 we're going to just create the project
12:54 and then configure from there you can
12:57 either create a new project or you can
12:59 open existing project and we can select
13:01 the extension that we already created in
13:02 the previous
13:04 lessons I'm just going to open the path
13:06 where my extension is located and it's
13:08 right here learn rate API
13:10 extension then let's enter here and make
13:12 sure that you select that extension and
13:14 not the outside folder it's not a big
13:15 difference but it's good to have this
13:18 one as the root folder then click on
13:20 okay it will often be asking do you
13:22 trust location when you open the project
13:24 and I totally trust my location because
13:25 I write all the
13:28 code and now here how it looks on the
13:29 left you have your EXP Explorer it also
13:31 going to give you some kind of help file
13:34 and what's new in pycharm 2024 actually
13:36 I haven't looked at it myself yet so I
13:38 don't know what's new in 2024 I used to
13:42 use 2022 or 23 I don't remember all
13:43 right in this new version of py charm a
13:45 few things have definitely changed and
13:46 it looks a bit different to what I'm
13:48 used to but normally here's the button
13:50 to open your project and right here in
13:52 the bottom you'll notice python 3.8 and
13:55 this is The Interpreter of the Python my
13:57 case it already has something we can
14:00 click here go to interpreter settings
14:02 now we want to either click here and
14:04 show all or add the new interpreter I'm
14:06 going to show all I'm going to add it
14:08 here add new interpreter and then in
14:09 here I'm going to use Virtual
14:11 environment virtual environments allow
14:13 us to prec configure python environments
14:15 for different purposes we could install
14:17 all necessary packages globally but that
14:19 would clut our development space and
14:20 might lead to bugs across different
14:21 python projects because of the
14:23 dependencies this virtual environment
14:25 allows you to create separate
14:26 configurations for different packages
14:28 and different package versions as you
14:30 want so they do not interact with each
14:32 other imagine that you have a container
14:34 that you would use for ravit API 2023
14:36 development you would put all necessary
14:38 packages references and ravit API stabs
14:41 for 2023 so this container is dedicated
14:43 for working with ravit API 2023 then you
14:45 could create similar containers for
14:49 Revit API 2024 2022 and so on or maybe
14:50 you would decide that you want to create
14:52 a website and you would need another
14:54 virtual environment with another set of
14:56 packages and references and then
14:57 whenever you create a new project you
14:59 can just grab the right container with
15:01 the Right Packages pre-installed and you
15:02 can easily switch between them during
15:04 development and this is what we're going
15:05 to do in py charm we're going to create
15:06 two virtual
15:08 environments so I'm going to click here
15:11 on the new and it often suggest you to
15:13 put the vent folder inside of your
15:15 project but in case of our parate
15:17 extension I would not recommend that
15:18 instead of that let's open a folder and
15:20 move it somewhere else I want to make
15:22 sure that it's actually inside of my app
15:25 data but in there I'm going to create a
15:26 new folder and I'm going to call it
15:29 something like parit virtual environment
15:31 then I'm going to go inside of there and
15:33 I'm going to create a new folder and
15:36 this is going to be for ravy 23 click on
15:38 okay and it has to be an empty folder so
15:40 click on okay then you need to select
15:42 your python version in my case I already
15:45 have Python 2.7 installed in C here but
15:47 you can select from one of the available
15:49 versions if you don't see your version
15:50 here you can click on free dots and find
15:53 the location yourself as I said mine is
15:55 located in the drive
15:58 C then there is Python 2.7 and you need
16:01 to click on the python. X and the moment
16:02 you click it's going to open the right
16:04 thing now we don't need this stick box
16:06 so click on okay and move further it's installing
16:07 installing
16:10 it now it's installing it and right here
16:12 we have our new virtual environment I'm
16:14 going to delete that one because I don't
16:16 want to use it I just need the
16:18 2023 let's also create the second one
16:20 for ravit
16:22 2021 in here I'm going to just write ravy
16:23 ravy
16:25 21 click on okay I use the same
16:28 interpreter click on okay now I have two
16:29 different Environ
16:31 and now in here we can click on show
16:33 interpreter paths and these are all the
16:34 different paths that python interpreter
16:36 is going to look for your packages or
16:38 stops or anything else we going to click
16:40 here on the path and we need to provide
16:43 the path to our Revit API
16:45 stops all right if I remember correctly
16:47 I think I put it here in pie charm Vin
16:49 and right here is the folder for Revit
16:52 21 and Rit 23 so I'm going to copy the
16:55 path come here and paste it on the
16:57 top and then inside I'm going to look
17:01 for the r 2023 I want to take this
17:03 folder and then we're going to add our
17:06 pyit masters folder which I can also see
17:07 right here we're going to go to pyit
17:09 library and we need this
17:12 path okay these are the two paths click
17:15 on Okay now click on RIT 2021 click on
17:17 The Interpreter and we're also going to
17:20 do the same we need our P RIT path and
17:23 we also need the path to our pie charm
17:25 environment in this case I think it's
17:30 going to be 2021 and let's click on okay
17:31 all right now click okay okay okay and
17:32 you can see on the bottom that it's
17:34 scanning all the folders indexing and
17:36 you have to wait until it's finished
17:38 before you're going to try
17:40 it okay it's complete and now here you
17:43 can see your interpreters I can see my R
17:45 21 and I can see R 23 and it's very
17:48 quick to jump between them now let's
17:50 quickly create a new python file I'm
17:52 going to call it test.py just to see if
17:55 we have our interpreter working and
17:56 first of all let's test the regular
17:58 python autocomplete going to import OS
18:01 and then right OS path join and you can
18:02 see it offers me all the auto
18:05 suggestions and so on the next we're
18:07 going to try from Autodesk RVE it and it
18:09 doesn't see it cuz I think we'll also
18:12 need to restart our pie charm so let's do
18:16 that and I see that it's still not
18:18 working so let's go and have a look
18:20 inside interpreter settings again I'm
18:22 going to show all and have a look at
18:24 these two then let's go and check the
18:26 paths and for some reason you can see
18:28 when you first add it sometimes it kind
18:29 of deletes it right away I don't know
18:31 why but we're going to try to add it
18:34 again going to take RAV 21 and we're
18:36 going to take our pit
18:39 Masters which is going to be this one
18:41 click on
18:43 okay and then 23 we're also going to do
18:46 the same let's add py RIT and then we're
18:48 also going to add ravit
18:50 2023 I don't know why it happens but
18:52 it's often when I install pie charm
18:54 create my interpreter and add paths
18:55 right away it doesn't remember the paths
18:58 on the first try and now if I'm going to
19:02 try from Autodesk cravy DB import
19:04 everything collector equals filtered
19:07 element collector and everything works
19:14 good and now we can also test different
19:16 ravit API versions right now I'm in my
19:18 ravit API 2023 I can write something
19:21 like category do and then there is a buil-in
19:21 buil-in
19:24 category this parameter is available in
19:26 2023 version so it gives me auto
19:28 suggestions but if I'm going to go to
19:32 2021 and remove it and then try to
19:34 category and then try to get built in
19:35 category it doesn't make me this
19:37 suggestions because this parameter
19:39 doesn't exist in R 21 and this way you
19:41 can jump between to make sure that you
19:43 get the right suggestions cuz sometimes
19:45 you can have the same method but in one
19:46 version it takes four arguments and in
19:48 the other it takes three arguments and
19:49 then you also have to make two different
19:51 scripts all right and if you followed me
19:53 along you should have your code editor
19:55 set up correctly and I strongly
19:56 recommend you to install both py charm
19:58 and visual studio code so you have a
20:01 back version and for your homework test
20:03 if your autocomplete work in both of
20:05 these code editors and if not try
20:07 restarting the code editor maybe check
20:08 if all the references are placed
20:10 correctly because you saw that my
20:11 references disappeared on the first try
20:14 in pie charm for some reason and lastly
20:16 rewatch this video again and make sure
20:17 that you follow all the steps correctly
20:19 but you can also let me know in the
20:20 community or the comment section below
20:22 if something went wrong or you need help
20:24 with anything but please describe all
20:26 the steps that you already tried and if
20:27 you get any error messages this will
20:29 help me identify the issue and help you
20:32 solve it and once everything works
20:33 correctly you're ready to start the next
20:35 lesson where we'll talk about pirate
20:37 script anatomy and we will create uh
20:39 templates that you will use for all your
20:41 scripts in the future so you never have
20:43 to start from blank page again I will
20:45 see you there and I want to wish you