Stairs

Stairs

Anonymous
Not applicable
629 Views
4 Replies
Message 1 of 5

Stairs

Anonymous
Not applicable

Hi

 

I am trying to get data from stairs

 

I have done the same with Floors, Doors, Walls, Railings etc, and that works fine, but not with Stairs

 

FilteredElementCollector FMStairCollector = new FilteredElementCollector(OpenDoc);

ElementCategoryFilter FMStairCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Stairs);

 

FMStairCollector.OfClass(typeof(Stairs));

 

foreach (Stairs FMStairs in FMStairCollector)

{

 ....................

}

 

Can anyone tell me what I do wrong ?

 

Regards

Anders

 

0 Likes
630 Views
4 Replies
Replies (4)
Message 2 of 5

mikako_harada
Community Manager
Community Manager

Hi Anders, 

 

I think your rvt file has old stairs.  There are two types of stairs.  Stairs by component was added a few releases back. Old was is still types element, meaning that it is not exposed.  

 

There is a sample in chm file under class stairs, using category instead to filter: 

 

private Stairs GetStairInfo(Document document)
{
Stairs stairs = null;

FilteredElementCollector collector = new FilteredElementCollector(document);
ICollection<ElementId> stairsIds = collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIds();
foreach (ElementId stairId in stairsIds)
{
if (Stairs.IsByComponent(document, stairId) == true)
{
stairs = document.GetElement(stairId) as Stairs;

// Format the information
String info = "\nNumber of stories: " + stairs.NumberOfStories;
info += "\nHeight of stairs: " + stairs.Height;
info += "\nNumber of treads: " + stairs.ActualTreadsNumber;
info += "\nTread depth: " + stairs.ActualTreadDepth;

// Show the information to the user.
TaskDialog.Show("Revit", info);
}
}

return stairs;
}

 

The best to troubleshoot in the situation like this is to place two types of stairs and use Revit lookup to examine the elements which makes up stairs. 


Mikako Harada
Developer Technical Services
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Mikako

Thanks, That worked fine with staitrs by component

 

Do you mean that I can't get data from by saits by sketch through the API ?

 

Can you show be how to get data from Ramps as well ?

 

Regards Anders

 

 

 

0 Likes
Message 4 of 5

mikako_harada
Community Manager
Community Manager

Hi Anders, 

 

Probably not in the same level.  But you should be able to get some basic information in the parameter and geometry as they are exposed from the base class.   Try "snoop" into the element using RevitLookup tool.  You will see you can still access parameters and geometry.  

 

Same for Ramp, you can get the basic information through parameters and geometry.  

 

You can find RevitLookup here:  

 

https://github.com/jeremytammik/RevitLookup 

 

On how to use parameters and geometry, you can find information in our training materials: 

 

http://images.autodesk.com/adsk/files/Revit2016APITraining 

 

https://github.com/ADN-DevTech/RevitTrainingMaterial

 

I hope this helps. 


Mikako Harada
Developer Technical Services
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi

 

That works fine with the instants parameters, but can you please show me how to get some of the type parametres as well, I tried this but, failed !!

I am using this code:

 

Stairs stairs = null;

FilteredElementCollector collector = new FilteredElementCollector(OpenDoc);

ICollection<ElementId> stairsIds = collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIds();

foreach (ElementId stairId in stairsIds)

{

 

Element stairtype = OpenDoc.GetElement(stairId);

Stair_Keynote = stairtype.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);

........

 

I have done somthing similar with eg Railings, but I can't get it to work with Stairs

 

Regards Anders

 

 

 

 

 

0 Likes