You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

获取轴的交点:平面轴交点查找及实例族插入需求

在平面中查找轴网交点并插入族的方法

手动操作方案

  • 开启交点捕捉:激活Revit状态栏的「交点」捕捉按钮,放置族时鼠标会自动吸附到轴网交叉点,直接点击即可完成放置。
  • 批量标记辅助:使用系统自带或自定义的交点标记族,通过「放置在交点」命令批量标记所有轴网交点,再基于标记点批量插入目标族。

自动化(Revit API)方案

如果需要批量处理大量交点,可通过Revit API实现:

  1. 筛选目标平面内的轴网
    使用FilteredElementCollector获取文档中所有轴网,通过轴网的工作平面或标高筛选出目标平面内的实例。
  2. 计算轴网交点
    分离水平与垂直方向的轴网,遍历每一对轴网,调用Curve.Intersect()方法计算交点坐标。
  3. 插入族实例
    利用FamilyInstance.Create()方法,在计算得到的交点位置创建族实例,注意指定正确的工作平面和方向。

C#代码示例

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Collections.Generic;
using System.Linq;

public void CreateFamiliesAtGridIntersections(UIDocument uiDoc)
{
    Document doc = uiDoc.Document;
    // 替换为你的族类型ID和目标工作平面ID
    ElementId familySymbolId = new ElementId(12345);
    ElementId workPlaneId = new ElementId(67890);

    FamilySymbol familySymbol = doc.GetElement(familySymbolId) as FamilySymbol;
    if (familySymbol == null || !familySymbol.IsActive) return;

    WorkPlane workPlane = doc.GetElement(workPlaneId) as WorkPlane;
    if (workPlane == null) return;

    // 获取目标平面内的所有轴网并按方向分类
    var grids = new FilteredElementCollector(doc)
        .OfClass(typeof(Grid))
        .Cast<Grid>()
        .Where(g => g.GetWorkPlane().Id == workPlaneId)
        .ToList();

    var horizontalGrids = grids.Where(g => 
        g.Curve is Line line && Math.Abs(line.Direction.Y) > 0.9).ToList();
    var verticalGrids = grids.Where(g => 
        g.Curve is Line line && Math.Abs(line.Direction.X) > 0.9).ToList();

    // 事务内执行修改
    using (Transaction trans = new Transaction(doc, "Create Families at Grid Intersections"))
    {
        trans.Start();
        foreach (var hGrid in horizontalGrids)
        {
            foreach (var vGrid in verticalGrids)
            {
                IntersectionResult result;
                var intersectStatus = hGrid.Curve.Intersect(vGrid.Curve, out result);
                if (intersectStatus == SetComparisonResult.Overlap)
                {
                    XYZ intersectPoint = result.XYZPoint;
                    FamilyInstance.Create(doc, familySymbol, workPlane, intersectPoint, XYZ.BasisZ, StructuralType.NonStructural);
                }
            }
        }
        trans.Commit();
    }
}

内容的提问来源于stack exchange,提问作者andrey berkov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 01:10:55