I've been reading the RevitAPI docs (still learning), searching (and finding) some answers, but I can't seem to be able to change the family name in a Revit model. I'm new to Python and have written a handful of scripts. Looking to get off dead center on this one.
Basically, I want to rename a family called "VA Titleblock Consultant Logo (PIN07)" to some other name, say "Billy's New Family Is Nice"
I'm able to get the name, but everything I try after that just fizzles.
Elements = FilteredElementCollector(doc).OfClass(FamilySymbol).WhereElementIsElementType()
for m in Elements:
try:
contains = "VA Titleblock Consultant Logo (PIN07)"
if m.FamilyName.startswith((contains)):
print m.FamilyName
m.FamilyName = "Some Name"
except:
print "I'm a reject and can't get this right."
I've also tried to understand how to rename a Type (Symbol) with a family and can't figure that out either.
t = Transaction(doc, 'loadfamily')
t.Start()
#Rename Family Type
Elements = FilteredElementCollector(doc).OfClass(FamilySymbol).WhereElementIsElementType()
for m in Elements:
try:
contains = "VA Titleblock Consultant Logo (PIN07)"
if m.FamilyName.startswith((contains)):
m.Name = contains + "Append"
except:
print "Type name not changed"
#Rename Family
Elements = FilteredElementCollector(doc).OfClass(Family)
for m in Elements:
try:
contains = "VA Titleblock Consultant Logo (PIN07)"
if m.Name.startswith((contains)):
m.Name = "VA Im Slow"
except:
print "what an idiot, I finally got it"
t.Commit()
I believe that the family is hard-coded to match the family definition RFA
filename. At least, that is what Revit always expects. Obviously, once the family has been loaded into a project and the RFA
file is no longer present, you may be able to change it. I would be pretty careful in doing so, though...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.