How to find start/end of ramp in revit, perhaps with sketches?
Asked Answered
H

1

35

I have a bunch of ramps that I would like to know the begin and end points of (and in case of multiple begin/end points I would like to know how they connect). I currently get these as

List<TransitionPoint> ret = new List<TransitionPoint>();
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> ramps = collector.OfCategory(BuiltInCategory.OST_Ramps).ToElements();

foreach (var ramp in ramps)
{
   //what goes here?
}

These ramps contain the following properties:

Type Comments
Ramp Max Slope (1/x)
Category
URL
Design Option
Type Name
Ramp Material
Function
Manufacturer
Family Name
Model
Keynote
Type Image
Text Size
Shape
Text Font
Maximum Incline Length
Assembly Description
Assembly Code
Type Mark
Category
Thickness
Cost
Description

Now if these where stairs I would use ICollection stairs = collector.OfCategory(BuiltInCategory.OST_Stairs).OfClass(typeof(Stairs)).ToElements(); and then I can cast the objects into Stairs however there does not appear to be a class simmulair to Stairs which would allow me to adres Stairs.GetStairsRuns().

Anybody know how to either get something like a RampRun or otherwise find the start and end of a ramp?

I have also tried the following sollution but that didn't work either

public static void MapRunsToRamps(Document doc)
{
   var rule = ParameterFilterRuleFactory.CreateNotEqualsRule(new ElementId(BuiltInParameter.HOST_ID_PARAM), "null", true);

   ElementParameterFilter filter = new ElementParameterFilter(rule);
   FilteredElementCollector collector = new FilteredElementCollector(doc);
   List<Element> rampsRuns = collector.WherePasses(filter).ToElements().ToList<Element>();
   foreach (Element e in rampsRuns)
   {
      var hostpara = e.get_Parameter(BuiltInParameter.HOST_ID_PARAM);
      if (hostpara != null)
      {
         var host = doc.GetElement(new ElementId(hostpara.AsInteger()));
         if (host.Category.Equals(BuiltInCategory.OST_Ramps))
         {
            //breakpoint that is never activated 
         }
      }
   }
}

This finds plenty of objects just none with a ramp as a host.

Here is an example of a ramp and the location I'm trying to find marked with red arrows. ramps marked with red arrows

this https://forums.autodesk.com/t5/revit-api/how-do-we-get-the-x-y-z-cordinates-for-stairs-ramps/td-p/2575349 suggests that we can use a locationcurve, any way to do that?

edit: There do appear to be sketches based on which we might be able to find the ramps, question is if I have a sketch say with

    var rampCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_StairsSketchRunLines);
    var rampsRuns = new FilteredElementCollector(doc).WherePasses(rampCategoryfilter);

then I can indeed get the locations but what I do not have is the ramp that this belongs too, any idea how to find that?

Hocker answered 29/2, 2016 at 12:26 Comment(12)
And which Revit version are you using?Smelt
I'm developing for 2015-2016 and 2017Hocker
Take a look at this: knowledge.autodesk.com/de/support/revit-products/learn-explore/… (check the GetStairLandings method)Smelt
I know the stairs component quite well, my problem would be solved if I could do the same (get runs ext.) with ramps as with stairs but I cannot cast ramps into a ramps class as easily as I can cast stairs.Hocker
have you explored your ramp with RevitLookup? is it point based, curve based, or sketch based? Can you not extract the required information from the pure ramp geometry?Commeasure
The ramp can be any of them but let's start by point based. I have looked at the object in the revitlookup which gives access to the same parameters as I printed above. How would I get the data from the pure ramp geometry? I think that some sort of ramp runs contain the underlying data which would be hosted by the ramps can we use that somehow?Hocker
Futher update, it appears that it's possible to get stairruns but it' s unclear how to then cast them too actual stairrun objects.Hocker
So the latest status is that if we can somehow get the run from a StairsRunType then we have solved this, anybody got any idea? The internet seems to contain no more information about the StairsRunType class than that it was added in revit 2013 and that it can be used to get certain information about stairs.Hocker
Never mind that there was something weird with my test case.Hocker
So how do we find which sketch is assosiated with a particulair ramp?Hocker
i still have not heard a clear answer on the following questions, which can both be answered quite simply by snooping the ramp with RevitLookup: (i) does the ramp have a non-null Location property? (ii) is it a LocationCurve? if so, the location curve start and end point might give you what you need. (iii) have you explored the ramp geometry? returned by the Element.Geometry property via the get_Geometry method. you might be able to determine the desired start and end point from that.Commeasure
Regarding access to the sketch, here are two work-around hints: thebuildingcoder.typepad.com/blog/2010/11/…; thebuildingcoder.typepad.com/blog/2011/11/…Commeasure
T
4

Assuming that your Ramp is a FamilyInstance :

var fecRamps = new FilteredElementCollector(doc)
    .OfClass(typeof(FamilyInstance))
    .Where(pElt =>
    {
        int lCatId = pElt.Category.Id.IntegerValue;
        return lCatId == (int)BuiltInCategory.OST_Ramps;
    })
    .OfType<FamilyInstance>()
    .ToList();

List<XYZ> lRampLocs = new List<XYZ>();
foreach (var pFam in fecRamps)
{
    var fLoc = pFam.Location as LocationCurve;
    var fRampSide1 = new XYZ(fLoc.Curve.GetEndPoint(0);
    var fRampSide2 = new XYZ(fLoc.Curve.GetEndPoint(1);

    lRampLocs.Add(fRampSide1);
    lRampLocs.Add(fRampSide2);
}

Every FamilyInstance has a Location and you can cast the Location as a LocationCurve. From the curve, you can get the end points via the Autodesk.Revit.DB namespace.

Thegn answered 25/1, 2017 at 16:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.