Python for Revit: Basics of collecting data from Revit database

  Рет қаралды 53,687

pyRevit

pyRevit

Күн бұрын

Пікірлер: 76
@katchupoy01
@katchupoy01 5 жыл бұрын
Thank you. I know how hard to create videos like yours, and I am so grateful that you did this classes for pyrevit. You are awesome. I hope you keep doing these tutorials. I just started, and I have a lot to learn.
@pyRevit
@pyRevit 5 жыл бұрын
Thank you! 😁
@tadeh1
@tadeh1 4 жыл бұрын
I was not expecting to get an intro to Revit API class out of this. Thanks for the information it helped a lot in my understanding of the API.
@JonnyD000
@JonnyD000 5 жыл бұрын
This lecture has been super helpful, you're very good at explaining this stuff. Now I'm excited to watch the rest of the Python for Revit Course!
@martinspence406
@martinspence406 7 жыл бұрын
Thank you so much for this, Ehsan. You are presenting this in an extremely informative, thorough and nicely paced manner :-)
@ArsenSafaryan
@ArsenSafaryan 6 жыл бұрын
Thank you!!! This is the most user friendly video to get started with Revit and Python for someone who knows Revit well and knows the basics of Python!! I would really like to see more similar videos from you on this channel discussing different challenges such as PartUtils. etc.
@michaeljones1410
@michaeljones1410 3 жыл бұрын
Halfway through session #2, learning much and enjoying the process! Thank you so much.
@thomastakeuchi985
@thomastakeuchi985 4 жыл бұрын
I dont know how to thank uou more then liking all your videos and subscribe! Thank you very much! Alos, your didatic is very good ! Keep up the good work!
@Thepeopleofsyria
@Thepeopleofsyria 7 жыл бұрын
Thank you so much for this video. More and more, please, of these very usefull Python with Revit skills.
@AlbrechtJ
@AlbrechtJ 3 жыл бұрын
Ehsan, thanks for explaining your masterpiece work.
@leonardillerhaus4236
@leonardillerhaus4236 6 жыл бұрын
Thank you so much for your great work! I really appreciate the way you explain how things work. Looking forward to the next sessions!
@mehdinourollah
@mehdinourollah 7 жыл бұрын
Thank you so much for this tool and for these AWESOME videos and tutorials that you provide ...Thx Again and Dame Shoma ham garm :D
@timetostudy6443
@timetostudy6443 3 жыл бұрын
This thing gave me a headache. Tho don’t know if I should continue, thanks you for the invaluable tutorial
@engahmedsalah
@engahmedsalah 2 жыл бұрын
you're simply Great 👏🏻👍🏻
@martinchen9667
@martinchen9667 6 жыл бұрын
Thank you so much for this! A really good video for API newbie.
@yuanlin4139
@yuanlin4139 5 жыл бұрын
Thanks a lot for the video!!! One newbie question, what's the editor you use to type out script before running in Python Shell? (its convenient to be able to reference to Revit API) Thanks a lot!
@pyRevit
@pyRevit 5 жыл бұрын
I use VisualStudio Code at the moment. But I don't use autocompletion for Revit API
@ChristianJGentry
@ChristianJGentry 6 жыл бұрын
Awesome video, does a lot of this information transfer over to Dynamo users as well?
@pyRevit
@pyRevit 6 жыл бұрын
Definitely specially if you're using the python node in Dynamo. pyRevit and Dynamo with the same Revit API. Dynamo however has built in collectors for different categories as well as many other collectors and addons
@ChristianJGentry
@ChristianJGentry 6 жыл бұрын
Very cool! What features does pyRevit offer that Dynamo doesn't? I am not trying to downplay pyRevit's capabilities, I am just genuinely curious about the differences.
@pyRevit
@pyRevit 6 жыл бұрын
There is no direct comparison honestly. Dynamo is a visual programming platform that brings programming to people with no actual programming experience. pyRevit is a rapid-prototyping platform in IronPython for Revit. pyRevit helps with creating powerful tools and distributing them to your company teams very quickly since it does not need compilation. It's a better platform if you're building a toolbar of tools and don't want to use C#.
@ChristianJGentry
@ChristianJGentry 6 жыл бұрын
Thanks for the info! I will definitely try to get well versed in pyRevit then. I have been using Dynamo for a while, but after learning a bit of Python I can feel Dynamo encouraging bad habits and holding me back. Thanks again, great work!
@doodlslee
@doodlslee 6 жыл бұрын
Thank you so much. That's very helpful for me.
@tonyiommisg
@tonyiommisg 4 жыл бұрын
When I try to run CL, I get the error stating that FilteredElementCollector is not defined. If I make it DB.FilteredElementCollector, it works. Same with BuiltInCategory. Why is that? Thank you!
@pyRevit
@pyRevit 4 жыл бұрын
FilteredElementCollector is under Autodesk.Revit.DB namespace
@jamiehutchings2869
@jamiehutchings2869 2 жыл бұрын
Here's a stupid error I made that might be tripping up someone else: please note that it's "OfCategory", not "ofCategory" ... I'm not used to method names beginning with an uppercase letter, and of course in English, "of" is almost never capitalized in titles, so I mistyped it and it took me forever to find my error!
@chandumadgula9424
@chandumadgula9424 Жыл бұрын
Hi..the video was insightful.. How to get the wall element out of the revit object in the pyrevit console...Thanks in advance
@throwaway3946
@throwaway3946 4 жыл бұрын
Hello, I have followed your tutorial. It has been incredibly helpful! However, following the method used the total volume printed is incorrect? The volume being printed is 1712, when manually calculated the result is: 48.4 m^3. I am commenting here as a last resort, please can somebody assist? thank you in advance. wall_collect = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType() total_volume = 0.0 for wall in wall_collect: vol = wall.LookupParameter('Volume') if vol: total_volume = total_volume + vol.AsDouble() print("Total volume is: {}".format(total_volume))
@throwaway3946
@throwaway3946 4 жыл бұрын
Please ignore me. this is the correct result in Cubic feet!
@alexandraleclerc4651
@alexandraleclerc4651 6 жыл бұрын
Thank you so much for this video ! You called the parameter with a STR ("Volume"), but if my Revit got another langage, it can't find this parameter ?
@pyRevit
@pyRevit 6 жыл бұрын
In this example I'm using the parameter name directly. If this parameter is called something else in your language you should use the proper name. But for all Revit standard parameters you can use BuiltInParameter enum. This way no matter what the language is, Revit will always return the correct parameter. See www.revitapidocs.com/2018.1/fb011c91-be7e-f737-28c7-3f1e1917a0e0.htm
@alexandraleclerc4651
@alexandraleclerc4651 6 жыл бұрын
Thank you so much !
@DinkeyMalcho
@DinkeyMalcho 4 жыл бұрын
Hi, I kind of got stuck around 33 - I keep getting a message: 'Exception : IronPython.Runtime.UnboundNameException: name 'FilteredElementCollector' is not defined' Could it be that there is something wrong with the 'rps_init.py' startup script?
@pyRevit
@pyRevit 4 жыл бұрын
FilteredElementCollector is in the Autodesk.Revit.DB namespace. Make sure to import that first. "from Autodesk.Revit import DB" then use it like "DB.FilteredElementCollector"
@sepidehroohi3233
@sepidehroohi3233 4 жыл бұрын
hi, i have the same problem,did you solve that?
@HuyLeAEC
@HuyLeAEC 3 жыл бұрын
@@sepidehroohi3233 you can try cl = DB.FilteredElementCollector(doc) cl.OfCategory(DB.BuiltInCategory.OST_Walls)
@jo199281
@jo199281 6 жыл бұрын
vary helpful tutorial !
@Shawshank08
@Shawshank08 5 жыл бұрын
Hi Ehsan, just getting started with this series. I am trying to do the same example but instead with ducts (total length of all ducts). But the builtincategory has "ost_ductsystem" which returns a null value when looking up the length parameter. There is no ost_duct or pipe. Any other way ?
@pyRevit
@pyRevit 5 жыл бұрын
I haven't worked with ducts but seems like you are collecting Duct Systems instead of duct instances. Draw a Duct in Revit and check its Category.Name and Category.Id to see what Builtin Category you need to specify. You can also use the .OfClass filter on the FilteredElementCollector to collect by the duct element class instead
@Shawshank08
@Shawshank08 5 жыл бұрын
Hi Ehsan, this might be a stupid question. So i used OfClass filter but it still won't work on ducts. I get "Exception : IronPython.Runtime.UnboundNameException: name 'Duct' is not defined". I checked on RevitApiDocs and Duct Class inherits class MEPCurve. Could that be a reason ?
@pyRevit
@pyRevit 5 жыл бұрын
Send me your code or a snippet please. It’s hard to debug without seeing 😁
@Shawshank08
@Shawshank08 5 жыл бұрын
@@pyRevit Oh Yeah ! sorry about that. Here is the code and error Code: from Autodesk.Revit.DB import * length_collector=FilteredElementCollector(doc).OfClass(Duct) #iterate over ducts and collect total length total_length=0 for le in length_collector: length_param=le.LookupParameter('Length') if length_param: total_length= total_length + length_param.AsDouble() print(total_length) Error: Exception : IronPython.Runtime.UnboundNameException: name 'Duct' is not defined at IronPython.Runtime.Operations.PythonOps.GetVariable(CodeContext context, String name, Boolean isGlobal, Boolean lightThrow) at IronPython.Compiler.LookupGlobalInstruction.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 Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)
@Shawshank08
@Shawshank08 5 жыл бұрын
@@pyRevit Ehsan, it worked. I had to add "import Autodesk.Revit.DB.Mechanical"
@andyoohhh2061
@andyoohhh2061 6 жыл бұрын
Thank you Ehsan!!!
@eda4241
@eda4241 3 жыл бұрын
i am very excited, but it doesnt work 'el'. i do all step correct. but 'el' says: >>> el Traceback (most recent call last): File "", line 1, in NameError: name 'el' is not defined how can ı defıne 'el'? or sth else?(vers.2018)
@pyRevit
@pyRevit 3 жыл бұрын
Use this script as the RPS "init" script: gist.github.com/eirannejad/4e275166bf2015f4f844bb1d087ca4d6
@eda4241
@eda4241 3 жыл бұрын
@@pyRevit I embed script ın 'init.py' file. It works. Thanks.
@feri4life177
@feri4life177 2 жыл бұрын
nice.
@ganesankathiravan7710
@ganesankathiravan7710 6 жыл бұрын
Thank you very much for the very informative tutorial. If i want to count total number of windows in the model, what filter need to be used?
@pyRevit
@pyRevit 6 жыл бұрын
You need to filter for OST_Windows using OfCategory method on the FilteredElementCollector. www.revitapidocs.com/2018.1/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm
@ganesankathiravan7710
@ganesankathiravan7710 6 жыл бұрын
Thank you very much for your help. I got it and works perfect.
@pochuncheung569
@pochuncheung569 6 жыл бұрын
Very Good!!!!!!!!!!!
@thomas_lex_inc
@thomas_lex_inc 6 жыл бұрын
Thank you so much sir :D
@billmoresso908
@billmoresso908 6 жыл бұрын
Thank you so much! How to select elements of linked RVT document in current project?
@titobandito6060
@titobandito6060 6 жыл бұрын
When importing modules what is the most efficient way to know which modules to import? Do you write your code and then go back and look for the modules they are contained within?
@pyRevit
@pyRevit 6 жыл бұрын
Not really. overtime you learn slowly which modules to use by looking at their documentation a lot and testing them. But for tasks that I don't know there is a module, I generally do a search on Stackoverflow or Pypi to see if there is anything available and read their docs.
@adryjanek
@adryjanek 6 жыл бұрын
Hi! Thanks for great tutorials! I'm having problem with unit conversion in that example. When I add to this loop additional prints I get something like this: for wall in wall_collector: vol_param=wall.LookupParameter('Volume') if vol_param: total_volume = total_volume + vol_param.AsDouble() print(vol_param.AsValueString()) print(vol_param.AsDouble()) Output: 36.80 m³ 1299.57973535 21.28 m³ 751.496107833 18.40 m³ 649.789867675 10.64 m³ 375.748053917 Do you know what can be cause of that?
@pyRevit
@pyRevit 6 жыл бұрын
These are 4 pairs of prints for 4 elements being processed. Remember you're in a loop. Each loops isprinting AsValueString() and AsDouble() values
@titomoura7014
@titomoura7014 4 жыл бұрын
Hi everyone, How could I create a command that calculate total weight of a scaffold according to the items selected? Thank you.
@selincelen471
@selincelen471 3 жыл бұрын
Why don't we use "GetMaterialVolume" method? Thanks!
@pyRevit
@pyRevit 3 жыл бұрын
The intention was to talk about the underlying API and explaining how it works.
@selincelen471
@selincelen471 3 жыл бұрын
​@@pyRevit Thank you for your explanation and great video. This helps me a lot.
@TheMido688
@TheMido688 3 жыл бұрын
Thank you so much for this session , Ehsan. I tried the code in the session but the result of the volume is in cubic feet , i asking if there is a method to represent the volume in cubic meter as the Revit model is in metric unit
@abduls9316
@abduls9316 2 жыл бұрын
You could convert like this total_volume = (total_volume + vol_param.AsDouble())*0.0283
@musalah1
@musalah1 5 жыл бұрын
Thanks, I have been enjoying going through this. When I do the for loop to print (for el in cl:...etc) I dont get anything back. no errors but nothing is printed either. I do have a couple of walls modeled. Any idea what Im doing wrong?
@musalah1
@musalah1 5 жыл бұрын
nevermind! figured it out lol
@bongbong26d
@bongbong26d 5 жыл бұрын
Sorry to interrupt, but i face the same problem, may i ask how did you solve this problem?? Much thanks!!
@konstantinshyshkin4314
@konstantinshyshkin4314 6 жыл бұрын
Hello. Thank you for your tutorial. Trying recode it, but have one trouble. In my system i use m3 units, but when i get values by AsDouble, system return to me Volume in CF not in m3, but if i try get values by string, i got it in m3 but in string format. Please help me, is it possible get Volume in m3 by method AsDouble?
@pyRevit
@pyRevit 6 жыл бұрын
No. AsDouble() always returns values in internal API units. You need to do a quick CF to m3 conversion obviously. The AsValueString() however returns the string value with representing unit sign based on the model unit settings. That is good for quickly displaying pre-formatted results.
@stijncox8503
@stijncox8503 5 жыл бұрын
I get an Exception "LookupParameter() takes exactly 2 arguments (1 given)". What did I wrong?
@pyRevit
@pyRevit 5 жыл бұрын
The first parameter is the object instance. LookupParameter is a method on the type Element. So call that from the element instance. e.g el.LookupParameter(param_name)
@mtbfun2960
@mtbfun2960 5 жыл бұрын
I have this in my script "wall.LookupParameter('Volume')" and it didn't work?
@pyRevit
@pyRevit 5 жыл бұрын
Not sure then. Please submit your test model and script in issues to I can take a look. github.com/eirannejad/pyRevit/issues
@stijncox8503
@stijncox8503 5 жыл бұрын
It works! 😀 Thanks a lot, I wrote everything of the beginning on my own and it works. I have also convert it to cubic meters!
@sbr4897
@sbr4897 Жыл бұрын
Stop sayingg ammmmm ummmmm uhmmmmmm it sooo annoyinggggg
@feri4life177
@feri4life177 Жыл бұрын
Hi, i got the following error. >>> Exception : IronPython.Runtime.UnboundNameException: name 'BuildInCategory' is not defined bei IronPython.Runtime.Operations.PythonOps.GetVariable(CodeContext context, String name, Boolean isGlobal, Boolean lightThrow) bei IronPython.Compiler.LookupGlobalInstruction.Run(InterpretedFrame frame) bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) bei Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) bei IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) bei Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) bei Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)
How to pyRevit: Adding a python tool to pyRevit
17:31
pyRevit
Рет қаралды 17 М.
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 32 МЛН
Throwing Swords From My Blue Cybertruck
00:32
Mini Katana
Рет қаралды 11 МЛН
Самое неинтересное видео
00:32
Miracle
Рет қаралды 2,2 МЛН
Whoa
01:00
Justin Flom
Рет қаралды 58 МЛН
Python for Revit: python, RPS, RPW, and pyRevit
22:52
pyRevit
Рет қаралды 61 М.
Revit API Course for beginners | Lesson 1 | Set up your coding environment
24:34
Accessing Categories from Revit in Power BI
9:39
Speckle
Рет қаралды 3,6 М.
Unlocking the power of pyRevit! (Webinar)
49:38
Aussie BIM Guru
Рет қаралды 8 М.
Advanced Filtering of Elements in Revit Database
54:23
pyRevit
Рет қаралды 14 М.
pyRevit - The Ultimate Guide (Live) w/Ehsan
1:08:21
TheRevitKid
Рет қаралды 56 М.
bonus session, tldw: my personal python best practices
44:50
Visualizing Revit Rooms in Power BI
23:48
Speckle
Рет қаралды 9 М.
Python for Revit: Revit document as a database
20:29
pyRevit
Рет қаралды 13 М.
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 32 МЛН