在做项目的过程中,轴网都是进行翻模或者拾取,而翻模出来的轴网往往都是不堪入目的,为了满足项目需要,做了轴网对齐的功能,废话不多说,直接上干货。
首先做一些准备工作,先建立一个轴网过滤类,接下来会用到,代码如下:
class GridSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element element)
{
int idValue = element.Category.Id.IntegerValue;
if (idValue == (int)BuiltInCategory.OST_Grids)
{
return true;
}
return false;
}
public bool AllowReference(Reference reference, XYZ position)
{
return false;
}
}
接下来就是真正的主题轴网对齐,代码如下:
//新建轴网选择过滤器;
GridSelectionFilter gridSelectionFilter = new GridSelectionFilter();
//框选轴网;
IList<Element> r