reduce Elements dimension

reduce Elements dimension

husam_al-jawhar
Enthusiast Enthusiast
301 Views
2 Replies
Message 1 of 3

reduce Elements dimension

husam_al-jawhar
Enthusiast
Enthusiast

Hi all,

I have columns in my project, and after a period of time, I realized that I should reduce the length, width, and height of each column by about 1 cm. How can I visually achieve this in Revit using Python?

Cheers, 

 

302 Views
2 Replies
Replies (2)
Message 2 of 3

architect.bim
Collaborator
Collaborator

Hi!

I'm not sure about changing the height of the columns, as it is usually linked to the elevation of the level above and it's easier to move level manually. But as for length and width, you have to do it by changing the parameter values. Follow the steps below:


1. Define a system element category through Revit Lookup. Most likely it will be either OST_StructuralColumns for structural columns or OST_Columns for architectural ones.
2. Make a selection of elements of a given category using FilteredElementCollector.
3. Check in Revit which parameters control the length and width of the column. First of all, you need to understand if they are type or instance parameters. If type, then add the WhereElementIsElementType() method to the collector. If instance, then WhereElementIsNotElementType().
4. Open a transaction and start to loop through all the columns selected in the collector.
5. For each column:
5.1 Get the parameter objects as well as their numeric values. To do this, look up the parameter names and get them via the LookupParameter() method (in the case of system parameters, you can also get them using the BuiltInParameter enumeration using the get_Parameter method).
5.2 Subtract 10 mm from each value, converting millimeters to feet.
5.3 Assign new values to the parameters
6. Close the transaction

 

An example of one possible implementation of your code is shown below:

 

 

# Use these imports if you run your code in Revit Python Shell
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit import DB
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory

doc = __revit__.ActiveUIDocument.Document

# If using Dynamo, delete the code above and turn the comments below into code.
# import clr

# clr.AddReference('RevitServices')
# from RevitServices.Persistence import DocumentManager

# clr.AddReference('RevitAPI')
# from Autodesk.Revit import DB
# from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory

# doc = DocumentManager.Instance.CurrentDBDocument

column_types = FilteredElementCollector(doc) \
    .OfCategory(BuiltInCategory.OST_Columns) \
    .WhereElementIsElementType()

with DB.Transaction(doc, 'Changing Type Parameter Values') as t:
    t.Start()
    for column_type in column_types:
        depth_par = column_type.LookupParameter("Depth")
        width_par = column_type.LookupParameter("Width")
        depth_value = depth_par.AsDouble() - (10 / 304.8)
        width_value = width_par.AsDouble() - (10 / 304.8)
        depth_par.Set(depth_value)
        width_par.Set(width_value)
    t.Commit()

 

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 3 of 3

husam_al-jawhar
Enthusiast
Enthusiast
Hi Maxim,
Many thanks for your answer. I will try it and inform you of the results.
Cheers,