예제 #1
0
파일: Outline.cs 프로젝트: ksobon/archilab
 internal Outline(Autodesk.Revit.DB.Outline o)
 {
     InternalOutline = o;
 }
예제 #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var points = new List <Rhino.Geometry.Point3d>();

            if (!DA.GetDataList("Points", points))
            {
                return;
            }

            var tolerance = 0.0;

            if (!DA.GetData("Tolerance", ref tolerance))
            {
                return;
            }

            var boundingBox = true;

            if (!DA.GetData("BoundingBox", ref boundingBox))
            {
                return;
            }

            var strict = true;

            if (!DA.GetData("Strict", ref strict))
            {
                return;
            }

            var inverted = false;

            if (!DA.GetData("Inverted", ref inverted))
            {
                return;
            }

            var scaleFactor = 1.0 / Revit.ModelUnits;

            var targets = new List <Rhino.Geometry.Box>();

            Autodesk.Revit.DB.ElementFilter filter = null;

            if (boundingBox)
            {
                var pointsBBox = new Rhino.Geometry.BoundingBox(points);
                {
                    var box = new Rhino.Geometry.Box(pointsBBox);
                    box.Inflate(tolerance);
                    targets.Add(box);
                }

                pointsBBox = pointsBBox.Scale(scaleFactor);
                var outline = new Autodesk.Revit.DB.Outline(pointsBBox.Min.ToHost(), pointsBBox.Max.ToHost());

                if (strict)
                {
                    filter = new Autodesk.Revit.DB.BoundingBoxIsInsideFilter(outline, tolerance * scaleFactor, inverted);
                }
                else
                {
                    filter = new Autodesk.Revit.DB.BoundingBoxIntersectsFilter(outline, tolerance * scaleFactor, inverted);
                }
            }
            else
            {
                var filters = points.Select <Rhino.Geometry.Point3d, Autodesk.Revit.DB.ElementFilter>
                                  (x =>
                {
                    var pointsBBox = new Rhino.Geometry.BoundingBox(x, x);
                    {
                        var box = new Rhino.Geometry.Box(pointsBBox);
                        box.Inflate(tolerance);
                        targets.Add(box);
                    }

                    x           = x.Scale(scaleFactor);
                    var outline = new Autodesk.Revit.DB.Outline(x.ToHost(), x.ToHost());

                    if (strict)
                    {
                        return(new Autodesk.Revit.DB.BoundingBoxIsInsideFilter(outline, tolerance * scaleFactor, inverted));
                    }
                    else
                    {
                        return(new Autodesk.Revit.DB.BoundingBoxIntersectsFilter(outline, tolerance * scaleFactor, inverted));
                    }
                });

                filter = new Autodesk.Revit.DB.LogicalOrFilter(filters.ToList());
            }

            DA.SetDataList("Target", targets);
            DA.SetData("Filter", filter);
        }