/// <summary> /// Экземпляр класса с информацией по документу связанного файла /// </summary> public DocumentData(RevitLinkInstance link) { Basename = Regex.Match(link.Name, @"(.+)\.rvt").Groups[1].Value; IsLink = true; _Document = link.GetLinkDocument(); IsLoaded = _Document != null; Instance = link; InstanceCorrectionTransform = DocumentUtils.GetCorrectionTransform(link); }
public List <IntersectionMepCurve> GetIntersections() { linkedDocInstance = DocumentUtils.ChooseLinkedDoc(doc); if (linkedDocInstance == null) { return(new List <IntersectionMepCurve>()); } else { var progress = new UI.ProgressBar("Поиск пересечений...", hosts.Count()); Transform tr = DocumentUtils.GetCorrectionTransform(linkedDocInstance); List <IntersectionMepCurve> intersectionList = new List <IntersectionMepCurve>(); foreach (HostObject host in hosts) { List <Face> hostFaces = GeometryUtils.GetFaces(host); if (hostFaces.Count > 0) { BoundingBoxXYZ bb = host.get_BoundingBox(null); Outline outline = new Outline(tr.OfPoint(bb.Min), tr.OfPoint(bb.Max)); BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(outline); List <MEPCurve> meps = new FilteredElementCollector(linkedDoc) .OfClass(typeof(MEPCurve)) .WherePasses(filter) .Cast <MEPCurve>() .ToList(); foreach (MEPCurve m in meps) { Curve mepCurve = GeometryUtils.FindDuctCurve(m.ConnectorManager); if (mepCurve != null) { XYZ[] interPts = (from wallFace in hostFaces select FindFaceIntersection(mepCurve, wallFace)).ToArray(); if (interPts.Any(x => x != null)) { XYZ pt = interPts.First(x => x != null); try { IntersectionMepCurve i = new IntersectionMepCurve(host, m, pt, linkedDocInstance); intersectionList.Add(i); } catch (NotImplementedException) { } } } } } progress.StepUp(); } progress.Close(); return(intersectionList); } }
protected XYZ FindFaceIntersection(Curve DuctCurve, Face WallFace) { // Коррекция позиции связанного файла // Так как перемещаем не ПЛОСКОСТЬ, а ЛУЧИ, то инвертируем перемещение Transform tf = DocumentUtils.GetCorrectionTransform(linkedDocInstance); tf = tf.Inverse; Curve correctedCurve = DuctCurve.CreateTransformed(tf); //The intersection point //Intersection point set SetComparisonResult results; results = WallFace.Intersect(correctedCurve, out IntersectionResultArray intersectionR); if (SetComparisonResult.Disjoint != results && intersectionR != null && !intersectionR.IsEmpty) { return(intersectionR.get_Item(0).XYZPoint); } else { return(null); } }