Hi, the goal is to open a list of different Revit family annotation tags and add a new type 2.5mm text or change the 3mm type to 2.5mm and save. I am struggling with trying to get the label inside the open family to add a new or change the family type if anyone can help with that. Below is just me messing around trying to find somthing to do it with no luck. I’ve just pulled first item from list to save opening a bunch while trying to get it to work.
I guess it would have to save with the new created type selected. I’m assuming it would.
Always having a headache with dynamo haha. This year is the year to do some Lynda tutorials on python in dynamo though. Happy new year! and thanks for some help. Although I don’t know python well enough to get anywhere…
I did this below. This may actually be to much if there is no nodes to do it.
Haha, that’s cool.
Without getting into the nitty-gritty, here is a quick and dirty script that will create a new type avoiding duplicates and returns the newly created types:
Sorry Jeremy, the problem is a bit more complex to solve it quickly, under the pump right now. The problem I have found is that Dynamo doesn’t support labels:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
# The inputs to this node will be stored as a list in the IN variables.
docs = IN[0]
result = []
# Place your code below this line
for doc in docs:
labelCollector = FilteredElementCollector(doc).OfClass(TextElement).ToElements()
for e in labelCollector:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType":
result.append(e.GetType())
# Assign your output to the OUT variable.
OUT = result
Hahaha, sorry, I should have provided a bit of context here. The idea is to retrieve the type of TextElement and duplicate it, so I called Duplicate(“name”) directly inside the python script but this error shows up:
And I though I should check what kind of object it is, that is the reason I plugged it into Object.Type
result = []
# Place your code below this line
for doc in docs:
labelCollector = FilteredElementCollector(doc).OfClass(TextElement).ToElements()
for e in labelCollector:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType":
result.append(e.GetType().Duplicate("New Type"))
Oooh, so GetType() is not getting the Type of the Family Instance?
Thanks Michael, I think I have found a workaround.
Because funny thing, GetTypeId() and retrieving the element later by id gets the Type and allows me to use the Duplicate method.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# The inputs to this node will be stored as a list in the IN variables.
docs = IN[0]
result = []
# Place your code below this line
for doc in docs:
t = Transaction(doc, doc.Title)
t.Start()
labelCollector = FilteredElementCollector(doc).OfClass(TextElement).ToElements()
for e in labelCollector:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType":
ft = doc.GetElement(e.GetTypeId())
try:
result.append(ft.Duplicate(IN[1]))
except:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType" and e.Name == "2.5mm":
result.append(ft)
pass
t.Commit()
# Assign your output to the OUT variable.
OUT = result
While using GetType() didn’t create any new type and returns this error when I try to modify type parameters:
docs = IN[0]
result = []
# Place your code below this line
for doc in docs:
t = Transaction(doc, doc.Title)
t.Start()
labelCollector = FilteredElementCollector(doc).OfClass(TextElement).ToElements()
for e in labelCollector:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType":
try:
result.append(e.GetTypeId().Duplicate(IN[1]))
except:
if e.Symbol.ToString() == "Autodesk.Revit.DB.TextElementType" and e.Name == "2.5mm":
result.append(e.GetType())
pass
t.Commit()
# Assign your output to the OUT variable.
OUT = result
Edit: the logic I was following was to get all TextElement, use GetType method inherited from Object, and use Duplicate method from TextElementType that is inherited from ElementType;