Python Scripting Video Course

Hey guys,

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.

https://www.lynda.com/Dynamo-Studio-tutorials/Dynamo-Revit-Python-Scripting/647661-2.html

cheers,

35 Likes

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.)

14 Likes

Great work Jeremy,

it’s a really clear and concise run through of all the major topics - I think this will help a lot of people! :slight_smile:

(As an aside: I really think an entire course could be devoted to the ins and outs of Filtered Element Collectors… )

2 Likes

Thank you! It is great to have a resource like that!

2 Likes

Thanks Oliver!

Hopefully it does, it is such a big topic that it was hard to condense to 3 hours! And you are right; FilteredElementCollecter is a huge topic!

Thanks Petar! Hope you find it helpful

Awesome resource Dimitar! I couldn’t fit absolutely everything in 3 hours so it’s good to have more resources on the topic to refer to

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 :slight_smile:

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

@adam_bear1

collecting types (rather than instances of a type) that its difficult to get in vanilla dynamo

Try to use Element.Type for that :slight_smile:

Marcel

thanks for the tip :slight_smile:

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]

doc.ProjectInformation.Number

FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks).ToElements()

FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()

1 Like

Thanks @aboodnoah, @Elton_Williams and @adam_bear1!

Really appreciate the feedback guys and glad to hear you are enjoying the course!

and @adam_bear, you can always get a couple weeks free trial on Lynda if you don’t have access :wink:

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.

1 Like

Love it! Thanks a ton for putting all that good stuff together!

There is also a method called .WhereElementIsElementType() which would do what you are suggesting.

2 Likes

:sweat_smile:

thanks @DyNewby, happy to do so! Glad to hear you enjoy it :slight_smile:

1 Like

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()

Also, it seems like revitpythonwrapper(http://revitpythonwrapper.readthedocs.io/en/latest/db/transaction.html) takes care of this issue but wouldn’t that require that revitpythonwrapper should be installed on every PC that uses my code?
Any tips/workarounds?

For now, I can only think of try-except-finally but they aren’t as robust as with blocks right?

try:
    TransactionManager.Instance.EnsureInTransaction(doc)

except:
    pass

finally:
    TransactionManager.Instance.TransactionTaskDone()