I get a lot of people asking for resources on how to get into Python scripting in Dynamo which can sometimes be difficult. I decided to put the basics into a video course which will hopefully get those that are starting out into some Python. I have tried to fit the basics of Python and the start of getting into the Revit API into the course
Check it out below, would love to hear some feedback from pros like you guys.
The PyRevit youtube channel is another great resource for Revit focused python learning:
However you should keep in mind that those videos are targeting the Revit python shell, which is implemented slightly differently from the Dynamo equivalent. (different ways to call the active document; no need to worry about element wrapping, because you’re not returning anything to the graph; etc.)
nice work out there , Lynda need it someone to dive into (Python-Dynamo-Revit API), because they have not much in tthis area,
Thank you for this nice work
Jeremy thank you so much for these tutorials, i started them a couple of nights ago and this is exactly what ive needed to start learning python. Ive struggled a few times in the past to learn python but none have actually broken it down right from the start to rationally explain the coding structure and exactly which bit does what. Cheers mate!
should be getting lynda soon, just so I can do this course, so I’m also excited
most of the things I’m trying to learn in python are about collecting types (rather than instances of a type) that its difficult to get in vanilla dynamo
clockwork and rhythmn Element.Type take an element input and output its type, thats not quite what I thinking of
I was getting excited to learn properly the things I have hashed together which mostly output all the types in the project browser not all types of the instances in the project
doc = DocumentManager.Instance.CurrentDBDocument
views = FilteredElementCollector(doc).OfClass(View)
appliedtemplates = [v.ViewTemplateId for v in views]
templates = [v.Id for v in views if v.IsTemplate == True]
There’s a ‘shortcut method’ to the filtered element collector .WhereElementIsNotElementType() <- it should also be possible to invert the entire filter, so all you will return is types. I’ve not tried this myself, but it’s how I would initially approach the task.
I was just wondering.
It’s possible to use context managers for the RevitAPI in C# using the syntax using (Transaction t = new Transaction(doc, "") { .... }
I was wondering how to do this in Python.
Apparently, doing this won’t work, but I don’t know why.
with Transaction(doc, 'x') as t:
t.Start()
.....
t.Commit()