Reputation: 13
I'm a little confused about how you get access to Revit's element data, such as an element's parameters, location, Id, etc.. If I have this code:
collector = FilteredElementCollector(doc)
collector.OfCategory(BuiltInCategory.OST_Walls)
walls = collector.OfClass(FamilySymbol)
return walls
It will print: Autodesk.Revit.DB.FilteredElementCollector object at 0x0000000000000038 [Auto...]. Where do I go from here? For instance, How do I get a return of the walls' location?
There might be a lot in here, and multiple steps for each item. I am mainly looking for a general concept of getting and/or setting new element data.
Any thoughts?
Upvotes: 0
Views: 2513
Reputation: 70314
The Revit API documentation points out that a FilteredElementCollector
is an IEnumerable<Element>
. So you actually have a list of wall objects. I like to add these to a python list to make working with them easier:
walls = list(collector)
Behind the scenes, list(collector)
will do something like:
walls = []
for w in collector:
walls.append(w)
(note, that this is not really how it works, but sort of explains it).
You can use the .NET inner workings to enumerate the walls in the collector
by doing this:
enumerator = collector.GetEnumerator()
walls = []
while not enumerator.IsDone():
walls.append(enumerator.Current)
enumerator.MoveNext()
You will want to check if the collector.OfClass(FamilySymbol)
line is correct - in my example document, that yielded an empty list - but maybe you do have walls that are FamilySymbol
s...
Next, you want to work with a wall object. So, take the first wall:
wall = walls[0]
interior_type_parameter = wall.Parameter['Interior Type']
And then work with the parameter... If you install the Revit SDK, you will find a tool for snooping objects and finding their parameters and values. Use this! Explore! Have fun!
Upvotes: 0
Reputation: 2185
I can't help with the Python, but I'm pretty familiar with Revit's API + C#.
You are using the collector to list all the walls on the project. What you want (to get the locations) is the FamilyInstance objects of these walls.
In C# would be something like this:
new FilteredElementCollector(uidoc.Document).OfClass(FamilyInstance).ToElements();
Next, you should loop the result to get each individual Element and convert it to a Wall:
foreach (Wall i in instances)
{
var location = i.Location as LocationCurve;
// The Curve element is a Line - 2 points defining it's position
var p0 = location.Curve.GetEndPoint(0);
var p1 = location.Curve.GetEndPoint(1);
}
Most of the information you want is on this FamilyInstance Object -> http://wikihelp.autodesk.com/Revit/enu/2014/Help/3665-Developers/0074-Revit_Ge74/0083-Family_I83/0086-FamilyIn86
Upvotes: 1