【问题标题】:How can I take into consideration Revit Project Base Point location when placing instances using Revit API使用 Revit API 放置实例时如何考虑 Revit 项目基点位置
【发布时间】:2020-10-24 02:47:24
【问题描述】:

[![从基点位置移动到测量点时的正确位置][2]][2]

我正在编写一个程序以在 Revit 中显示 navisworks 碰撞点,但是,当基点不是 (0,0,0) 时,我发现很难将它们放置在确切的位置。当我手动将位置差异添加到代码中时,它可以工作。如何以编程方式解决此问题?我知道可能有一个简单的计算要解决,但我似乎无法弄清楚。我从谷歌上搜索了一些想法,但无济于事。有什么想法可以解决这个问题吗?

public static XYZ WorldToLocal(Document document, XYZ coordinate, bool millimeters)
        {
            ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);
            FilteredElementCollector collector = new FilteredElementCollector(document);
            IList<Element> oProjectBasePoints = collector.WherePasses(filter).ToElements();

            Element oProjectBasePoint = null;

            foreach (Element bp in oProjectBasePoints)
            {
                oProjectBasePoint = bp;
                break;
            }

            double x = oProjectBasePoint.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble();
            double y = oProjectBasePoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble();
            double z = oProjectBasePoint.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble();
            double r = oProjectBasePoint.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM).AsDouble();

            XYZ result = new XYZ(
             coordinate.X * Math.Cos(r) - coordinate.Y * Math.Sin(r) ,
             coordinate.X * Math.Sin(r) + coordinate.Y * Math.Cos(r),
             coordinate.Z);

//Code that makes it work
            XYZ newpostion = new XYZ(result.X - 21.943, result.Y +13.410, result.Z);
//ends here
            if (millimeters)
            {
                return newpostion * 304.8;
            }
            return newpostion; 

        }

【问题讨论】:

    标签: c# revit-api autodesk-navisworks


    【解决方案1】:

    这会将测量点的位置返回到基点。解决我的问题。

       IEnumerable<BasePoint> points = new FilteredElementCollector(document)
                    .OfClass(typeof(BasePoint))
                    .Cast<BasePoint>();
    
                XYZ surveypointXYZ = new XYZ();
                foreach (BasePoint bp in points)
                {
                    if (bp.IsShared)
                    {
                        BoundingBoxXYZ bb = bp.get_BoundingBox(null);
                        surveypointXYZ = bb.Min;
    
                    }
                }
    

    【讨论】:

      猜你喜欢
      • 2022-09-27
      • 2011-02-14
      • 1970-01-01
      • 2023-03-30
      • 2020-09-15
      • 2019-08-14
      • 2020-04-20
      • 1970-01-01
      • 2013-01-07
      相关资源
      最近更新 更多