コード例 #1
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // grab input
            DB.Wall wallInstance = default;
            if (!DA.GetData("Curtain Wall", ref wallInstance))
            {
                return;
            }

            // only process curtain walls
            if (wallInstance.WallType.Kind == DB.WallKind.Curtain)
            {
                DA.SetData("Curtain Grid", new Types.DataObject <DB.CurtainGrid>(wallInstance.CurtainGrid, srcDocument: wallInstance.Document));

                // determine if curtain wall is embeded in another wall
                // find all the wall elements that are intersecting the bbox of this wall
                var bbox    = wallInstance.get_BoundingBox(null);
                var outline = new DB.Outline(bbox.Min, bbox.Max);
                var bbf     = new DB.BoundingBoxIntersectsFilter(outline);
                var walls   = new DB.FilteredElementCollector(wallInstance.Document).WherePasses(bbf).OfClass(typeof(DB.Wall)).ToElements();
                // ask for embedded wall inserts from these instances
                foreach (DB.Wall wall in walls)
                {
                    var embeddedWalls = wall.FindInserts(addRectOpenings: false, includeShadows: false, includeEmbeddedWalls: true, includeSharedEmbeddedInserts: false);
                    if (embeddedWalls.Contains(wallInstance.Id))
                    {
                        DA.SetData("Host Wall", Types.Element.FromElement(wall));
                        break;
                    }
                }
            }
        }
コード例 #2
0
ファイル: View.cs プロジェクト: andradam75/Synthetic
        /// <summary>
        /// Given a list of viewports, grid spacing and an origin point, function will renumber the viewports based on grid location.
        /// </summary>
        /// <param name="viewports">Revit ViewPorts</param>
        /// <param name="gridX">Grid spacing in the X direction</param>
        /// <param name="gridY">Grid spacing in the Y direction</param>
        /// <param name="originX">X coordinate of the grid origin</param>
        /// <param name="originY">Y coordinate of the grid origin</param>
        /// <returns name="viewports">The renumbered Revit ViewPorts</returns>
        internal static List <revitViewport> _renumberViewports(List <revitViewport> viewports, double gridX, double gridY, double originX, double originY)
        {
            //const double viewportOffset = 0.0114;

            //int i = 1;

            foreach (revitViewport vp in viewports)
            {
                revitOutline labelOutline = vp.GetLabelOutline();
                revitXYZ     minPt        = labelOutline.MinimumPoint;

                string viewNumber = _calculateViewNumber(minPt.X, minPt.Y, gridX, gridY, originX, originY);

                revitDB.Parameter param = vp.get_Parameter(revitDB.BuiltInParameter.VIEWPORT_DETAIL_NUMBER);
                if (param != null)
                {
                    param.Set(viewNumber);
                }

                //double x = Math.Floor(((minPt.X - originX) + viewportOffset) / gridX + 1);
                //double y = Math.Floor(((minPt.Y - originY) + viewportOffset) / gridY + 1);

                //if (x > 0 && y > 0)
                //{
                //    char yChar = (char)('A' - 1 + y);
                //    string yString = yChar.ToString();

                //    vp.get_Parameter(revitDB.BuiltInParameter.VIEWPORT_DETAIL_NUMBER).Set(yString + x);
                //}
                //else
                //{
                //    vp.get_Parameter(revitDB.BuiltInParameter.VIEWPORT_DETAIL_NUMBER).Set("!!" + i + "!!");
                //}
            }

            return(viewports);
        }
コード例 #3
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.ChangeUnits(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.ChangeUnits(scaleFactor);

                    if (strict)
                    {
                        var outline = new Autodesk.Revit.DB.Outline(x.ToHost(), x.ToHost());
                        return(new Autodesk.Revit.DB.BoundingBoxIsInsideFilter(outline, tolerance * scaleFactor, inverted));
                    }
                    else
                    {
                        return(new Autodesk.Revit.DB.BoundingBoxContainsPointFilter(x.ToHost(), tolerance * scaleFactor, inverted));
                    }
                });

                var filterList = filters.ToArray();
                filter = filterList.Length == 1 ?
                         filterList[0] :
                         new Autodesk.Revit.DB.LogicalOrFilter(filterList);
            }

            DA.SetData("Filter", filter);
            DA.SetDataList("Target", targets);
        }
コード例 #4
0
 public static BoundingBox ToBoundingBox(this DB.Outline value)
 {
     return(new BoundingBox(value.MinimumPoint.ToPoint3d(), value.MaximumPoint.ToPoint3d()));
 }
コード例 #5
0
        public static List <Model.Entity.Pile> GetIntersectEttPiles(this Model.Entity.Element ettElem)
        {
            var setting               = ModelData.Instance.Setting;
            var settingCate           = setting.Category.Id;
            var verOrHorFraming       = setting.VerOrHor;
            var distanceFromPile2Path = setting.DistanceFromPile2Path;
            List <Model.Entity.Pile> intersectEttPiles = new List <Model.Entity.Pile>();
            //var foundationCate = new Autodesk.Revit.DB.ElementCategoryFilter(BuiltInCategory.OST_StructuralFoundation);
            var cateFilter        = new Autodesk.Revit.DB.ElementCategoryFilter(settingCate);
            var revitElem         = ettElem.RevitElement;
            var bbRevitElem       = revitElem.get_BoundingBox(null);
            var ol                = new Autodesk.Revit.DB.Outline(bbRevitElem.Min, bbRevitElem.Max);
            var bbIntersectFilter = new Autodesk.Revit.DB.BoundingBoxIntersectsFilter(ol);
            var intersectPiles    = new FilteredElementCollector(revitData.Document).WherePasses(cateFilter)
                                    .WherePasses(bbIntersectFilter).ToList();
            var   curvePath    = (revitElem.Location as LocationCurve).Curve;
            XYZ   itemPoint    = null;
            Curve curveFraming = null;

            //revitData.Selection.SetElementIds(intersectPiles.Select(x => x.Id).ToList()); // Test Intersected Pile
            foreach (var item in intersectPiles)
            {
                if (settingCate.IntegerValue == (int)BuiltInCategory.OST_StructuralFoundation)
                {
                    itemPoint = (item.Location as LocationPoint).Point;
                }
                else if (settingCate.IntegerValue == (int)BuiltInCategory.OST_StructuralFraming)
                {
                    curveFraming = (item.Location as LocationCurve).Curve;
                    itemPoint    = (curveFraming.GetEndPoint(0) + curveFraming.GetEndPoint(1)) / 2;
                }
                var    intersectionResult = curvePath.Project(itemPoint);
                var    projection2curve   = intersectionResult.XYZPoint;
                double distance2P         = itemPoint.Distance2P(projection2curve);

                if (distance2P < distanceFromPile2Path.milimeter2Feet())
                {
                    switch (verOrHorFraming)
                    {
                    case Model.Entity.VerOrHor.HorizontalX:
                    {
                        if ((curveFraming as Line).Direction.IsXOrY())
                        {
                            intersectEttPiles.Add(new Model.Entity.Pile {
                                    RevitElement = item
                                });
                        }
                        break;
                    }

                    case Model.Entity.VerOrHor.VerticalY:
                    {
                        if (!(curveFraming as Line).Direction.IsXOrY())
                        {
                            intersectEttPiles.Add(new Model.Entity.Pile {
                                    RevitElement = item
                                });
                        }
                        break;
                    }

                    default:
                    {
                        intersectEttPiles.Add(new Model.Entity.Pile {
                                RevitElement = item
                            });

                        break;
                    }
                    }
                    //intersectEttPiles.Add(new Model.Entity.Pile { RevitElement = item });
                    //revitData.Document.Create.NewDetailCurve(revitData.ActiveView, Line.CreateBound(projection2curve, itemPoint));
                }
            }
            //ettElem.IntersectEttPiles.ForEach(x => x.HostEttElement = ettElem);
            return(intersectEttPiles);
        }