Would someone be able to help me write a script that removes a certain prefix from filled region names? I have 200 filled regions of which the majority have a "PA" prefix that I need to remove. Is Dynamo the way to go for this?
yes Dynamo or Python.
it is a single PA or it has variations with PA- or PA_ ?
Hi,
You can certainly do this with Dynamo. I attached the script for you. Change the Prefix when needed.
Select Accept as Solution and Likes are always welcome.
Ralph den Haan, (Lazy) BIM Specialist
here a quick python code inside Dynamo.
import clr
#add reference DocumentManager and Transaction manager
clr.AddReference("RevitServices")
#import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#add reference and Import RevitAPI
clr.AddReference("RevitAPI")
#import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc)
filter = ElementClassFilter(FilledRegionType)
els = collector.WherePasses(filter).ToElements()
names = [i.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString() for i in els]
#here put the prefix to delete
newNames = [i.strip("PA") for i in names]
#starts transation
TransactionManager.Instance.EnsureInTransaction(doc)
for i,j in zip(els,newNames):
i.Name = j
#ends transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = names, newNames
@Anonymousdenhaan I wasn't able to find the first 2 boxes. Element Classes and All Elements of Class. Is there a certain add in I need to install?
@Yien_Chao You can use code inside Dynamo? I thought you always had to use visual programming inside Dynamo??
Just look for the Python node and copy the previous code inside. Then run the script
The element classes can be changed to node: Element Types
and all elements of classes can be changed to: All elements of Types.
Select Accept as Solution and Likes are always welcome.
Ralph den Haan, (Lazy) BIM Specialist
Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.