How should I change?

How should I change?

Anonymous
Not applicable
501 Views
3 Replies
Message 1 of 4

How should I change?

Anonymous
Not applicable

Revit 2008 API 

private void GetWallOpenInfo()
{
// 창문을 구한다.
Document doc = _commandData.Application.ActiveDocument;
ElementFilterIterator eIter = doc.get_Elements(typeof(FamilyInstance));

_wallOpenInfo = new Dictionary<FamilyInstance, string>();

while (eIter.MoveNext())
{
FamilyInstance family = eIter.Current as FamilyInstance;
if (family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Doors)) ||
family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Windows)))
{
if (!_wallOpenInfo.ContainsKey(family))
_wallOpenInfo.Add(family, family.Host.UniqueId);
}
}
}

 

 

2014 Revit API

 

private void GetWallOpenInfo()
{
// 창문을 구한다.
Document doc = _commandData.Application.ActiveUIDocument.Document;
//ElementFilterIterator eIter = doc.get_Elements(typeof(FamilyInstance));
FilteredElementIterator eIter = doc.GetElement(typeof(FamilyInstance));

_wallOpenInfo = new Dictionary<FamilyInstance, string>();

while (eIter.MoveNext())
{
FamilyInstance family = eIter.Current as FamilyInstance;
if (family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Doors)) ||
family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Windows)))
{
if (!_wallOpenInfo.ContainsKey(family))
_wallOpenInfo.Add(family, family.Host.UniqueId);
}
}
}

 

 

How should I change?

 

0 Likes
502 Views
3 Replies
Replies (3)
Message 2 of 4

ollikat
Collaborator
Collaborator

Hi

 

In order to get some help and reasonable answers here you must be a bit more specific. Are you getting a compiler error or what's the problem?

 

BTW: It would be nice, if topic of the discussion thread would give a clear hint what is the issue...now it doesn't tell anything to anybody...

0 Likes
Message 3 of 4

augusto.goncalves
Alumni
Alumni

Probably instead

FilteredElementIterator eIter = doc.GetElement(typeof(FamilyInstance));

if (family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Doors)) || family.Category.Equals(doc.Settings.Categories.get_Item(BuiltInCategory.OST_Windows)))

 

You need to

FilteredElementIterator eIter = new FilteredElementIterator(doc);

eIter.OfClass(typeof(FamilyInstance));

ElementCategoryFilter filterDoor = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
ElementCategoryFilter filterWindow = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
LogicalOrFilter orFilter = new(filterDoor, filterWindow)

eIter.WherePasses(orFilter)

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 4 of 4

Anonymous
Not applicable
sorry;;
ElementFilterIterator eIter = doc.get_Elements(typeof(FamilyInstance));
%get_Elements%
You can not take advantage of.
0 Likes