julien.duprat
2008-07-03, 01:34 PM
I try to get a OST_Railings Category Reference...
I have two ways to do this :
First Way :
method
public static Category GetCategoryReference(Autodesk.Revit.Application revitApp, BuiltInCategory bic)
{
Filter filter = revitApp.Create.Filter.NewCategoryFilter(bic);
ElementIterator itor = revitApp.ActiveDocument.get_Elements(filter);
while (itor.MoveNext())
{
Element currentElement = itor.Current as Element;
if (currentElement != null && currentElement.Category != null)
{
return currentElement.Category;
}
}
return null;
}
Call : c = NovaExporterForRevitHelper.GetCategoryReference(revitApp, bicTemp);
Second Way :
method :
public static Category GetCategoryReference2(Autodesk.Revit.Application revitApp, BuiltInCategory bic)
{
CategorySet catSet = revitApp.Create.NewCategorySet();
return revitApp.ActiveDocument.Settings.Categories.get_Item(bic);
}
call : c = NovaExporterForRevitHelper.GetCategoryReference(revitApp, bicTemp);
First Method works with a lot of BuiltInCategory : Walls, Views....
But it don't work with OST_Railngs...
Can you help me ???
Thanks a lot.
julien.duprat@bewise.fr
I have two ways to do this :
First Way :
method
public static Category GetCategoryReference(Autodesk.Revit.Application revitApp, BuiltInCategory bic)
{
Filter filter = revitApp.Create.Filter.NewCategoryFilter(bic);
ElementIterator itor = revitApp.ActiveDocument.get_Elements(filter);
while (itor.MoveNext())
{
Element currentElement = itor.Current as Element;
if (currentElement != null && currentElement.Category != null)
{
return currentElement.Category;
}
}
return null;
}
Call : c = NovaExporterForRevitHelper.GetCategoryReference(revitApp, bicTemp);
Second Way :
method :
public static Category GetCategoryReference2(Autodesk.Revit.Application revitApp, BuiltInCategory bic)
{
CategorySet catSet = revitApp.Create.NewCategorySet();
return revitApp.ActiveDocument.Settings.Categories.get_Item(bic);
}
call : c = NovaExporterForRevitHelper.GetCategoryReference(revitApp, bicTemp);
First Method works with a lot of BuiltInCategory : Walls, Views....
But it don't work with OST_Railngs...
Can you help me ???
Thanks a lot.
julien.duprat@bewise.fr