我有一堆斜坡,我想知道它们的起点和终点(在有多个起点/终点的情况下,我想知道它们是如何连接的)。
我目前得到这些

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?
}

这些斜坡包含以下属性:
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

现在,如果这些楼梯在哪里,我将使用ICollection stairs = collector.OfCategory(BuiltInCategory.OST_Stairs).OfClass(typeof(Stairs)).ToElements();然后我可以将对象转换到Stairs中,但是似乎没有Stairs的类模拟器可以让我接受Stairs.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
         }
      }
   }
}

这样可以找到许多对象,而没有任何对象以斜坡为宿主。

这是一个坡道和我要查找的位置(用红色箭头标记)的示例。
c# - 如何在Revit中找到坡道的起点/终点,也许有草图?-LMLPHP

这个https://forums.autodesk.com/t5/revit-api/how-do-we-get-the-x-y-z-cordinates-for-stairs-ramps/td-p/2575349建议我们可以使用locationcurve,可以采用任何方法吗?

编辑:
确实有一些草图,我们可以根据这些草图找到坡道,问题是我是否有一个草图与
    var rampCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_StairsSketchRunLines);
    var rampsRuns = new FilteredElementCollector(doc).WherePasses(rampCategoryfilter);

那么我确实可以获得位置,但我所没有的也就是它所属的坡道,您知道如何找到它吗?

最佳答案

假设您的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);
}

每个FamilyInstance都有一个Location,您可以将Location转换为LocationCurve。从曲线上,您可以通过Autodesk.Revit.DB命名空间获取端点。

10-07 13:51