How to set up Revit API Autocomplete in pyCharm [RevitAPI + python]

Поділитися
Вставка
  • Опубліковано 5 лют 2025

КОМЕНТАРІ • 90

  • @ErikFrits
    @ErikFrits  2 роки тому +3

    Warning:
    There is a bug with python v3.10, which is known to be exposed if you install a VisualStudio 2022 runtime.
    stackoverflow.com/questions/69709251/failed-to-create-virtual-environment-in-pycharm
    So If you have a python 3.10 and you can not create a virtual enviroment with python 2.7 then try uninstalling python 3.10 and reinstalling python 2.7.

    • @renzogiancarloriosrugel2331
      @renzogiancarloriosrugel2331 2 роки тому +1

      But Revit 2023 works with Python 3? Any difference?

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      ​@@renzogiancarloriosrugel2331
      I still work mostly in Revit 2021, maybe going to migrate in the coming months.
      Also, I create my tools with pyRevit and I need access to .NET libraries with clr module to get List class and to make my GUI with WPF. clr module only available in IronPython(which is based on python 2.7).
      pyRevit also has support for python3, but I heard that sometimes it gives you issues, since it's in development.
      Overall I don't find so much difference when I code in py2 or py3. Just a few new things and packages are not available.

    • @renzogiancarloriosrugel2331
      @renzogiancarloriosrugel2331 2 роки тому +1

      @@ErikFrits The truth is that yes, there are not many differences and if there are, I imagine that ironpython would say it with the interpreter. I'll take a look at pyRevit.

    • @dascorp1
      @dascorp1 Рік тому

      @@ErikFrits Could you confirm we cannot use Python 3.10 while working with Revit v20.1, I followed your video and cannot get full autocompletions after "." for example FilteredElementCollector autocompletes but then nothing happens after . (dot). also set up vs code as per your note below and stuck at after dot autocompletion.

    • @ErikFrits
      @ErikFrits  Рік тому

      Your comment got lost, just noticed accidentaly.
      I recommend using pyCharm so it's easier to code but the code will get executed with python provided by pyRevit. So we can use pretty much any version of python in pyCharm, since autocomplete will be done thanks to stubs folder. Maybe stubs didn't load completely at first, therefore limited suggestions?
      Normally it should work well. Let me know if you still having issues

  • @ciljoy
    @ciljoy 2 роки тому +6

    Hi, thanks for making this step by step video. Setting up these coding environments can be really daunting, especially for people just trying to get into coding. One thing to note, pyCharm failed to set up a virtual environment for me using using python 2.7 as the base interpreter. But it works now, once I updated to python 2.7.16 (I'm on windows 10).

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      Yes I agree. I had to spend quite some time to remember myself how did I do it in the past😅.
      Thanks for sharing your solution!
      It might be useful for someone.

    • @iloveminecraftyeah
      @iloveminecraftyeah Рік тому

      I had the same error, thanks for the comment. It sets up the environment for me now

    • @general212f
      @general212f Рік тому +1

      I had the same problem. Many thanks for the comment. You saved me!

    • @akshaysuresh5302
      @akshaysuresh5302 10 місяців тому

      Huge Thanks

  • @owurakuotchere-darko9392
    @owurakuotchere-darko9392 2 роки тому +4

    Thank you for your Revit API videos… it’s really helpful and you have demistified things for me:)

    • @ErikFrits
      @ErikFrits  2 роки тому +3

      Happy to help!
      I know the feeling when you just starting with RevitAPI, I am trying to make series of tutorials I wish I had at the time ;)

  • @1985DreamZ
    @1985DreamZ Рік тому +1

    Hi Erik,
    Your Revit tutorial videos have been a tremendous help as I dive into this software. I have a couple of quick questions:
    I noticed you use Python 2.7 in your videos. Any specific reason for this choice over Python 3.11?
    Are there any videos on using C# in Revit? How can I apply C# codes into Revit?
    Appreciate your insights.

    • @1985DreamZ
      @1985DreamZ Рік тому +1

      Traceback (most recent call last):
      File "**************\main.py", line 1, in
      from Autodesk.Revit.DB import *
      File "*************************\stubs.min\Autodesk\Revit\DB\__init__.py", line 10, in
      from __init___parts.BaseExportOptions import BaseExportOptions
      ModuleNotFoundError: No module named '__init___parts'
      Process finished with exit code 1
      getting this error after following all the steps... just written from Autodesk.Revit.DB import *

    • @ErikFrits
      @ErikFrits  Рік тому

      I use 2.7 because pyRevit used to use IronPython 2.7.7 version.
      Now new IronPython version was released, I think it's something like 3.4.. And pyRevit uses it instead. I just keep my old environment as it doesn't matter what i Use in my IDE, because code is not being run from my IDE.
      So when we create our dev environment we just need to make Revit API autocomplete work and we don't need to care what python version we use.
      Regarding C#, I don't really use it and therefore I don't want to teach it to others.
      I decided to stay with python and be the guy who is using Revit API with python only :)
      I am kind of allergic to semi-colons ; 😂

    • @ErikFrits
      @ErikFrits  Рік тому

      I assume you try to run your code inside of IDE.
      As I mentioned IDE is used only to access Revit API autocomplete and other features for writing code, but not for execution.
      Revit API scripts need access to Revit application, and therefore we can run it from RevitPythonShell, pyRevit and Dynamo because they have their python engines setup already and work for us

    • @1985DreamZ
      @1985DreamZ Рік тому +1

      @@ErikFrits Hey. Thanks for the responses. I am writing to seek guidance on debugging python code in pycharm or in any other ide before runnig them into RPS, to view all the values are passing through correctly and identify any issues. Once i confirm everything is in order, i plan to run the code in RPS. Like we can debug .c# codes in vs, just like that. Hope i explained it well. What's my problem is.

    • @ErikFrits
      @ErikFrits  Рік тому

      I prefer debugging inside of Revit with pyRevit or RevitPythonShell.
      If you want to debug like in C# you would also need to use a lot of type hinting. I never really bothered looking for a way to debug in IDE.
      Often times I noticed mistakes due to things that depended on the Revit project itself.

  • @trevorbennett5324
    @trevorbennett5324 Рік тому +1

    How can you import the classes from the Electrical_Parts directory included with the API stubs? The argument you show here only seems to import the classes inside __init___parts.

    • @ErikFrits
      @ErikFrits  Рік тому

      There are seperate namespaces for different disciplines like Architecture, Structure, Electrical...
      If you look in RevitApiDocumentation, there is 'Autodesk.Revit.DB.Electrical Namespace'. So I guess you are trying to get classes from there.
      You can always look for the class you need in RevitAPIDocs and you will see which namespace contains them.
      try:
      from Autodesk.Revit.DB.Electrical import *
      Happy Coding!

    • @trevorbennett5324
      @trevorbennett5324 Рік тому +1

      @@ErikFrits Thank you. This was helpful but ultimately I got stuck at an API limitation. I wanted to create a new ElectricalSystemType so that I could calculate speaker loads on a low impedance power amplifier. Unfortunately the Revit API will not allow you to add new members to the ElectricalSystemType Enumeration. Not giving up yet... just trying to think of a way to make it work with the given system types. Thanks again!

    • @ErikFrits
      @ErikFrits  Рік тому

      ​@@trevorbennett5324 Can you create Electrical System Type manually in Revit?
      Normally enumerations are not meant to be modified. It's an object that is made to store predefined values.
      Have you tried using
      ElectricalSystem.Create method?
      www.revitapidocs.com/2023/b3ea7251-7230-ac0a-d5cc-0806b0c0ec1e.htm

  • @mykolavarvarchuk937
    @mykolavarvarchuk937 2 роки тому +1

    Thank you for your videos!

  • @danielsellam-kazoula9970
    @danielsellam-kazoula9970 2 роки тому +2

    Hi ! Thank for your videos ! Is it possible to make an other autocomplete but with pyRevit functions ?

    • @ErikFrits
      @ErikFrits  2 роки тому +2

      Hi, You are welcome!
      You are right, I should have mentioned pyrevit library in the video as well.
      Add path to your pyrevitlib in Interpreter's paths. Same as I did for RevitAPI in the video.
      In my case it's located here:
      C:\Users\ef\AppData\Roaming\pyRevit-Master\pyrevitlib
      Notice that 'ef' is my username in the computer.

    • @danielsellam-kazoula9970
      @danielsellam-kazoula9970 2 роки тому

      @@ErikFrits awesome !

  • @antoinelevert5394
    @antoinelevert5394 Рік тому +2

    Hi Erik, thank you very much for these videos, I am nevertheless blocked when I launch my new project, I have an error message which is displayed, "non-zero exit code (1)", and when I then go to the properties, project and python interpreter, I supposedly don't have a python interpreter, when I want to add one, I have the correct base interpreter, with python27, I don't understand, could you help me, thank you very much

    • @ErikFrits
      @ErikFrits  Рік тому +1

      What exact version of python did you install?
      I experienced some weird errors with pyCharm when I used 2.7.0, but Once I installed 2.7.18 (latest) then it worked fine. Maybe it's going to work for you as well if you get another python version and use it for your Virtual Environment.

    • @antoinelevert5394
      @antoinelevert5394 Рік тому +1

      @@ErikFrits Thank you very much for your answer, indeed by installing python 2.7.18 it works

  • @juanjosevillegas8237
    @juanjosevillegas8237 9 місяців тому +1

    The pycharm venv folder does not appear, I thought it came installed as part of pycharm, but I think it has to be activated externally, or am I wrong?

    • @ErikFrits
      @ErikFrits  8 місяців тому

      Hi, Do you mean venv folder after you created an interpreter?
      venv folder is created when you make your Virtual Environment (venv).
      It's a default name but in the tutorial I think I named it differently.
      Also I've heard that people had issues with pyCharm 2024 for making Revit API Coding environment. But once they downgraded to pyCharm 2023, they managed to make it work. Maybe this is part of your issue as well.

  • @Apsis0215
    @Apsis0215 Рік тому +2

    The PyCharm (PROFESSIONAL VERSION) interface has changed in the newer version - when adding a python interpreter, there is no gear icon , instead use the drop down arrow in pycharm 2023.1 and up.
    @eric- Has Eshan or anyone else gotten the updated stubs for Revit 22 23 24 in place?

    • @ErikFrits
      @ErikFrits  Рік тому

      That's true. I saw many people get confused when gear icon is not present but many people got an answer from comments.
      There is an extension in pyrevit something like pyRevit Dev. And there is a tool to generate stubs of current Revit version.
      It will generate folders with stubs, but I believe it will be missing __init__.py files. So you would need to create them in every folder yourself, and hopefully that works.
      To be honest I didn't bother updating stubs, I just use older version and when I get any errors I just go to docs and correct my code if there were any changes. But having correct stubs wouldn't hurt!
      Hope that helps.
      Happy Coding!

  • @SuradkarTushar
    @SuradkarTushar Рік тому +1

    Thank you for the detailed steps, and while everything seems to go fine + auto complete working, the line import clr shows an error, on running the script:
    \venv\stubs.min\clr.py", line 131
    def CompileModules(assemblyName,**kwArgs,p_str=None,p_object=None,*args): # real signature unknown; NOTE: unreliably restored from __doc__
    ^
    SyntaxError: invalid syntax

    • @ErikFrits
      @ErikFrits  Рік тому +1

      If you ran the script inside of pyCharm, that's fine. We aren't supposed to run scripts in pyCharm, it just helps us writing them.
      All Revit API scripts should be executed using Dynamo, pyRevit or RevitPythonShell, since they have proper environment setup for python and they can communicate with Revit Application.
      Let me know if you got that error from running the script in Revit.

  • @htt7897
    @htt7897 Рік тому +1

    Hello Erik. I need your help. Even i added Revit API (file Stubs.min) but when i test "from Autodesk.Revit.DB import *". it appeared "ModuleNotFoundError: No module named 'Autodesk'". could you help me this error

    • @ErikFrits
      @ErikFrits  Рік тому

      I assume you ran your script inside of pyCarm, right?
      We can only run these scripts from inside of revit using RevitPythonShell, pyRevit, Dynamo Python node...
      Because code need access to the app itself and also there are additional libraries added behind the scenes.

    • @htt7897
      @htt7897 Рік тому +1

      @@ErikFrits but the name "Autodesk" is always has re underline. hic

    • @ErikFrits
      @ErikFrits  Рік тому +1

      ​@@htt7897 Maybe you haven't referrenced the right folder for revit api stubs? Usually it should not be red and your Revit API autocomplete should work.
      1. If not then you need to check wheather autocomplete on built-in modules work.
      import os
      os.path.join

  • @gdmbre
    @gdmbre Місяць тому +1

    thank you so much!

  • @newshunhk
    @newshunhk 2 роки тому +2

    hi thanks for the video! I got warning on "from pyrevit import revit", can I ignore this?

    • @ErikFrits
      @ErikFrits  2 роки тому

      Did you get an error when you ran it inside of Revit?
      can you send the error message?

    • @newshunhk
      @newshunhk 2 роки тому +1

      @@ErikFrits same as your video @3:56, there is a red color underline under "pyrevit and "revit"

    • @newshunhk
      @newshunhk 2 роки тому +1

      Unresolved reference 'pyrevit'

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      ​@@newshunhk It is red because we haven't referenced pyRevit libraries for our interpreter.
      This code will not be executed inside of pyCharm. It's just so we can code with autocomplete and then we would load this script with pyRevit and run inside of Revit.
      To Add path to your pyrevitlib in Interpreter's paths. Same as I did for RevitAPI in the video.
      In my case it's located here:
      C:\Users\ef\AppData\Roaming\pyRevit-Master\pyrevitlib
      Notice that 'ef' is my username in the computer.
      Then it will recognize these functions and even provide you with documentation of them (CTRL + Q)

  • @AnasBarqawi
    @AnasBarqawi Рік тому +1

    Hey Erik your videos are really engaging and useful so thank you for the videos. I have a problem though that the Autodesk package is not installed apparently so the "from Autodesk.Revit.DB import *" command is not working for me. Can you help me fix this problem? I would be really grateful if you do.

    • @ErikFrits
      @ErikFrits  Рік тому

      Can you describe the problem?
      If you try to click 'run' in pyCharm it will tell you that Revit libraries are not installed. Because we can't run it from pyCharm, it's meant to run from revit via pyRevit/RevitPythonShell or Dynamo.
      Let me know if that clarification helped or you are facing another type of an issues.

    • @anasbarqawi2486
      @anasbarqawi2486 Рік тому

      ​@@ErikFrits the word Autodesk is underlined in red the first line which says from Autodes.Revit.DB import *. And the autocomplete is not working for me which is i assume because the module Autodesk is not installed. I tried installing it several times but the problem is still there.

    • @ErikFrits
      @ErikFrits  Рік тому

      ​ @Anas Barqawi You have written Autodes instead of Autodesk, is it typo just in a comment or you also have it in your code?
      Try running your code with Revit Python Shell to see if it works. As I've mentioned you can't run this code from pyCharm terminal. We can use pyCharm so it's easier to code and have some neat features, but then we either need to bring it in RevitPythonShell/Dynamo or create script.py file for our pyRevit extension and run it with a button.
      Let me know if it was misunderstanding.

  • @ShadowRin567
    @ShadowRin567 2 роки тому +2

    Hi Erik
    I have been following along with your videos but hit a dead end at 3:38. Under the settings when I go to interpreter I can’t see the settings icon, so I can’t paste the stubs path. Have you experienced this or have I just missed a step? Also great content that you are posting out there! :)

    • @ErikFrits
      @ErikFrits  2 роки тому

      Hi Kay,
      I have never experinced that.
      Could you send me a screenshot in LinkedIn messages or my email to check it. Maybe it will help.
      I assume you use pyCharm Community 2022, right?

    • @ShadowRin567
      @ShadowRin567 2 роки тому

      @@ErikFrits Hi Erik, thank you for the reply! I can send it to you over LinkedIn. Yes I’m using pycharm community :))

    • @ShadowRin567
      @ShadowRin567 2 роки тому +1

      @@ErikFrits I couldn’t send you a msg over LinkedIn Bc im don’t have a premium account so I’ll send a mail instead :)

    • @ErikFrits
      @ErikFrits  2 роки тому

      @@ShadowRin567 oh yeah. in LinkedIn you need to Connect for messaging...
      I have seen it, but it slipped my mind to check it once I got home.
      I will have a look now

  • @reingoedhart3508
    @reingoedhart3508 2 роки тому +1

    Hi Erik, is there a way to use packages such as numpy, pandas or matplotlib together with the revit api?

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      Hi Rein,
      It is possible, but I haven't tried it myself.
      Check this page in pyRevit Docs about CPython:
      www.notion.so/Create-Your-First-CPython-Command-b8a7718c554645d1a18454c0b363e3c9
      There is even an example that should work for numpy and pandas ;)

  • @zbyszekzbyszek5755
    @zbyszekzbyszek5755 2 роки тому +1

    Hello, can you do the same setup for Visual Studio Code?

    • @ErikFrits
      @ErikFrits  2 роки тому

      I don't use Visual Studio Code with python.
      But there is a guide I found in google. ;)
      www.macro4bim.com/post/vscode-intellisense-for-revit

  • @bimdan7825
    @bimdan7825 2 роки тому +1

    Dear Erik,
    It seems the PyCharm interface has changed since you made this video and I could not find out how to add autocompletion in the new interface.
    Could you please guide me on what to do?

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      Somebody has reached out with the same concern to me before.
      I think there was a button but it was sort of hidden.
      I would need to see screenshot of your pyCharm where you are stuck.
      Could you send me in LinkedIn (connect to write me) or by email? erikfrits95@gmail.com

    • @farsheedk2418
      @farsheedk2418 2 роки тому +1

      @@ErikFrits I just figured that there is a drop-down at the right corner of the interpreter’s box where we can find the Show all option.
      I managed to sort it out but thanks for the great stuff and getting back to me.

    • @ErikFrits
      @ErikFrits  2 роки тому +1

      Great! I did suspect that button just moved or looks a little different, but definitely not gone :)
      ⌨ Happy Coding!

  • @bogdanpopa2978
    @bogdanpopa2978 Рік тому +1

    I've followed the procedure for Revit 2024, PyCharm 2023.1 (Community Edition), pyRevit_4.8.12.22247, Python 3.11 (64bit), IronPython 3.4.0 - All latest versions . I can't set up the virtual environment, nor the interpreter is not loading. When attempting I get the following message: ImportError: Module use of python39.dll conflicts with this version of Python.- Note: I have unistalled everything before and ran a deep lean. Still... I get the same issue as my first attempt with the same setting and Revit 2023.

    • @ErikFrits
      @ErikFrits  Рік тому

      Sorry, Your message was stuck in 'Held for review'.
      pyCharm is weird with some python versions for some reason. I have experienced issues with some versions. What I noticed is that certain versions never fail me, while others consistently refuse to create a venv.
      Try using 2.7.18 python version.
      pyRevit/RevitPythonShell will use its own interpreter with IronPython when you run your scripts, so it's not that important to setup pyCharm with correct version. We just need to use python in pyCharm, so it's better for us to code with Autocomplete and many other features IDE offers us.
      P.S. When you create your Virtual Environment (venv), you can select your python version. Maybe it has remembered path to python 3.9 which you deleted and is trying to use it for creating new venv.

  • @عينالصقر-ذ6غ
    @عينالصقر-ذ6غ 2 роки тому +1

    Hello dear:
    Pycharm autocompletion code suggestion is not work , are you know how i resolve it ,
    Thank you too much

    • @ErikFrits
      @ErikFrits  2 роки тому

      Try checking if Autocomplete works on python built-in functions. e.g.
      import os
      os.p

  • @dirkvanrijckeghem7289
    @dirkvanrijckeghem7289 2 роки тому +1

    Hi Erik,
    Thanks for the instructions for this to run, but I'm running into a problem :
    - first my installation : running W10 in bootcamp on MacbookPro - generally good setup (albeit with too small a partition for windows - all project files go on external fast SSD)
    - I installed Python 2.7.18 and Pycharm 2022.2.4 community edition
    - Everything works but from Autodesk.Revit.DB import * doesn't work
    - I've added the pyrevitlib - path to the interpreters paths and then I get the autocomplete working fine but running it, gives me these traceback errors:
    E:\BIMvR\CODING\dvr_uitbreiding\RevitApi\testproject\Scripts\python.exe E:\BIMvR\CODING\dvr_dev\pythonProject\main.py
    Traceback (most recent call last):
    File "E:\BIMvR\CODING\dvr_dev\pythonProject\main.py", line 3, in
    from pyrevit import revit
    File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\__init__.py", line 21, in
    import clr #pylint: disable=E0401
    File "E:\BIMvR\CODING\dvr_uitbreiding\RevitApi\testproject\stubs.min\clr.py", line 26
    def accepts(*types,p_object=None): # real signature unknown; restored from __doc__
    ^
    SyntaxError: invalid syntax
    Process finished with exit code 1
    Any idea's ?
    Thanks

    • @ErikFrits
      @ErikFrits  2 роки тому

      Did you run this script inside of pyCharm or actually in Revit?
      Based on the error message I get a feeling that you clicked run inside of pyCharm and this will not work, because we need Revit modules to work properly and pyRevit takes care of a lot of things to make it easy for us to create python add-ins.
      I create this virtual environment to have Autocomplete in PyCharm so it's easier to code, but to run any code using Revit API we need to run it with:
      - pyRevit or
      - Revit Python Shell or
      - Python Node in Dynamo or
      - Grasshopper with RhinoInsideRevit
      There is an option to use pyRevit cli to make executable file outside of Revit, but I made some test half year ago and barely remember what I did. But it was possible!
      Hope that helps ;)

  • @feri4life177
    @feri4life177 2 роки тому +1

    Nice

  • @JonahHawk
    @JonahHawk Рік тому +1

    One more path for autocomplete of pyrevit, pyrevit.forms, pyrevit.revit, etc.
    C:\Users\YOUR_USER_FOLDER\AppData\Roaming\pyRevit-master\pyrevitlib
    This is in the installed folder from PyRevit. If for some reason your PyRevit installation is elsewhere, choose that location.

    • @trevorbennett5324
      @trevorbennett5324 Рік тому +1

      Thank you! This was messing me up... I went one folder down to "pyrevit" and it was broke good...

    • @ErikFrits
      @ErikFrits  Рік тому

      Exactly! Thanks for sharing in the comments.
      I have forgotten to cover it in this video but I included it in the updated version of this video (coming soon).

    • @tiagomarinhovalverde3916
      @tiagomarinhovalverde3916 Рік тому +1

      Muito obrigado.. Depois de várias tentativas conseguir com esse caminho.. pyRevit-master

    • @ErikFrits
      @ErikFrits  Рік тому

      @@tiagomarinhovalverde3916
      Fico contente em ajudar!

  • @thais3268
    @thais3268 Рік тому

    my code didn't work, error appears in all lines of code and I can't find this ''filtered'' on line 6.

    • @ErikFrits
      @ErikFrits  Рік тому

      You mean Autocomplete? Try writing it with capital F - FilteredElementCollector...
      If not working:
      1. check if regular autocomplete works with os module
      import os
      os.path.join....
      2. If regular autocomplete works but Revit API not, then there is a good chance that you have provided wrong path to revit api stubs folder. Try to verify that

    • @thais3268
      @thais3268 Рік тому +1

      @@ErikFrits Ok thanks, I'm trying again but without success :/

    • @ErikFrits
      @ErikFrits  Рік тому

      ​@@thais3268 Can you describe where you stuck? I am sort of guessing, but maybe if I get more context I can help better. If you have any error codes, they are also really helpful!
      1. Is the problem with running the code or writing (autocomplete)?
      2. If Running: Many people try to run scripts from pyCharm but that will always give an error, because we can only run scripts inside of Revit with pyRevit, RevitPythonShell, Dynamo, RhinoInsideRevit...
      3. Does your Autocomplete work for os module? If not then you python interpreter might be corrupted or wrong. Maybe it's worth creating a new one.
      If none of above useful, please provide more context ;)

  • @Snoop_haha
    @Snoop_haha 2 роки тому

    Helo, Erik. I Have a problem
    C:\Users\User\PycharmProjects\RevitAPI99\Scripts\python.exe C:\Users\User\PycharmProjects\pythonProject\pezet\main.py
    File "C:\Users\User\PycharmProjects\pythonProject\pezet\main.py", line 1
    from Autodesk.Revit.DB import
    ^
    SyntaxError: invalid syntax
    Process finished with exit code 1
    Any ideas?

    • @ErikFrits
      @ErikFrits  2 роки тому

      These Revit script will not work from pyCharm.
      We have created Autocomplete in pyCharm so it's easier for us to write Revit API scripts, but they have to be executed using pyRevit, Revit Python Shell or Python Node in Dynamo. These plugins have all necessary libraries and resources loaded in, so we can actually load all the classes and make our tools work.
      I should have mentioned that in the video.

  • @theartofscantobim
    @theartofscantobim Рік тому +1

    Hi, I need help...!!! this python v is killing me. I keep having the same error "Unused import statement 'from Autodesk.Revit.DB import *':1" I installed the 3.10 and I can not find interpreter path. I have uninstalled the 3.10 and reinstalled the 2.7.16 I had error, and then 2.7.17 and I keep the "unused import.." error.

    • @ErikFrits
      @ErikFrits  Рік тому +1

      I would try using 2.7.18 python, I used to get errors on creating virtual environment on some other versions of python, but this seems to work well. If you can create Virtual Environment and add revit api stubs, then I don't think it's a problem.
      Remember we use pyCharm as a helping tool to write code, but it gets executed from inside of Revit.
      Do you get this error when you run your script with pyRevit/RevitPythonShell or you try to run inside of pyCharm?
      After googling a little i saw statement like this: "You're not able to find the interpreter path. This problem can occur when PyCharm can't locate your Python interpreter. " Could that be an issue?
      I need more context to try to figure out what's going on.

    • @theartofscantobim
      @theartofscantobim Рік тому

      I have just run in pycharm trying to add the stud library, the virual environment is working the problem is that don't work Revit API Autocomplete.
      "C:\Users\gresa\PycharmProjects\RevitAPI2\Scripts\python.exe C:\Users\gresa\PycharmProjects\the-art-of-scantoBIM\main.py
      Traceback (most recent call last):
      File "C:\Users\gresa\PycharmProjects\the-art-of-scantoBIM\main.py", line 1, in
      from Autodesk.Revit.DB import *
      File "C:\Users\gresa\PycharmProjects\RevitAPI2\stubs.min\Autodesk\Revit\DB\__init__.py", line 10, in
      from __init___parts.BaseExportOptions import BaseExportOptions
      File "C:\Users\gresa\PycharmProjects\RevitAPI2\stubs.min\Autodesk\Revit\DB\__init___parts\BaseExportOptions.py", line 1, in
      class BaseExportOptions(object,IDisposable):
      NameError: name 'IDisposable' is not defined"
      Thanks mate for your help

    • @ErikFrits
      @ErikFrits  Рік тому

      ​@@theartofscantobim got it.
      So the problem is that we can't use Autodesk libraries from pyCharm.
      pyCharm is used only as a helping tool to write code (Think of it as a notepad on steroids), but code has to be executed inside of Revit via pyRevit, RevitPythonShell or Dynamo. I should have communicated that better.
      So whenever you will try to run any Revit API code in pyCharm you will always get a bunch of errors, because it does not know where these libraries are. And even if it did, it won't be able to get an instance of Revit Application.
      If Autocomplete doesn't work:
      1. Test if other libraries work, like os.
      import os
      os.path.join...

  • @qsbim
    @qsbim Рік тому +1

    i don't see pyrevit modle in pycham to import. Please help me

    • @ErikFrits
      @ErikFrits  Рік тому +1

      We need to add a reference to pyRevit lib folder separately from Revit API stubs. I forgot to show it in this video (I will upload updated in a few weeks)
      It's usually located in
      C:\Users\USER_NAME\AppData\Roaming\pyRevit-Master\pyrevitlib
      You can also access it with this folder path syntax:
      %appdata%\pyRevit-Master\pyrevitlib
      Try adding it same as we did for Revit API Stubs, and it should work
      Let me know if that helps.
      Happy Coding!