Automatically Creating Schedules for Precast Assemblies in Dynamo

Hello I am trying to use Dynamo to Automatically place the same Schedules on my sheets for Assemblies. Usually I would have to Right click on each assembly and set the view type and view template for every assembly in the project but that is too time consuming for the amount of precast assemblies that I have in the Project.( can’t copy and past-align to sheet because parameter changes)


I have been trying to alter the Python Script in the tool.assemblyViews Node from SteamNodes to no avail. Does anyone know how to alter the script to get the Schedules to be generated as well?

Hiya! Welcome!

Great to see you are experimenting with Python!

The Revit API of the AssemblyViewUtils shows the available commands for assembly views.

So following that; you could get the ViewTemplateId of your “CONCRETE TAKE OFF” template. And create a material takeoff for your assembly. For example:

inputAssembly = UnwrapElement(IN[0])

viewTemplate = [t for t in FilteredElementCollector(doc).OfClass(View).ToElements() if t.IsTemplate and t.Name == "CONCRETE_TAKE_OFF"][0]

view = AssemblyViewUtils.CreateMaterialTakeoff(doc, inputAssembly.Id)
view.ViewTemplateId = viewTemplate.Id
view.Name = "Assembly Material takeoff"

Make sure this happens in a Transaction as you are modifying your project.

Greetings,

Rick

2 Likes

Thank you Rick! I will give this a try and Let you know how it goes.

Hi, I have tried to insert the code into my script however I could not figure out where to insert it correctly so it would run. For context here are my inputs.


And then where I inserted your revisions

The element ID for my View Template is the 1970582 but I think I don’t have that in the correct place either.

I appreciate you helping me out. As you can probably tell this is my first deep dive into Python for Dynamo

No problem!

Let me explain what the viewTemplate = .... line does. It basically takes all the elements in your document. Then filters out all the elements that are not a View. Then it checks whether or not the found element is a template and the name is conform your preferred viewTemplate. The result will therefore be your viewTemplate.

view.ViewTemplateId = viewTemplate.Id ← This line is there to take your new view, and set its template to your new template. The way to do that is to take your viewTemplate’s Id. viewTemplate.Id will probably be that 1970582 number, but if you’d open up a new document that Id will be different. It is therefore better practice to find the template.Id on this method.

Line 82 can just be view.ViewTemplateId = viewTemplate.Id

It might still cause errors, let me know in that case!

Rick

1 Like

Thanks Rick! This Allowed me to apply the View template successfully.
Appreciate the Help!!