简体   繁体   English

使用 Revit API 放置实例时如何考虑 Revit 项目基点位置

[英]How can I take into consideration Revit Project Base Point location when placing instances using Revit API

无需手动移动的位置

[![Correct location when moved from base point location to survey point][2]][2] [![从基点位置移动到测量点时的正确位置][2]][2]

基点距测量点的尺寸

I'm in the process of writing a program to show navisworks clash points in Revit, however, i'm finding it difficult to place them at the exact location when the Base point is not (0,0,0).我正在编写一个程序以在 Revit 中显示 navisworks 冲突点,但是,当基点不是 (0,0,0) 时,我发现很难将它们放置在确切的位置。 When i manually add the difference in location to the code, it works.当我手动将位置差异添加到代码中时,它可以工作。 How do I solve this programmatically?如何以编程方式解决此问题? I understand there is probably a simple calculation to solve but i can't seem to figure it out.我知道可能有一个简单的计算要解决,但我似乎无法弄清楚。 I go some ideas from googling around to be no avail.我 go 谷歌搜索的一些想法无济于事。 Any ideas how to go about this?任何想法如何 go 关于这个?

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; 

        }

This returns the location of the survey point to the base point.这会将测量点的位置返回到基点。 Solving my question.解决我的问题。

   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;

                }
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM