Ejemplo n.º 1
0
        /// <summary>
        /// Create a `MEP Space
        /// based on a location
        /// </summary>
        /// <param name="point">Location point for the space</param>
        /// <returns></returns>
        public static Space ByPoint(Point point)
        {
            DB.XYZ   revitPoint = GeometryPrimitiveConverter.ToXyz(point);
            DB.Level revitLevel = GetNearestLevel(revitPoint);

            DB.UV uv = new DB.UV(revitPoint.X, revitPoint.Y);

            return(new Space(revitLevel, uv));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a Room
        /// based on a location and a level
        /// </summary>
        /// <param name="point">Location point for the room</param>
        /// <param name="level">Level of the room</param>
        /// <returns></returns>
        public static CustomRoom ByPointAndLevel(Point point, Level level)
        {
            DB.Level revitLevel = level.InternalElement as DB.Level;
            DB.XYZ   revitPoint = GeometryPrimitiveConverter.ToXyz(point);

            DB.UV uv = new DB.UV(revitPoint.X, revitPoint.Y);

            return(new CustomRoom(revitLevel, uv));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a MEP Space
        /// based on a location and a level
        /// </summary>
        /// <param name="point">Location point for the space</param>
        /// <param name="level">Level of the space</param>
        /// <returns></returns>
        public static Space ByPointAndLevel(Point point, Level level)
        {
            //Check if the level is in the document
            if (level.InternalElement.Document != DocumentManager.Instance.CurrentDBDocument)
            {
                throw new ArgumentException("The level does not exist in the given document");
            }

            DB.Level revitLevel = level.InternalElement as DB.Level;
            DB.XYZ   revitPoint = GeometryPrimitiveConverter.ToXyz(point);

            DB.UV uv = new DB.UV(revitPoint.X, revitPoint.Y);

            return(new Space(revitLevel, uv));
        }
Ejemplo n.º 4
0
        public static Dictionary <string, object> InstanceByPointAndHost(Point point, FamilyType familyType, Element host)
        {
            AD.Document     currentDBDocument = DocumentManager.Instance.CurrentDBDocument;
            AD.XYZ          xYZ          = GeometryPrimitiveConverter.ToXyz(point, true);
            AD.FamilySymbol familySymbol = (AD.FamilySymbol)(familyType.InternalElement);
            if (!familySymbol.IsActive)
            {
                familySymbol.Activate();
            }
            AD.Element element = host.InternalElement;
            AD.Level   level   = element.Document.GetElement(element.LevelId) as AD.Level;
            TransactionManager.Instance.EnsureInTransaction(currentDBDocument);
            AD.FamilyInstance element2 = currentDBDocument.Create.NewFamilyInstance(xYZ, familySymbol, element, level, 0);
            var ele = element2.ToDSType(false);

            TransactionManager.Instance.TransactionTaskDone();
            return(new Dictionary <string, object>
            {
                {
                    "FamilyInstance",
                    ele
                }
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Place an instance of a Revit group
        /// </summary>
        /// <param name="point">Location point for the group instance</param>
        /// <param name="groupType">The type of the group</param>
        /// <returns></returns>
        public static Group PlaceGroupInstance(Point point, GroupType groupType)
        {
            DB.XYZ revitPoint = GeometryPrimitiveConverter.ToXyz(point);

            return(new Group(revitPoint, groupType.InternalGroupType));
        }