Our Recent Posts

Tags

No tags yet.

Automate Elements Tagging in Revit

Automating workflow in Revit is much easier now using dynamo, so in this topic we will go through automate element tagging which usually consumes a lot of time, that you need to fill the parameter for each element one by one. watch the below video for better understanding.

Dynamo Script:

The goal for the below script is to add a parameter and fill it with the floor number for each element in the project.

Dynamo Script Request Here

Python Code:

  • You need to install the following packages:

  • Data-shapes

  • Clockwork

  • MEPover

Categories:

StartFragment#Copyright(c) 2018, Mohammad Nawar #BIMhex, http://BIM-hex , mohadnawar@live.com import sys import clr import System sys.path.append(r'C:\Python24\Lib') clr.AddReference('ProtoGeometry') clr.AddReference('RevitServices') clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') clr.AddReference("RevitNodes") from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager from System.Collections.Generic import * from Autodesk.DesignScript.Geometry import * from Autodesk.Revit.DB import* import Autodesk, RevitServices import Revit clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion) from RevitServices.Persistence import DocumentManager pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib' sys.path.append(pyt_path) doc = DocumentManager.Instance.CurrentDBDocument bics = System.Enum.GetValues(BuiltInCategory) cdata = list() for bic in bics: try: cdata.append((Revit.Elements.Category.ById(ElementId(bic).IntegerValue), Revit.Elements.Category.ById(ElementId(bic).IntegerValue).Name)) except: pass y = cdata o1 = [] for k in y: o1.append(k[1]) o1= sorted(o1) o2 = [] for i in o1: for j, val in enumerate(y): s = 1 if i == val[1]: o2.append(val[0]) o3 = [] for w in o2: if w not in o3: o3.append(w) OUT = o3EndFragment

Get Elements:

StartFragment#Copyright(c) 2018, Mohammad Nawar #BIMhex, http://BIM-hex , mohadnawar@live.com import sys import clr import System sys.path.append(r'C:\Python24\Lib') clr.AddReference('ProtoGeometry') clr.AddReference('RevitServices') clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') clr.AddReference("RevitNodes") from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager from System.Collections.Generic import * from Autodesk.DesignScript.Geometry import * from Autodesk.Revit.DB import* import Autodesk, RevitServices import Revit clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion) from RevitServices.Persistence import DocumentManager pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib' sys.path.append(pyt_path) doc = DocumentManager.Instance.CurrentDBDocument bics = System.Enum.GetValues(BuiltInCategory) cdata = list() for bic in bics: try: cdata.append((Revit.Elements.Category.ById(ElementId(bic).IntegerValue), Revit.Elements.Category.ById(ElementId(bic).IntegerValue).Name)) except: pass y = cdata o1 = [] for k in y: o1.append(k[1]) o1= sorted(o1) o2 = [] for i in o1: for j, val in enumerate(y): s = 1 if i == val[1]: o2.append(val[0]) o3 = [] for w in o2: if w not in o3: o3.append(w) result = [] for x in o3: if x.Name == IN[0].Name: filter = ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, x.Id)) result.append(FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType().ToElements()) OUT = resultEndFragment

If Statement:

StartFragmentimport clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * #The inputs to this node will be stored as a list in the IN variables. dataEnteringNode = IN x = IN[0] for i in x: if i == True: o = None break else: o = "Floor Number" #Assign your output to the OUT variable. OUT = oEndFragment

#revit #Dynamo #automation #3D #4D #P #Python #Programming

©2018 by Nawar.

  • YouTube Social  Icon
  • LinkedIn Social Icon