BIM World
A Professional BIM Learning Platform


Harnessing the Power of Revit Macros for Enhanced Workflow

The macro functionality in Revit is incredibly powerful, offering two key advantages. First, macros can be saved directly within the project file. This means that when the file is shared, others can use the pre-written macros without needing to install additional tools. Second, for developing simple functions or conducting feasibility studies, using macros directly is often more straightforward and convenient than working with other IDEs.

Below is an example of a Revit macro written in C#. Simply copy the essential code into ThisDocument, run the macro, and it will assign elevation parameter data from electrical device family instances based on faces visible in the current view. This data is stored in the parameter named Point Height Sharing Parameter for later height annotation.

public void GetHeight()
{
    FilteredElementCollector fec = new FilteredElementCollector(Document, ActiveView.Id);
    fec.OfCategory(BuiltInCategory.OST_ElectricalFixtures).WhereElementIsNotElementType();

    using (Transaction tran = new Transaction(Document, "GetHeight"))
    {
        tran.Start();
        foreach (FamilyInstance fi in fec)
        {
            var para1 = fi.GetParameters("立面");
            var para2 = fi.GetParameters("点位高度");
            if (para1.Count > 0 && para2.Count > 0)
            {
                para2[0].Set(para1[0].AsDouble());
            }
        }
        tran.Commit();
    }
}
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Harnessing the Power of Revit Macros for Enhanced Workflow

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up