Revit Architecture Forum
Welcome to Autodesk’s Revit Architecture Forums. Share your knowledge, ask questions, and explore popular Revit Architecture topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Batch remove prefix from filled region name

8 ANTWORTEN 8
Antworten
Nachricht 1 von 9
skyeg321
510 Aufrufe, 8 Antworten

Batch remove prefix from filled region name

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? 

8 ANTWORTEN 8
Nachricht 2 von 9
Yien_Chao
als Antwort auf: skyeg321

yes Dynamo or Python.

 

it is a single PA or it has variations with PA- or PA_ ?

Nachricht 3 von 9
ralphdenhaan
als Antwort auf: skyeg321

Hi,

 

You can certainly do this with Dynamo. I attached the script for you. Change the Prefix when needed.

ralphdenhaan_0-1686769325406.png

 




Select Accept as Solution and Likes are always welcome. 


Ralph den Haan, (Lazy) BIM Specialist


LinkedIn | LazyBIM Blog


 

Nachricht 4 von 9
Yien_Chao
als Antwort auf: skyeg321

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

 

Nachricht 5 von 9
skyeg321
als Antwort auf: ralphdenhaan

@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?

Nachricht 6 von 9
skyeg321
als Antwort auf: Yien_Chao

@Yien_Chao You can use code inside Dynamo? I thought you always had to use visual programming inside Dynamo??

Nachricht 7 von 9
Yien_Chao
als Antwort auf: skyeg321

Just look for the Python node and copy the previous code inside. Then run the script 

Nachricht 8 von 9
Yien_Chao
als Antwort auf: skyeg321

Python inside Dynamo is there since a couple of years i think. It's Cpython (3.0) now , but you still have access to IronPython (2.0)
Nachricht 9 von 9
ralphdenhaan
als Antwort auf: skyeg321

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


LinkedIn | LazyBIM Blog


 

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report