Hello, I want to get the name and then rename a filled region, however I am a bit stuck.
First I use a filtered element collector to get all OfClass FilledRegion Type
Filled_Regions_elements = DB.FilteredElementCollector(doc).OfClass(DB.FilledRegionType)
Then I am trying to loop over this list and then get the .Name of all of these, however, I think that perhaps I am getting the type as opposed to the Element? any help to get me on the right track much appreciated!
Alien
March 24, 2022, 11:22am
2
Can you paste a screen shot of your graph?
@ssw9UZNL use this collector (category instead of class):
FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_DetailComponents).WhereElementIsNotElementType().ToElements()
Thanks tradelie, once I have isolated down all the filled regions, how do I get the actual type name of the object?
you can filter by name if you want using an If statement with python, or a simple Filter.ByBoolMask in Dynamo.
But it doesnt give me the actual name of the type, I want to return the name of the type itself and then possibly change that name?
check out this:
if you are comfortable with python you can use the ‘filtered element collector’ to get the element ids for system family types, then pass that to clockwork’s Element.SetName
[PrefixFamiliyNamesCapture]
formatting is slightly different when using python from string
"
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import \\
Element, FilteredElementCollector, BuiltInCategory,\\
CeilingType, FillPatternElement, FilledRegionType, FloorType,\\
GraphicsStyleType, RoofType, WallType…
A simplified code to your request:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
fRegions = FilteredElementCollector(doc).OfClass(FilledRegionType).ToElements()
TransactionManager.Instance.EnsureInTransaction(doc)
for f in fRegions:
if Element.Name.__get__(f) == "Vertical":
f.Name = "Horizontal"
TransactionManager.Instance.TransactionTaskDone()
OUT = fRegions
1 Like
Thankyou, what I dont understand is what is the ‘Element’ part of the script, why cant I just write
f. Name to retrieve the name)?
Sam
ssw9UZNL:
Thankyou, what I dont understand is what is the ‘Element’ part of the script, why cant I just write
f. Name to retrieve the name)?
It’s currently an inheritance bug (getter) in IronPython (same in Python.Net ), there are several workarounds
opened 04:17PM - 24 Mar 22 UTC
closed 09:29PM - 27 Apr 22 UTC
confirmed
### Prerequisites
The issue tracker is used to report bugs and request new fe… atures, NOT to ask questions.
Questions should be posted to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.
* [x] Are you running the latest version?
* [x] Did you perform a cursory search?
### Description
.NET property is not accessible in derived classes where only the setter or the getter has been overridden
a workaround is to use the unbound base class instance method syntax (Ipy2 or Ipy3)
### Steps to Reproduce
C# lib
```
using System;
using System.Collections.Generic;
namespace TestGetter
{
public class BaseClass
{
protected string name = "noname";
public virtual string Name
{
get { return name; }
set {name = value; }
}
}
public class DerivedClass : BaseClass
{
public override string Name
{
set { base.Name = value.ToUpper();}
}
}
}
```
Python code
```
import clr
import sys
import System
print(sys.implementation)
print(sys.version)
sys.path.append(r'C:\Users\****l\Documents\SharpDevelop Projects\TestGetter\TestGetter\bin\Debug')
clr.AddReference("TestGetter")
from TestGetter import BaseClass, DerivedClass
d = DerivedClass()
b = BaseClass()
b.Name = 'BaseClass Name'
d.Name = 'DerivedClass Name'
print("#" * 40)
print(b.Name) # ok
print("#" * 40)
try:
print(d.Name) # TypeError: property cannot be read
except:
import traceback
print(traceback.format_exc())
print("#" * 40)
try:
print(BaseClass.Name.GetValue(d)) # workaround ok
except:
import traceback
print(traceback.format_exc())
```
Result
![image](https://user-images.githubusercontent.com/53660624/159962451-35c18c24-da45-426e-a883-4a8562702341.png)
3 Likes
@ssw9UZNL . Use
Element.Parameters Node.
you will get the filled region name