Gets information about stairs and stairs from elements containing such information

Hello, I have the following code:

public static void HandleStairs(Document doc) List<TransitionPoint> ret = new List<TransitionPoint>(); FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection<Element> stairs = collector.OfCategory(BuiltInCategory.OST_Stairs).ToElements(); foreach (var stair in stairs) { var st= stair as Stairs; if(st!=null) { %code that is never executed } } return ret; } 

Now the problem is that no matter what the stairs seem to always be zero, I heard that another programmer had the same problem.

a stair variable gets several objects with stair properties (called a staircase that has risers and ext. platforms), but it doesn't really seem like they are being taken to the stairs. Does anyone know how to actually drop this onto a ladder (or else get all the ladders in a document?)

Please note that the staircase is an element with the following properties:

 Riser to Tread Connection Monolithic Material Apply Nosing Profile Stringer Material Text Size Begin with Riser Stringer Carriage Height URL Open Stringer Offset Right Stringer Riser Type Cost Left Stringer Underside of Winder Stringer Height Nosing Profile Manufacturer Middle Stringers Keynote Riser Material Minimum Tread Depth Text Font Monolithic Stairs Maximum Riser Height Landing Carriage Height Break Symbol in Plan Landing Overlap Extend Below Base Nosing Length Assembly Description End with Riser Description Function Type Image Type Comments Stringer Thickness Assembly Code Calculation Rules Trim Stringers at Top Model Tread Thickness Tread Material Riser Thickness 

I mainly need staircase objects to get runs associated with staircase objects, or actually I need the paths that the runs follow.

You can hopefully use the following:

  var tesselated = new List<XYZ>(); var stairPath = run.GetStairsPath(); foreach (Curve curve in stairPath) { tesselated.AddRange(curve.Tessellate()); } 

Because I need XYZ places for the positions of any stairs attached to the geometry of the building.

+5
source share
3 answers

First of all, you absolutely must find out and tell us which element you are talking about. Otherwise, this discussion is completely pointless. One very simple way to determine if you need to explore the staircase element using RevitLookup:

https://github.com/jeremytammik/RevitLookup

If you don’t know what RevitLookup is, you should completely stop everything else that you do with the Revit API and start from scratch, working on new Revit API material, especially installing and starting to use RevitLookup:

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

The selected filtered item-element retrieves all the items in the Stairs category. This “staircase” can be DirectShape, in which case you can assign the category “Stairs” to it. It will then be extracted by the filter of the filtered elements above.

Here is an example of a “staircase” extruded roof, which will always be and remains a roof, with the category “Roofs” and, therefore, can never be identified by your filter filter:

http://thebuildingcoder.typepad.com/blog/2014/09/events-again-and-creating-an-extrusion-roof.html#7

Sorry for the incomprehensible answer, but I have to say that your question is also quite confusing. Never heard anything like it before. Hope this helps.

+4
source

What you did looks reasonable, although as others have pointed out, it is obvious that somehow you are returning an element that is not a Stair element.

I would advise - to make sure you get back what you want, what you use:

.OfClass (TypeOf (stairs))

using the FilteredElementCollector filter. However, you can probably abandon the WhereElementIsNotElementType () and OfCategory () methods, since they are implicit in the above description.

Thus, everything that you return must be capable of action.

+1
source

The as operator returns null if a failure occurs, so any doc.GetElement(stairId) does not return a Stairs type or one of its subtypes.

I assume doc is a kind of “repository” document, so you probably need to create a new instance of Stairs and populate it with information obtained from what doc.GetElement(stairId) returns.

0
source

Source: https://habr.com/ru/post/1242543/


All Articles