コード例 #1
0
        /// <summary>
        /// Show a colored Vector Analysis Display in the Revit view
        /// </summary>
        /// <param name="view"></param>
        /// <param name="samplePoints"></param>
        /// <param name="samples"></param>
        /// <returns></returns>
        public static VectorAnalysisDisplay ByViewPointsAndVectorValues(View view,
                                                                        Autodesk.DesignScript.Geometry.Point[] samplePoints, Autodesk.DesignScript.Geometry.Vector[] samples)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (samplePoints == null)
            {
                throw new ArgumentNullException("samplePoints");
            }

            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            if (samplePoints.Length != samples.Length)
            {
                throw new Exception("The number of sample points and number of samples must be the same");
            }

            return(new VectorAnalysisDisplay(view.InternalView, samplePoints.ToXyzs(), samples.ToXyzs()));
        }
コード例 #2
0
        /// <summary>
        /// Show a colored Face Analysis Display in the Revit View
        /// </summary>
        /// <param name="view"></param>
        /// <param name="elementFaceReference"></param>
        /// <param name="sampleUvPoints"></param>
        /// <param name="samples"></param>
        /// <returns></returns>
        public static FaceAnalysisDisplay ByViewFacePointsAndValues(View view, ElementFaceReference elementFaceReference,
                                                                    double[][] sampleUvPoints, double[] samples)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (elementFaceReference == null)
            {
                throw new ArgumentNullException("elementFaceReference");
            }

            if (sampleUvPoints == null)
            {
                throw new ArgumentNullException("sampleUvPoints");
            }

            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            if (sampleUvPoints.Length != samples.Length)
            {
                throw new Exception("The number of sample points and number of samples must be the same");
            }

            return(new FaceAnalysisDisplay(view.InternalView, elementFaceReference.InternalReference, sampleUvPoints.ToUvs(), samples));
        }
コード例 #3
0
        /// <summary>
        /// Creates a new elevation ViewSection on the ElevationMarker at the desired index.
        /// </summary>
        /// <param name="planView">The PlanView in which the ElevationMarker is visible. The new elevation ViewSection will derive its extents and inherit settings from the ViewPlan.</param>
        /// <param name="index">The index on the ElevationMarker where the new elevation ViewSection will be placed. The elevation marker can have up to four views, indexed from 0 to 3.</param>
        /// <returns>The new elevation ViewSection.</returns>
        public SectionView CreateElevationByMarkerIndex(Revit.Elements.Views.View planView, int index)
        {
            var view = planView as PlanView;

            if (view == null)
            {
                throw new InvalidOperationException(Properties.Resources.NotPlanView);
            }

            TransactionManager.Instance.EnsureInTransaction(Document);
            Autodesk.Revit.DB.ViewSection sectionView = this.InternalMarker.CreateElevation(Document, view.InternalViewPlan.Id, index);
            TransactionManager.Instance.TransactionTaskDone();
            return(sectionView.ToDSType(true) as SectionView);
        }
コード例 #4
0
        public static IList <Element> OfCategory(Category category, Revit.Elements.Views.View view = null)
        {
            if (category == null)
            {
                return(null);
            }

            var catFilter = new Autodesk.Revit.DB.ElementCategoryFilter(category.InternalCategory.Id);
            var fec       = (view == null) ?
                            new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument) :
                            new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument, view.InternalView.Id);
            var instances =
                fec.WherePasses(catFilter)
                .WhereElementIsNotElementType()
                .ToElementIds()
                .Select(id => ElementSelector.ByElementId(id.IntegerValue))
                .ToList();

            return(instances);
        }
コード例 #5
0
ファイル: Viewport.cs プロジェクト: iAhmedsalama/DynamoRevit
        /// <summary>
        /// Creates a new Viewport at a given location on a sheet.
        /// </summary>
        /// <param name="sheet">The Sheet on which the new Viewport will be placed.</param>
        /// <param name="view">The view shown in the Viewport.</param>
        /// <param name="location">The new Viewport will be centered on this point.</param>
        /// <returns>The new Viewport.</returns>
        public static Viewport BySheetViewLocation(Sheet sheet, Revit.Elements.Views.View view, Autodesk.DesignScript.Geometry.Point location)
        {
            if (sheet == null)
            {
                throw new ArgumentNullException("sheet");
            }
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }
            if (IsViewEmpty(view.InternalView))
            {
                throw new InvalidOperationException(Properties.Resources.EmptyView);
            }

            return(new Viewport(sheet, view, location));
        }
コード例 #6
0
        /// <summary>
        /// Creates a new Viewport at a given location on a sheet.
        /// </summary>
        /// <param name="sheet">The Sheet on which the new Viewport will be placed.</param>
        /// <param name="view">The view shown in the Viewport.</param>
        /// <param name="location">The new Viewport will be centered on this point.</param>
        /// <returns>The new Viewport.</returns>
        public static Viewport BySheetViewLocation(Sheet sheet, Revit.Elements.Views.View view, Autodesk.DesignScript.Geometry.Point location)
        {
            ElementId sheetId      = sheet.InternalView.Id;
            ElementId viewId       = view.InternalView.Id;
            XYZ       viewLocation = GeometryPrimitiveConverter.ToRevitType(location);

            if (!Autodesk.Revit.DB.Viewport.CanAddViewToSheet(Document, sheetId, viewId))
            {
                throw new InvalidOperationException(Properties.Resources.ViewAlreadyPlacedOnSheet);
            }
            if (IsViewEmpty(view.InternalView))
            {
                throw new InvalidOperationException(Properties.Resources.EmptyView);
            }

            TransactionManager.Instance.EnsureInTransaction(Document);
            var viewport = Autodesk.Revit.DB.Viewport.Create(Document, sheetId, viewId, viewLocation);

            TransactionManager.Instance.TransactionTaskDone();
            return(viewport.ToDSType(true) as Viewport);
        }
コード例 #7
0
ファイル: Viewport.cs プロジェクト: iAhmedsalama/DynamoRevit
        /// <summary>
        /// Initialize a Viewport element
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="view"></param>
        /// <param name="location"></param>
        private void InitViewport(Sheet sheet, Revit.Elements.Views.View view, Autodesk.DesignScript.Geometry.Point location)
        {
            ElementId sheetId      = sheet.InternalView.Id;
            ElementId viewId       = view.InternalView.Id;
            XYZ       viewLocation = GeometryPrimitiveConverter.ToRevitType(location);

            TransactionManager.Instance.EnsureInTransaction(Document);

            var viewportElement = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Viewport>(Document);

            if (viewportElement == null)
            {
                if (!Autodesk.Revit.DB.Viewport.CanAddViewToSheet(Document, sheetId, viewId))
                {
                    throw new InvalidOperationException(Properties.Resources.ViewAlreadyPlacedOnSheet);
                }
                viewportElement = Autodesk.Revit.DB.Viewport.Create(Document, sheetId, viewId, viewLocation);
            }
            else
            {
                if (!Autodesk.Revit.DB.Viewport.CanAddViewToSheet(Document, sheetId, viewId))
                {
                    viewportElement.SetBoxCenter(viewLocation);
                }
                else
                {
                    viewportElement = Autodesk.Revit.DB.Viewport.Create(Document, sheetId, viewId, viewLocation);
                }
            }

            InternalSetViewport(viewportElement);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, this.InternalElement);
        }
コード例 #8
0
        /// <summary>
        /// Show a colored Face Analysis Display in the Revit View
        /// </summary>
        /// <param name="view"></param>
        /// <param name="elementFaceReference"></param>
        /// <param name="sampleUvPoints"></param>
        /// <param name="samples"></param>
        /// <returns></returns>
        public static FaceAnalysisDisplay ByViewFacePointsAndValues(View view, object elementFaceReference,
                        double[][] sampleUvPoints, double[] samples)
        {

            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (elementFaceReference == null)
            {
                throw new ArgumentNullException("elementFaceReference");
            }

            if (sampleUvPoints == null)
            {
                throw new ArgumentNullException("sampleUvPoints");
            }

            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            if (sampleUvPoints.Length != samples.Length)
            {
                throw new Exception("The number of sample points and number of samples must be the same");
            }

            return new FaceAnalysisDisplay(view.InternalView, ElementFaceReference.TryGetFaceReference(elementFaceReference).InternalReference, sampleUvPoints.ToUvs(), samples);
        }
コード例 #9
0
        /// <summary>
        /// Show a colored Point Analysis Display in the Revit view
        /// </summary>
        /// <param name="view"></param>
        /// <param name="samplePoints"></param>
        /// <param name="samples"></param>
        /// <returns></returns>
        public static PointAnalysisDisplay ByViewPointsAndValues(View view,
                        Autodesk.DesignScript.Geometry.Point[] samplePoints, double[] samples)
        {

            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (samplePoints == null)
            {
                throw new ArgumentNullException("samplePoints");
            }

            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            if (samplePoints.Length != samples.Length)
            {
                throw new Exception("The number of sample points and number of samples must be the same");
            }

            return new PointAnalysisDisplay(view.InternalView, samplePoints.ToXyzs(), samples);
        }
コード例 #10
0
ファイル: Sheet.cs プロジェクト: RobertiF/Dynamo
        /// <summary>
        /// Create a Revit Sheet by the sheet name, number, a title block FamilySymbol, and a collection of views.  This method will automatically
        /// pack the view onto the sheet.
        /// </summary>
        /// <param name="sheetName"></param>
        /// <param name="sheetNumber"></param>
        /// <param name="titleBlockFamilySymbol"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        public static Sheet ByNameNumberTitleBlockAndView(string sheetName, string sheetNumber, FamilySymbol titleBlockFamilySymbol, View view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            return Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, titleBlockFamilySymbol, new[] { view });
        }
コード例 #11
0
ファイル: Sheet.cs プロジェクト: RobertiF/Dynamo
        // PB: Commented out until we have a good way of setting the sheet size given the views.  Not sure how to do that yet.

        ///// <summary>
        ///// Create a Revit Sheet by the sheet name, number, and a collection of views.  This method will automatically
        ///// pack the views onto the sheet.
        ///// </summary>
        ///// <param name="sheetName"></param>
        ///// <param name="sheetNumber"></param>
        ///// <param name="views"></param>
        ///// <returns></returns>
        //public static Sheet ByNameNumberAndViews(string sheetName, string sheetNumber, AbstractView[] views)
        //{
        //    if (sheetName == null)
        //    {
        //        throw new ArgumentNullException("sheetName");
        //    }

        //    if (sheetNumber == null)
        //    {
        //        throw new ArgumentNullException("sheetNumber");
        //    }

        //    if (views == null)
        //    {
        //        throw new ArgumentNullException("views");
        //    }

        //    if (views.Length == 0)
        //    {
        //        throw new ArgumentException("Must supply more than one view");
        //    }

        //    return new Sheet(sheetName, sheetNumber, views.Select(x => x.InternalView));
        //}

        ///// <summary>
        ///// Create a Revit Sheet by the sheet name, number, and a view.  This method will automatically
        ///// pack the views onto the sheet.
        ///// </summary>
        ///// <param name="sheetName"></param>
        ///// <param name="sheetNumber"></param>
        ///// <param name="view"></param>
        ///// <returns></returns>
        //public static Sheet ByNameNumberAndView(string sheetName, string sheetNumber, AbstractView view)
        //{
        //    if (view == null)
        //    {
        //        throw new ArgumentNullException("view");
        //    }

        //    return Sheet.ByNameNumberAndViews(sheetName, sheetNumber, new[] { view });
        //}

        /// <summary>
        /// Create a Revit Sheet by the sheet name, number, a title block FamilySymbol, and a collection of views.  This method will automatically
        /// pack the views onto the sheet. 
        /// </summary>
        /// <param name="sheetName"></param>
        /// <param name="sheetNumber"></param>
        /// <param name="titleBlockFamilySymbol"></param>
        /// <param name="views"></param>
        /// <returns></returns>
        public static Sheet ByNameNumberTitleBlockAndViews(string sheetName, string sheetNumber, FamilySymbol titleBlockFamilySymbol, View[] views)
        {
            if (sheetName == null)
            {
                throw new ArgumentNullException("sheetName");
            }

            if (sheetNumber == null)
            {
                throw new ArgumentNullException("sheetNumber");
            }

            if (titleBlockFamilySymbol == null)
            {
                throw new ArgumentNullException("titleBlockFamilySymbol");
            }

            if (views == null)
            {
                throw new ArgumentNullException("views");
            }

            if (views.Length == 0)
            {
                throw new ArgumentException("Must supply more than 0 views");
            }

            return new Sheet(sheetName, sheetNumber, titleBlockFamilySymbol.InternalFamilySymbol, views.Select(x => x.InternalView));
        }
コード例 #12
0
ファイル: Viewport.cs プロジェクト: iAhmedsalama/DynamoRevit
 /// <summary>
 /// Create a new Viewport by Sheet, View and Location
 /// </summary>
 /// <param name="sheet"></param>
 /// <param name="view"></param>
 /// <param name="location"></param>
 private Viewport(Sheet sheet, Revit.Elements.Views.View view, Autodesk.DesignScript.Geometry.Point location)
 {
     SafeInit(() => InitViewport(sheet, view, location));
 }