要查找与几何体相交的元素,我将使用Jeremy在其博客http://thebuildingcoder.typepad.com/blog/2010/12/find-intersecting-elements.html中的示例帖子。但是边界框总是与X,Y和Z轴并列,这可能会导致问题,例如返回元素并非真正发生冲突,因为有时边界框并不总是与几何重合,因为旋转了族实例。除此之外,还有一个问题是边界框会考虑符号的几何形状而不是实例,并且也会考虑翻转的几何体,这意味着边界框比我想要的要大。有没有办法获得当前视图中的真实几何?我该如何解决这个问题?
答案 0 :(得分:1)
我正在使用另一个策略,该策略访问实例的几何,以验证家庭实体的面部是否与更近的管道发生冲突。
class FindIntersection
{
public Conduit ConduitRun { get; set; }
public FamilyInstance Jbox { get; set; }
public List<Conduit> GetListOfConduits = new List<Conduit>();
public FindIntersection(FamilyInstance jbox, UIDocument uiDoc)
{
XYZ jboxPoint = (jbox.Location as LocationPoint).Point;
FilteredElementCollector filteredCloserConduits = new FilteredElementCollector(uiDoc.Document);
List<Element> listOfCloserConduit = filteredCloserConduits.OfClass(typeof(Conduit)).ToList().Where(x =>
((x as Conduit).Location as LocationCurve).Curve.GetEndPoint(0).DistanceTo(jboxPoint) < 30 ||
((x as Conduit).Location as LocationCurve).Curve.GetEndPoint(1).DistanceTo(jboxPoint) < 30).ToList();
//getting the location of the box and all conduit around.
Options opt = new Options();
opt.View = uiDoc.ActiveView;
GeometryElement geoEle = jbox.get_Geometry(opt);
//getting the geometry of the element to acess the geometry of the instance.
foreach (GeometryObject geomObje1 in geoEle)
{
GeometryElement geoInstance = (geomObje1 as GeometryInstance).GetInstanceGeometry();
//the geometry of the family instance can be acess by this method that returns a GeometryElement type.
//so we must get the GeometryObject again to acess the Face of the family instance.
if (geoInstance != null)
{
foreach (GeometryObject geomObje2 in geoInstance)
{
Solid geoSolid = geomObje2 as Solid;
if (geoSolid != null)
{
foreach (Face face in geoSolid.Faces)
{
foreach (Element cond in listOfCloserConduit)
{
Conduit con = cond as Conduit;
Curve conCurve = (con.Location as LocationCurve).Curve;
SetComparisonResult set = face.Intersect(conCurve);
if (set.ToString() == "Overlap")
{
//getting the conduit the intersect the box.
GetListOfConduits.Add(con);
}
}
}
}
}
}
}
}
}
答案 1 :(得分:0)
您能提供一个complete minimal reproducible case,以便我们了解具体情况并分析可以做些什么吗?也许你可以包括一个轴对齐的接线盒和一个不对的接线盒,因此我们可以看到你的现有算法执行的程度与多么糟糕。谢谢!
答案 2 :(得分:0)
我在filtering for intersecting elements and conduits intersecting a junction box的博客文章中总结了此讨论和迄今为止的结果。