在链接和元素之间添加尺寸

问题描述 投票:0回答:2

我试图找到链接墙面,但是当我使用引用创建新维度时,我将得到有关“引用数量无效”的结果。我无法将脸部链接到活动脸部。

 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            var rf1 = uidoc.Selection.PickObject(ObjectType.PointOnElement, "select");
            var element1 = doc.GetElement(rf1);
            var location = element1.Location as LocationPoint;
            var point = location.Point;
            var rf2 = uidoc.Selection.PickObject(ObjectType.LinkedElement, "select");
            var linkElement = doc.GetElement(rf2) as RevitLinkInstance;
            var linkDoc = linkElement.GetLinkDocument();
            var linkWall = linkDoc.GetElement(rf2.LinkedElementId) as Wall;
            var wallLocation = linkWall.Location as LocationCurve;
            var curve = wallLocation.Curve;
            var cRf = curve.Reference;
            var solid = BIMTools.Geometry.GetSolid(linkWall);
            Face face = null;
            
            foreach (var solidFace in solid.Faces)
            {
                XYZ normal = ((Face)solidFace).ComputeNormal(new UV(0, 0));
                if (normal.Y < 0)
                {
                    face = solidFace as Face;
                    break;
                }
            }
            var viewLevel = uidoc.ActiveView.GenLevel.Elevation;
            var tPoint = new XYZ(point.X,(face as PlanarFace).Origin.Y, viewLevel);
            point = new XYZ(point.X, point.Y, viewLevel);

            var line = Line.CreateBound(point, tPoint);
            var references = new ReferenceArray();
            references.Append(rf1);
            references.Append(face.Reference);

            using (Transaction trans = new Transaction(doc,"create"))
            {
                trans.Start();
                var dimension = doc.Create.NewDimension(uidoc.ActiveView, line, references);
                trans.Commit();
            }
            return Result.Succeeded;
        }
revit-api
2个回答
0
投票

The Building Coder 提供了有关创建尺寸标注的完整文章列表。


0
投票

您解决过这个问题吗?我遇到了同样的问题。我的插件将在项目中的元素上放置尺寸。链接文件中完全相同的元素,我收到引用错误(即使在文档中找到并使用了 2 个引用。Create.NewDimension()。

我在 The Building Coder 中找不到答案,没有找到尺寸标注链接元素的信息。

© www.soinside.com 2019 - 2024. All rights reserved.