How To Get Elements in Revit API with FilteredElementCollector

Sdílet
Vložit
  • čas přidán 9. 09. 2024

Komentáře • 55

  • @ErikFrits
    @ErikFrits  Před 2 lety +2

    📘 Get your FilteredElementCollector Guide:
    ko-fi.com/s/14b0b8e31c

  • @harley9015
    @harley9015 Před 2 lety +2

    Love the explanation and how you delved a bit further into the API for things that aren't just on the surface like others do. Also thank you for touching on filters, it's definitely a broad topic but another perspective is always informative.

    • @ErikFrits
      @ErikFrits  Před 2 lety +1

      Thank you!
      I will eventually cover filters in more depth, but for now you can check my guide for FEC and Filters with examples and explanation if you want to learn more about them.

  • @mahmoudfawzy8354
    @mahmoudfawzy8354 Před rokem +1

    Easy, simple, powerful💪

  • @zeinabmostafa5068
    @zeinabmostafa5068 Před 7 měsíci +1

    Yes, please It would be Great if you create a video for filters Like BoundingBoxIntersectsFilter

    • @ErikFrits
      @ErikFrits  Před 7 měsíci

      I might write a newsletter episode about that one 😉

  • @jedsanford7879
    @jedsanford7879 Před rokem +1

    This is super helpful! I went and made some collector functions based on this code and added them to my lib file I started. But you gotta let me know how to put a list in multiple lines like that when you are making you category list.

    • @ErikFrits
      @ErikFrits  Před rokem +1

      Thanks, I hope I understood your question right. It has been a while since I made the video.
      1️⃣In python if we break a line and leave '\' in the end, then python reads next line as part of the current line.
      e.g.
      FilteredElementCollector(doc).OfClass(Wall).ToElements()
      FilteredElementCollector(doc) \ 👈
      .OfClass(Wall) \ 👈
      .ToElements()
      Usually IDE(at least pyCharm) adds this automatically when you break the line.
      2️⃣ However, if you meant lists, then we don't need this sign because lists are covered with square brackets on both sides, and python knows. There you are free to break it into multiple lines. Just keep track of commas.
      e.g.
      [1,2,3,4,5,6]
      [1,
      2,3,
      4,
      5,
      6]
      I hope I answered your question. If not feel free to expand your question on that.
      Happy Coding!

    • @jedsanford7879
      @jedsanford7879 Před rokem +1

      @@ErikFrits yup you understood it perfect! thanks for the reply. Those lists look so neat when you break lines like that

  • @pfaria
    @pfaria Před 2 lety +1

    Great video like always. Thank you.

  • @tomaszwisniewski319
    @tomaszwisniewski319 Před rokem +1

    Great video, if you could make one's about filters it would be perfect, thank you Erik

    • @ErikFrits
      @ErikFrits  Před rokem

      Thanks!
      I have plans for it, but at the moment I need to cross many other things from the to-do list ;)

  • @feri4life177
    @feri4life177 Před 2 lety +1

    Great

  • @melatubino
    @melatubino Před rokem +1

    Hi! I just bought the guide, and I find it amazing. When are you going to update it? I use Revit 2023. Thanks!

    • @ErikFrits
      @ErikFrits  Před rokem

      Glad you liked it!
      Unfortunately, I have no time for that at the moment. But I will have a phase when I will write more guides and update this one along the way as well.
      P.S. If anyone know nice E-Book online writer let me know. I need something that supports code snippets, so it's not images but an actual text that can be copied.
      So far I think I might do it in Figma due to higher customizability, but that's not the final decision.

    • @ummarkhan561
      @ummarkhan561 Před 8 měsíci

      Which Guide it is?

  • @mitchelloatman
    @mitchelloatman Před 2 lety +1

    Yes, please make a video for filters

    • @ErikFrits
      @ErikFrits  Před 2 lety

      Is there any specific filter you are interested in or just in general?

    • @mitchelloatman
      @mitchelloatman Před 2 lety

      @@ErikFrits just in general.

    • @mitchelloatman
      @mitchelloatman Před 2 lety

      What I really need is to understand how to pass a list or filtered elements into a dialog like the PyRevit "Select From List (Single, Multiple)" dialog.
      Would also like a video on how you make the dialogs for your EF Tools commands.

    • @ErikFrits
      @ErikFrits  Před 2 lety

      Noted.
      I have a video in mind for pyRevit input forms, but I am quite busy with many other video ideas for now, hopefully get to that one in a few months.
      I create my GUI with WPF, and it's quite advanced from my opinion. I will eventually try to make some tutorials on the topic, but I will leave it for the end, I try to focus on more basic concepts for now.

  • @anthonyugbewi8109
    @anthonyugbewi8109 Před rokem +1

    Beautiful and smooth video… is there a discord community for pyrevit ? I ll love to join one, if no , do you mind to create one

    • @ErikFrits
      @ErikFrits  Před rokem

      Thanks, Appreciate that!
      Currently I am at the capacity. I wanted to make a small community as well, but then I realized I wouldn't have any time for that.
      There is an online pyRevit forum which is quite active.
      discourse.pyrevitlabs.io/

  • @cobyiv
    @cobyiv Před 2 lety +2

    I have been struggling with selecting elements in a given view that is both in the current model and in linked models. Does the filter element collector work for linked models as well?

    • @ErikFrits
      @ErikFrits  Před 2 lety +1

      Usually, we need to provide doc variable of the project we want to get our elements.
      if you want to get Linked elements, then you need to find and pass doc from linked model.
      I am not sure if we can provide linked model and then provide a view from another project. I believe there should be a way to achieve that but I haven't tried to get it like this yet.

    • @cobyiv
      @cobyiv Před 2 lety +1

      @@ErikFrits much appreciate response! I am interested in programmatic approach to grab elements from current doc and all visible linked elements as well…perhaps a topic of a future video if you ever are able to crack the code ;) 🙏

  • @brunoCarneiroDis
    @brunoCarneiroDis Před 5 měsíci +1

    Hi, erik!
    i have seen your tutorial and by the way i have learned a lot, thanks!
    i have had some difficulties to understand the VARIABLES and i did not understand when you used active_view = doc.ActiveView. Do you know where i can learn more about it?

    • @ErikFrits
      @ErikFrits  Před 5 měsíci +1

      You might need to check some python basics course. CS50 Introduction to Python by Harvard is a popular free course on edx.org platform.
      I would recommend start there

    • @brunoCarneiroDis
      @brunoCarneiroDis Před 5 měsíci

      @@ErikFrits Thank you, Erik

  • @jacr2020
    @jacr2020 Před rokem

    Great video. I have a question. How to set a value parameter from a host to elements that it contains? For example, from a beam to rebars. Thank you.

    • @ErikFrits
      @ErikFrits  Před rokem

      I haven't worked with rebars in Revit API, but usually there is a property 'Host' that returns an element. Have a look inside of Revit Lookup
      For example:
      if I have a variable window. I can get its wall something like this:
      wall = window.Host
      Or if you have a list of windows and you need a list of hosts:
      walls = [window.Host for window in all_windows]
      If you new to parameters in Revit API, I have another video which will show you all you need to read and set parameters ;)

  • @WietseStarsz
    @WietseStarsz Před rokem +1

    Hey Erik, I really learned a lot from your videos! I am really stuck at the moment with using a doc-changed hook, it seems to be impossible to use transactions with it (edit a parameter). Maybe you have some knowledge about this?

    • @ErikFrits
      @ErikFrits  Před rokem +1

      Hi Wietse, Happy to help!
      Can you share an example of what you have tried so far? It will be easier to point to an issue with the code.

    • @WietseStarsz
      @WietseStarsz Před rokem +1

      @@ErikFrits Thank you! There seems to be an issue where my comment keeps getting deleted whenever I send a link to a gist with the code... Is there any other way I can send this to you?

    • @ErikFrits
      @ErikFrits  Před rokem

      That could happen for sure!. CZcams comment moderation system is weird, because it does not even let mee see them to approve or disapprove...
      Reach out to me in LinkedIn.

  • @smitbangare9526
    @smitbangare9526 Před 11 měsíci +1

    Hello, I am not getting OST_Walls on my autocomplete. Can you tell the reason?

    • @ErikFrits
      @ErikFrits  Před 11 měsíci

      Do you get other Revit API Autocomplete suggestions?
      If No, did you add Revit API stubs in your virtual environment in pyCharm? I have a video on adding Revit API Autocomplete in pyCharm for that.

  • @giancarloarciniegas8466
    @giancarloarciniegas8466 Před 2 lety +1

    Hello i would like to know if there is a way to install my plugin in a .exe file or a .msi file and not have to install pyrevit to add the extensions.
    thank you very much for everything.

    • @ErikFrits
      @ErikFrits  Před 2 lety

      python is not supported in Revit by default.
      you need pyRevit or RevitPythonShell to run python scripts,
      therefore you need pyRevit to have EF-Tools extension.

    • @giancarloarciniegas8466
      @giancarloarciniegas8466 Před 2 lety

      @@ErikFrits For example once I have made my own extension, then I could not create an .exe or .msi file type?
      Isn't there a way to do this?
      (move from python to C# language)

    • @ErikFrits
      @ErikFrits  Před 2 lety

      ​@@giancarloarciniegas8466 you can definitely make this with C#, but with python I don't think there is a ready solutions for that.
      You would need to create some custom plugin to display and run your python scripts in revit. You probably can use RevitPythonShell or pyRevit as a base and build on top of it something custom. Not an easy. Try searching in Google, maybe someone has solved this problem already and shared solution.

  • @facelessone86
    @facelessone86 Před měsícem +1

    Is there any way to get this to work with a CAD link? I'm trying to get text from it.

    • @ErikFrits
      @ErikFrits  Před měsícem +1

      No, FilteredElementCollecotr won't help with that.
      I haven't tried to read the layers from a CAD link yet, but that's an interesting topic

    • @facelessone86
      @facelessone86 Před měsícem

      @ErikFrits based on what I did so far with linework it looks like it's possible to get everything I need for linework with importinstance. There is nothing for text however. I started implementing what it looks like everyone else does, export to dxf and read that file for text info.

  • @FelanaDiamondraRANDRIAMADISON

    Hey! i am new to revit api .. how to get all elements objects in revit? without filter

    • @ErikFrits
      @ErikFrits  Před rokem +1

      FilteredElementCollector is probably the easiest approach. Try this:
      all_instances = FilteredElementCollector(doc).WhereElementIsNotElementType().ToElements()

    • @FelanaDiamondraRANDRIAMADISON
      @FelanaDiamondraRANDRIAMADISON Před rokem +1

      @@ErikFrits Thanks 😉

    • @FelanaDiamondraRANDRIAMADISON
      @FelanaDiamondraRANDRIAMADISON Před rokem +1

      Hey@@ErikFrits , I'm here again. Is there a way to retrieve all structural and architectural elements, or do I have to specify all the structural and architectural categories and use the FilteredElementCollector method?

    • @ErikFrits
      @ErikFrits  Před rokem

      @@FelanaDiamondraRANDRIAMADISON
      You still need to use FilteredElementCollector. You can use .OfClass or OfCategory to get desired elements.
      If you decide to use OfClass, be aware that certain classes are located in discipline namespaces like Autodesk.Revit.DB.Architecture, Autodesk.Revit.DB.Structure and others.

  • @martinelko9
    @martinelko9 Před 11 měsíci

    I cannot join your newsletter without typing password

    • @ErikFrits
      @ErikFrits  Před 11 měsíci

      Try this:
      temp.learnrevitapi.com/
      Sorry I am remaking my main website for the course and I took my main domain right away to simplify it

    • @martinelko9
      @martinelko9 Před 11 měsíci +1

      many thanks @@ErikFrits