pyRevit Guide: Create your first Extension for Autodesk Revit [RevitAPI + python]

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ก.ย. 2024

ความคิดเห็น • 63

  • @smitbangare9526
    @smitbangare9526 6 วันที่ผ่านมา +1

    9:30 for "Lib" folder autocomplete in VS Code, add your folder location in "python.analysis.extraPaths" & "python.autoComplete.extraPaths".

    • @ErikFrits
      @ErikFrits  6 วันที่ผ่านมา +2

      That's right! I will mention it in the reuse code lesson (new is coming out soon).
      Also for pyCharm users you can just right click on the lib folder -> Mark Directory As -> Source Root.
      Then pyCharm will look inside and give you autocomplete as well. VS Code might also have something similar to mark lib folder like that.

  • @nitishsharma4832
    @nitishsharma4832 2 ปีที่แล้ว +3

    Thank you for such a high quality tutorial

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว +1

      You are very welcome!
      I am really glad you are finding lots of value in these tutorials!

  • @alipakdel7497
    @alipakdel7497 ปีที่แล้ว +2

    Erik this is awesome. Thanks for your tutorials. This is what I really need.

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว +1

      💟 Thank you!
      Happy to help!

    • @alipakdel7497
      @alipakdel7497 ปีที่แล้ว +1

      @@ErikFrits keep up the good work!

  • @que_ash
    @que_ash ปีที่แล้ว +3

    idk the bundle.yaml thing is not working for me even after restart, all others working fine

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      Maybe it's the syntax inside of bundle.yaml file?
      You can compare your syntax with mine on GitHub. Could be that spacing is also important.
      Here is my Bundle.
      github.com/ErikFrits/EF-Tutor/blob/main/EF-Tutor.tab/bundle.yaml

  • @iaconst4.0
    @iaconst4.0 4 หลายเดือนก่อน +1

    GRACIAS HERMANO!, POR COMPARTIR TU CONOCIMIENTO!

    • @ErikFrits
      @ErikFrits  4 หลายเดือนก่อน

      Happy to help ;)

  • @mahmoudfawzy8354
    @mahmoudfawzy8354 ปีที่แล้ว +2

    Simple and powerful

  • @javierperezmarin4121
    @javierperezmarin4121 ปีที่แล้ว +1

    Thanks for the videos! Looking forward to see that course that you are preparing!! This is a good start to get an overall idea of how this Revit API world looks like.
    One question regarding what pycharm automatically creates when you divide empty doc string with newline (min 08:10). What exactly do you do? I am not able get the same as you. What do you click?
    By the way, is it normal to not understand the logic on the scripts, right? 😅I am a 100% beginner with this.
    Many thanks again!

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว +1

      Thanks Javier!
      I simply clicked on Enter, and pyCharm has filled in the rest. I noticed that sometimes it doesn't work, but that might be due to Dev Environment (set up Python Interpreter).
      That's fine, you are just starting. These videos are more about setting up your development environment. I also have other videos that explain you everything that I code so you slowly get comfortable with it. After a while you realize that we use the same code for getting elements, modifying parameters and creating elements. But first time we see it, it looks scary, especially if you are new to programming.
      Give it some time! We all start somewhere.
      Happy Coding!

  • @mohamedanany3832
    @mohamedanany3832 ปีที่แล้ว +1

    Thanks for sharing such that amazing tutorials 🙏 keep going bro 👌

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      Happy to help!

  • @srenvilladsen9294
    @srenvilladsen9294 2 ปีที่แล้ว +2

    Great video ;) thank you

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว

      Thanks, glad to help ;)

  • @antoinelevert5394
    @antoinelevert5394 ปีที่แล้ว +1

    hi, thanks again for his videos
    I carefully followed all your steps, only I block at the end, at 10min, I have this error code: "'Selection' object has no attribute 'GetElementsIds'", I think he can't do it linking with the Revit library, because in Pycharm I also have type errors: "Unresolved reference 'Autodesk'", "Unresolved reference '__revit__'". What is the method to link our pycharm to the Revit library, I hope I was clear enough, thanks again for your help

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      You have misspelled the name of the method.
      It should be 'GetElementIds' instead of GetElementsIds. (word Element is single not plural)
      Regarding pyCharm, you are not supposed to click on Run button in pyCharm because it's not connected to revit and missing libraries, it's okay.
      We use pyCharm to make the process of writing code better, think of it as NotePad with steroids.
      And we have to execute our scripts from Revit via Dynamo, pyRevit or RevitPythonShell.
      Happy Coding!

  • @luqmanghani8047
    @luqmanghani8047 3 หลายเดือนก่อน +1

    Hi Eric ! Thanks for the tutorial ! im facing a problem where my icon not shown in the revit. the button work perfectly fine but didnt show the icon. How to fix that?

    • @ErikFrits
      @ErikFrits  2 หลายเดือนก่อน

      Hmm that's strange. Probably there was a mistake somewhere.
      1. Is it named 'icon.png' ?
      2. Is the size less than 96x96 px?
      3. Have you reloaded pyRevit ?

    • @luqmanghani8047
      @luqmanghani8047 2 หลายเดือนก่อน +1

      @@ErikFrits Found it ! i rename the file as 'icon' with no '.png' at the back. Cause the file are already in PNG format. Thank you for your help Erik

    • @ErikFrits
      @ErikFrits  2 หลายเดือนก่อน

      @@luqmanghani8047 Ah so you had file extensions hidden by default.
      Glad we found the solution ;)

  • @ayseguleyi9173
    @ayseguleyi9173 3 หลายเดือนก่อน

    Thank you for the great videos!

    • @ErikFrits
      @ErikFrits  2 หลายเดือนก่อน

      Glad you found them useful!
      Happy Coding!

  • @rahmaadel5763
    @rahmaadel5763 หลายเดือนก่อน +1

    I have a problem when writhing uidoc= __revit__ActiveUI Document in (script file) it gives me unresolved reference ... how can I fix that please?

    • @ErikFrits
      @ErikFrits  หลายเดือนก่อน

      That's okay.
      It will still execute correctly in Revit.
      The error just means that your IDE (pyCharm/VSCode) doesn't know about __revit__, and therefore it mentions that it's unresolved.
      In pyRevit's engine it will have access to such variable, and it will work correctly.

    • @rahmaadel5763
      @rahmaadel5763 หลายเดือนก่อน

      @@ErikFrits It didn't work actually it (when I click on the tab in revit it gives an error!!

  • @FelanaDiamondraRANDRIAMADISON
    @FelanaDiamondraRANDRIAMADISON ปีที่แล้ว +1

    Hey, can you give me help, I want to deploy a Revit extension and install it on user machines but I don't have idea on how to do it

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      Ideally you would want to host your extension on GitHub and then install it to other users via pyRevit Extensions menu. There is an option for private repo as well, but users will need to know GitHub Username and Password to use that.
      I have a video about hosting it on GitHub but it's a little dated.
      Also for Password you would need to create Access-Token on GitHub Settings. it's easy to do. For some reason pyRevit can't use Login and Password of the GitHub account for that. Probably GitHub's decision for security reasons.

  • @debbiketchum3047
    @debbiketchum3047 ปีที่แล้ว +1

    I am having trouble getting pyCharm to autofill the Snippets function. I added the file path to the Interpreters but it isn't working. The screen resolution is rather fuzzy so I am not able to tell if I have done it right. P.S. I am a Python "newbie" and these videos are great!

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      Yeah sorry for fuzzy screen, I improved it since.
      You need to add path to your lib folder in interpreter settings for custom lib autocomplete.
      Also inside lib folder you need to create __init__.py files, so python treats it as a package and actually can read and import files, functions and other stuff...
      Hope it helps, if not, describe the problem in more detail and I will do my best ;)

  • @rickypei7950
    @rickypei7950 ปีที่แล้ว +1

    Hi, Mr. Erik, I follow your operations step by step, no button shown on Revit. Do you know what's the problem?

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว +1

      So there are a few things to check:
      1. Is your folder structure correct? check all folder ending like .extension, .tab, .panel, .pushbutton
      2. Did you refference correct folder in pyRevit settings? You should point to the folder where .extension is located. Not .extension folder itself!
      You can download my EF-Tutor extension from GitHub and add it to pyRevit to have an example of how it should look. Then you can just start renaming and replacing my buttons with yours. Then you will find where you did something wrong.

  • @daveotis7016
    @daveotis7016 2 ปีที่แล้ว +2

    Great video!
    Can wait for the next one! Question about reloading pyRevit. Do you need any "admin" permission to reload? Just to make sure because if i became a pro like you, i will share my tools up to 200 team members! Thanks.

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว +1

      Thanks,
      Usually you don't need admin rights for reloading. Maybe if your extension is located in a folder with restricted access then it might need it, but I highly doubt it.

  • @sanderdeweert9522
    @sanderdeweert9522 ปีที่แล้ว +1

    Hi! Thanks for your video's! I'm using Revit 2023. I tried every step of your video, but keep getting stuck on the import of the custom snippets. I tried to use the reload button, added the project folder as a custom directory. After running the script it keeps giving back "ImportError: No module named Snippets._selection". Do you know what I might do wrong?

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      I would need to see your folder structure to understand where the issues comes from.
      Have a look at my library folder in EF-Tools and compare what you might be missing
      github.com/ErikFrits/EF-Tools/tree/main/lib
      You would need lib folder in the root directory of your extension with a folder structure like below.
      Don't forget __init__.py files. You can keep them empty, they are needed so python recognizes these folders as a package, then it will allow importing from them.
      /lib
      - __init__.py
      - /Snippets
      - __init__.py
      - _selection.py

    • @sanderdeweert9522
      @sanderdeweert9522 ปีที่แล้ว

      @@ErikFrits Thanks for your response. The name of the lib folder was differtent. I changed it, but it still gives the error. I just invited you as a collaberator to the project in Github.

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว +1

      @@sanderdeweert9522 Oops, I've just declined it before I saw your comment...
      Can you resend invite

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      I looked in your GitHub. It looks correct to me...
      Have you tried reloading pyRevit after you created lib folder?
      Every time we update anything in lib folder, we need to reload pyRevit so lib changes apply. pyRevit store it in cache otherwise after you use it once.

    • @sanderdeweert9522
      @sanderdeweert9522 ปีที่แล้ว

      @@ErikFrits Yeah, I reloaded it multiple times en tried everything. Maybe it has something to do with the Revit Version?
      I get the same error if I want to import pandas, to work with Excel Data.
      After reloading, I get the error below (i changed "user" in the path):
      IronPython Traceback:
      Traceback (most recent call last):
      File "C:\Users\user\AppData\Roaming\pyRevit-Master\extensions\pyRevitCore.extension\pyRevit.tab\pyRevit.panel\tools.stack\Reload.pushbutton\script.py", line 32, in
      File "C:\Users\user\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\loader\sessionmgr.py", line 327, in reload_pyrevit
      File "C:\Users\user\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\loader\sessionmgr.py", line 285, in load_session
      File "C:\Users\user\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\loader\sessionmgr.py", line 105, in _perform_onsessionloadstart_ops
      File "C:\Users\user\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\loader\sessionmgr.py", line 57, in _clear_running_engines
      StandardError: Exception has been thrown by the target of an invocation.
      Script Executor Traceback:
      System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      --- End of inner exception stack trace ---
      at Microsoft.Scripting.Runtime.LightExceptions.ThrowException(LightException lightEx)
      at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value)
      at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
      at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
      at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
      at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
      at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
      at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
      at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
      at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
      at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
      at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
      at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)

  • @AlekseyShapovalov
    @AlekseyShapovalov ปีที่แล้ว +1

    День добрый! Спасибо за замечательный материал! Уроки очень полезные и качественные! Хотел спросить , будет ли возможность осветить способы блокировки некоторых стандартных функций Revit? В одном из роликов видел, пример выдачи окошка об ошибке, при нажатии на одну из кнопок. Хочу узнать сам принцип реализации, понять куда копать. Цель - защитить модели от создания лишних Уровней, убрать возможность Импорта DWG и т.д.. Порой можно подобное реализовать строгим соблюдением BIM-стандарта, но зачастую это не помогает. Видел на просторах ютуба вариант, где заблокирована даже возможность пересохранять модель как хранилище. Буду благодарен за подсказку!

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว

      Спасибо!
      I hope you don't mind English, It's much quicker for me to reply.
      So you want to use Events in Revit API!
      There are a bunch of them and they allow us to make an action when certain things happens (View opened, model saved, Doc changed...)
      RevitAPI Docs Events - www.revitapidocs.com/2015/54d437bf-87bb-1ba5-9357-8989c3da5ca7.htm (That's not all!)
      In pyRevit they are called hooks and they are a simpler way to create Event Handlers. Unfortunately I keep getting an error on doc-updater.py for the latest pyRevit version so I haven't experimented much with them. That's the hook that allows you to make changes to a model easily. There are many others that you can have a look in pyRevit Dev Docs.
      pyRevit Docs - Create First Hook: www.notion.so/Create-Your-First-Hook-0214eee855fc43cead1e6f30f586a04e
      1 Important thing to notice that many of these hooks are Read-Only, which means we can make an action, as long as it does not try to make changes in Revit.
      If you want to make changes then you need to create an IUpdater, it's a special class that allows to subscribe to such events and make a change to the model.
      The topic is not an easy one, and you should think a lot about performance, because you don't want to make an event handler that will make it twice as slow to work on the model, so try to be very efficient with them.
      Here are my 2 cents about hooks ;)
      Hope it guides you in the right direction

    • @AlekseyShapovalov
      @AlekseyShapovalov ปีที่แล้ว +1

      @@ErikFrits Thanks a lot for the quick and detailed answer! I wish you further development of the channel, it really helps! 💎

  • @MohamedSabith-wl1ii
    @MohamedSabith-wl1ii ปีที่แล้ว +1

  • @marceloromero8896
    @marceloromero8896 2 ปีที่แล้ว +1

    ⌨ 👌

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว +1

      Hey, Well done 💪

    • @marceloromero8896
      @marceloromero8896 2 ปีที่แล้ว +1

      @@ErikFrits Thanks a lot for the good quality content, Erik!

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว

      It's my pleasure!

  • @jmco1045
    @jmco1045 2 ปีที่แล้ว +2

    :)

  • @husamaljawhar4800
    @husamaljawhar4800 ปีที่แล้ว +1

    I did it, thanks man

    • @ErikFrits
      @ErikFrits  ปีที่แล้ว +1

      Well done! It's just the beginning
      Happy Coding!

  • @aviodenheimer4090
    @aviodenheimer4090 ปีที่แล้ว +1

  • @metalmonster86
    @metalmonster86 2 ปีที่แล้ว +2

    • @ErikFrits
      @ErikFrits  2 ปีที่แล้ว

      Thanks for watching the whole thing

  • @christophermarrinan5966
    @christophermarrinan5966 ปีที่แล้ว +1