Revit二次开发之技能篇(二)———轴网尺寸标注

在利用revit出图时,避免不了要对轴网进行标注,下面分享一下轴网尺寸标注的一些开发经验:

轴网尺寸标注:

首先要获取到尺寸标注的引用,将引用添加到引用集合中,关键代码如下:

  ReferenceArray array = new ReferenceArray();
  array.Append(new Reference(grid));

然后就是获取到需要尺寸标注的位置,在轴网的Curve上获取点,距离起始点一定距离的方法代码如下:

 public static XYZ getStartPoint(Line line, double length)
        {

            XYZ start = line.GetEndPoint(0);
            XYZ dir = line.Direction;
            XYZ tempone = start + length * dir;
            return tempone;
        }

距离终止点一定距离的方法代码类似:

  public static XYZ getEndPoint(Line line, double length)
        {
            XYZ end = line.GetEndPoint(1);
            XYZ dir = line.Direction;
            XYZ temptwo = end - length * dir;
            return temptwo;
        }

获取到轴网上的点,连接相邻轴网上的点,利用新建尺寸标注方法就可以进行轴网尺寸标注了;

  Transaction tran = new Transaction(doc);
                    tran.Start("轴网尺寸标记");
                    Dimension nowDim = doc.Create.NewDimension(doc.ActiveView, nowLine, arrayTwo);
                    tran.Commit();

其中nowLine为相邻轴网所取点构造的新的Line,arrayTwo为轴网引用的集合!

分享就到这里,如有疑问或者更好的开发思路请留言;

版权归个人所有转载请注明网址:https://blog.csdn.net/fengmochen/article/details/85958150

猜你喜欢

转载自blog.csdn.net/fengmochen/article/details/85958150