public override void Apply(AvoidData data)
 {
     Autodesk.Revit.DB.ElementTransformUtils.MoveElement(data.Document, new ElementId(data.Entity.LineId), GetSideVector());
     foreach (var tagId in data.Entity.TagIds)
     {
         Autodesk.Revit.DB.ElementTransformUtils.MoveElement(data.Document, new ElementId(tagId), GetSideVector());
     }
 }
Example #2
0
        /// <summary>
        /// 避让测试
        /// return true when collided
        /// return false when passed
        /// </summary>
        /// <returns></returns>
        public bool CheckCollision(AvoidData data, bool tryAvoid = false)
        {
            Document document = data.Document;
            View     view     = document.ActiveView;
            IEnumerable <ElementId> selectedPipeIds = data.SelectedPipeIds;
            ElementId    currentLineId     = new ElementId(data.Entity.LineId);
            List <Line>  currentLines      = tryAvoid ? data.TemporaryLines : data.CurrentLines;
            VLTriangle   currentTriangle   = tryAvoid ? data.TemporaryTriangle : data.CurrentTriangle;
            FamilySymbol multipleTagSymbol = data.MultipleTagSymbol;
            //管道避让
            var otherPipeLines = new FilteredElementCollector(document).OfClass(typeof(Pipe))
                                 .Select(c => Line.CreateBound((c.Location as LocationCurve).Curve.GetEndPoint(0), (c.Location as LocationCurve).Curve.GetEndPoint(1))).ToList();
            var pipeCollisions = new FilteredElementCollector(document).OfClass(typeof(Pipe)).Excluding(selectedPipeIds.ToList())
                                 .Select(c => Line.CreateBound((c.Location as LocationCurve).Curve.GetEndPoint(0), (c.Location as LocationCurve).Curve.GetEndPoint(1))).ToList()
                                 .Where(c => VLGeometryHelper.IsPlanarCover(currentLines, currentTriangle, c) != VLGeometryHelper.VLCoverType.Disjoint).ToList();
            //标注避让
            var collector = new FilteredElementCollector(document).OfClass(typeof(FamilyInstance)).WhereElementIsNotElementType().Excluding(new List <ElementId>()
            {
                currentLineId
            });
            var otherLines    = collector.Where(c => (c as FamilyInstance).Symbol.Id == multipleTagSymbol.Id);
            var boundingBoxes = otherLines.Select(c => c.get_BoundingBox(view));
            List <BoundingBoxXYZ> crossedBoundingBox   = new List <BoundingBoxXYZ>();
            List <BoundingBoxXYZ> uncrossedBoundingBox = new List <BoundingBoxXYZ>();

            foreach (var boundingBox in boundingBoxes.Where(c => c != null))
            {
                if (VLGeometryHelper.VL_IsRectangleCrossed(currentTriangle.A, currentTriangle.C, boundingBox.Min, boundingBox.Max))
                {
                    crossedBoundingBox.Add(boundingBox);
                }
                else
                {
                    uncrossedBoundingBox.Add(boundingBox);
                }
            }
            PmSoft.Optimization.DrawingProduction.Utils.GraphicsDisplayerManager.Display(@"E:\WorkingSpace\Outputs\Images\0822标注避让.png", tryAvoid ? data.TemporaryTriangle : data.CurrentTriangle, otherPipeLines, pipeCollisions, crossedBoundingBox, uncrossedBoundingBox);
            return(pipeCollisions.Count() > 0 || crossedBoundingBox.Count() > 0);
        }
Example #3
0
 /// <summary>
 /// 应用避让
 /// </summary>
 public abstract void Apply(AvoidData data);
Example #4
0
 public override void Apply(AvoidData data)
 {
 }