Air calculator


Thanks to this function, the selection of diffusers from my addin will no longer be a painful process. You can adjust the program to your needs and preferences. You can see more in my video linked below.

In article “Air calculator”:

Ikona funkcji z

Revit air calculator – program idea

The program allows you to set your own preferences for the selection of diffusers in Revit. Based on your settings, you can then place items directly into the model. When will you use it?

  1. You select ventilation devices such as diffusers

Instruction how to install my extension you can find here.

How program work

I describe the program in more detail in my video. Here I will only post basic information about the functions included in the calculator.

Air terminal calculator settings

Using this function, you can add or remove a preference for the selection of a given air terminal. The program contains separate preferences for the supply and return systems. A detailed description of entering your own preferences can be found in the video below.

air calculator function

Air terminal calculator (supply lub return)

When we enter our own preferences, we will be able to fully use the calculator. Just select the devices you are interested in and enter the air flow. The program will return suggested devices based on our settings.

air calculator diffusers

Film with program use

Source code – Revit air calculator

Below is the code for one of the functions (Air terminal calculator(supply)). For more please visit mine GitHub, where new versions of the overlay will appear on a regular basis.

Copyright (C) 2023 Paweł Kińczyk
## Imports

from Autodesk.Revit.UI.Selection import *
from Autodesk.Revit.DB import *
from pyrevit import forms, script
from rpw import revit
import json
import os

doc = revit.doc
uidoc = revit.uidoc

class CustomISelectionFilter(ISelectionFilter):
    def __init__(self, nom_categorie):
        self.nom_categorie = nom_categorie

    def AllowElement(self, e):
        if e.Category.Name in self.nom_categorie:
            # if self.nom_categorie.Contains(e.Category.Name):
            # if e.Category.Name == self.nom_categorie:
            return True
            return False

    def AllowReference(self, ref, point):
        return True

def pick_objects(title="Pick", filter=""):
    with forms.WarningBar(title=title):
        return uidoc.Selection.PickObjects(ObjectType.Element, CustomISelectionFilter(filter))

def open_json(name_of_file="", open_method="r"):
    with open(name_of_file, open_method) as file:
        data = json.load(file)
        return data

# Pick air terminal
    air_terminal = pick_objects(
        title="Pick supply air terminal", filter="Air Terminals")
    forms.alert(title="Program Error",
                msg="You didn't pick any air terminal", exitscript=True)

# Write air flow
    air_flow = forms.ask_for_string(
        prompt="Write air supply", title="Air terminal air flow")
    air_flow = int(air_flow)
    forms.alert(title="Program Error",
                msg="You didn't write anything", exitscript=True)

# Get air terminal sizes
    dqj_list = open_json("air_terminals_supply_settings.json", "r")
    forms.alert(title="Program Error",
                msg="Didn't find settings", exitscript=True)

# Search for prefer family
correct_dqj = []
for dqj in dqj_list:
    dqj_min = int(dqj[0][0:4:])
    dqj_max = int(dqj[0][5:9:])
    if air_flow > dqj_min and air_flow < dqj_max:
        air_flow_avaible = ("{}-{}".format(dqj_min, dqj_max))
        new_dqj = tuple([air_flow_avaible])+tuple(dqj[1])

    selected_dqj =
        correct_dqj, title="Select air terminal which you want to pick", multiselect=False, button_name='Select DQJ', width=800)
    selected_dqj_size = selected_dqj[1]
    forms.alert(title="Program Error",
                msg="You didn't pick any type", exitscript=True)    

transaction = Transaction(doc, 'Air terminal calculator - PYLAB')

# Change to new type
    for element in air_terminal:
        element = doc.GetElement(element)

        if isinstance(element, FamilyInstance):
            family_instance = element
            family_instance = None

        types = family_instance.Symbol.GetSimilarTypes()
        for i in types:
            if selected_dqj_size in Element.Name.GetValue(doc.GetElement(i)):
except Exception as e:
    forms.alert(title="Program Error", msg=e, exitscript=True)


Please report any irregularities in the operation of the program that occur during use on my social accounts or account GitHub.

See also:

Paweł Kińczyk
Paweł Kińczyk
Articles: 84

Leave a Reply

Your email address will not be published. Required fields are marked *