如何在revit中找到ramp的开始/结束,也许用草图?

Thi*_*ser 34 c# api autodesk revit revit-api

我有一堆斜坡,我想知道它的开始和结束点(如果有多个开始/结束点,我想知道它们是如何连接的).我目前得到这些

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?
}
Run Code Online (Sandbox Code Playgroud)

这些斜坡包含以下属性:

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
Run Code Online (Sandbox Code Playgroud)

现在,如果这些楼梯我将使用ICollection stairs = collector.OfCategory(BuiltInCategory.OST_Stairs).OfClass(typeof(Stairs)).ToElements(); 然后我可以将对象投射到楼梯但是似乎没有一个类的simmulair到楼梯,这将允许我adresStairs.GetStairsRuns().

任何人都知道如何获得像RampRun这样的东西或者找到斜坡的开始和结束?

我也尝试了以下溶剂,但这也没有用

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 
         }
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

这会找到大量的对象,只有一个斜坡作为主机.

这是一个斜坡的例子,我试图找到标有红色箭头的位置. 斜坡标有红色箭头

这个https://forums.autodesk.com/t5/revit-api/how-do-we-get-the-xyz-cordinates-for-stairs-ramps/td-p/2575349建议我们可以使用位置曲线,任何方式这样做?

编辑:似乎有基于我们可以找到斜坡的草图,问题是我是否有草图说

    var rampCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_StairsSketchRunLines);
    var rampsRuns = new FilteredElementCollector(doc).WherePasses(rampCategoryfilter);
Run Code Online (Sandbox Code Playgroud)

那么我确实可以获得位置,但我没有的是它所属的斜坡,任何想法如何找到它?

Uch*_*chi 4

假设您RampFamilyInstance

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);
}
Run Code Online (Sandbox Code Playgroud)

每个FamilyInstance都有 aLocation并且您可以将 the 转换Location为 a LocationCurve。从曲线中,您可以通过名称空间获取端点Autodesk.Revit.DB