Revit API:更改横断面图的视图方向和深度

时间:2018-10-16 11:07:28

标签: c# revit-api

我对Revit API还是很陌生,我一直在用Section视图抓挠头。我有从这里创建剖面图的想法:

http://thebuildingcoder.typepad.com/blog/2011/07/section-view-creation.html

但是,无论我做什么,似乎都无法确定视图方向和剖视图的“深度”。结果始终是一个剖面图,可让我从模型的下方向上看(视图方向=(0,0,-1)),而且我总是看到模型的表面,而不是通过其核心进行完全切割。

由于视图的“视图方向”,“上方向”和“右方向”属性没有set(),因此我假定只能从创建横断面图的过程中实现所需的目标。

我试图更改边界框的视图,边界框上的最小和最大点...但是结果是相同的。这是我的代码

private void CreateSectionView(FamilyInstance beam)
    {
        // I tried to change the input view here
        View view = new FilteredElementCollector(_doc)
                        .OfCategory(BuiltInCategory.OST_Views)
                        .OfType<View>()
                        .FirstOrDefault(x => x.Name.Equals("East"));

        BoundingBoxXYZ boxXYZ = beam.get_BoundingBox(view);
        // determine the size of the box
        double length = boxXYZ.Max.X - boxXYZ.Min.X;
        double width = boxXYZ.Max.Y - boxXYZ.Min.Y;
        double height = boxXYZ.Max.Z - boxXYZ.Min.Z;

        // determine min point and max point
        // I tried to changed values here
        XYZ maxPt = new XYZ(length, width, 0);
        XYZ minPt = new XYZ(0, 0, height);
        XYZ middle = (boxXYZ.Max + boxXYZ.Min) / 2;

        // crate transform 
        // tried here
        Transform transform = Transform.Identity;
        transform.BasisX = XYZ.BasisX;
        transform.BasisY = XYZ.BasisZ;
        transform.BasisZ = XYZ.BasisY.Negate();
        transform.Origin = middle;

        // crate bounding box for section view
        BoundingBoxXYZ box = new BoundingBoxXYZ();
        box.Max = maxPt;
        box.Min = minPt;
        box.Transform = transform;


        // create a bounding box
        ElementId viewTypeId = GetSectionViewTypeId(ViewFamily.Section);
        ViewSection sectionView = ViewSection.CreateSection(_doc, viewTypeId, boxXYZ);            
    }

我错过了什么或做错了什么?如何实现我想要的(从下至上的视图,并从其核心切开,以其他角度查看该元素)?

0 个答案:

没有答案