Exemplo n.º 1
0
 /// <summary>
 /// This will set a leader's elbow position. Note: Obtain the leader element from the text note with TextNote.GetLeaders
 /// </summary>
 /// <param name="leader">The leader to set the elbow position of.</param>
 /// <param name="location">The new location for the leader elbow.</param>
 public static void SetLeaderElbowPosition(Leader leader, Point location)
 {
     Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
     TransactionManager.Instance.EnsureInTransaction(doc);
     leader.Elbow = location.ToXyz();
     TransactionManager.Instance.TransactionTaskDone();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a Revit Axonometric (isometric) View from an Eye position and target position and Bounding Box
        /// </summary>
        /// <param name="eyePoint">A Point representing the eye point.</param>
        /// <param name="target">A Point representing the target of view.</param>
        /// <param name="boundingBox">A BoundingBox. The view will be cropped to this bounding box</param>
        /// <param name="name">The name of the view.</param>
        /// <param name="isolateElement">If this argument is set to true, the element or
        /// bounding box will be isolated in the current view by creating a minimum size
        /// crop box around it.</param>
        /// <returns>An AxonometricView object.</returns>
        public static AxonometricView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint,
                                                                     Autodesk.DesignScript.Geometry.Point target,
                                                                     Autodesk.DesignScript.Geometry.BoundingBox boundingBox,
                                                                     string name         = DEFAULT_VIEW_NAME,
                                                                     bool isolateElement = false)
        {
            if (boundingBox == null)
            {
                throw new ArgumentNullException("boundingBox");
            }

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

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

            if (name == null)
            {
                name = DEFAULT_VIEW_NAME;
            }

            return(new AxonometricView(eyePoint.ToXyz(true), target.ToXyz(true), boundingBox.ToRevitType(true), name, isolateElement));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculates the path of egress from each desk instance to the escapeLocation and returns a list of EgressResult objects.
        /// </summary>
        /// <param name="deskInstances"> A list of Revit desk family instances.</param>
        /// <param name="escapeLocation"> The point where the exit is, typically from a door location.</param>
        /// <param name="view"> The view to perform the egress calculation.</param>
        /// <param name="maxEgressDistance"> The maximum distance which is permitted for escape.</param>
        public static List <EgressResult> GetResults(List <DynamoElement> deskInstances, ProtoPoint escapeLocation, DynamoView view, double maxEgressDistance)
        {
            double maxEgressDistanceInFt =
                UnitUtils.ConvertToInternalUnits(maxEgressDistance, DisplayUnitType.DUT_MILLIMETERS);

            Document doc = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(doc);

            XYZ escapeLocationXyz = escapeLocation.ToXyz();

            List <EgressResult> egressResults = new List <EgressResult>();

            foreach (var deskInstance in deskInstances)
            {
                LocationPoint deskLocation = (LocationPoint)deskInstance.InternalElement.Location;

                PathOfTravel pathOfTravel = PathOfTravel.Create((View)view.InternalElement, deskLocation.Point, escapeLocationXyz);

                EgressResult egressResult = new EgressResult(deskInstance, pathOfTravel, maxEgressDistanceInFt);

                egressResults.Add(egressResult);
            }

            TransactionManager.Instance.TransactionTaskDone();

            return(egressResults);
        }
Exemplo n.º 4
0
        public static string AddSplitLineWithElevation(global::Revit.Elements.Element roof, Curve curve, double elevation)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.RoofBase internalRoof = (Autodesk.Revit.DB.RoofBase)roof.InternalElement;

            Point startPoint = Point.ByCoordinates(curve.StartPoint.X, curve.StartPoint.Y, elevation);
            Point endPoint   = Point.ByCoordinates(curve.EndPoint.X, curve.EndPoint.Y, elevation);

            string result;

            try
            {
                TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
                internalRoof.SlabShapeEditor.Enable();
                SlabShapeVertex vertex1 = internalRoof.SlabShapeEditor.DrawPoint(startPoint.ToXyz());
                SlabShapeVertex vertex2 = internalRoof.SlabShapeEditor.DrawPoint(endPoint.ToXyz());
                internalRoof.SlabShapeEditor.DrawSplitLine(vertex1, vertex2);
                TransactionManager.Instance.TransactionTaskDone();
                result = "Success.";
            }
            catch (Exception)
            {
                result = "not so success.";
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Form a Refernece plane from two end points in the Active view.  The cut vector is the Z Axis.
        /// </summary>
        /// <param name="start">The location where the bubble will be located</param>
        /// <param name="end">The other end</param>
        /// <returns></returns>
        public static ReferencePlane ByStartPointEndPoint(Point start, Point end)
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }

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

            return(new ReferencePlane(start.ToXyz(),
                                      end.ToXyz(),
                                      (end.ToXyz() - start.ToXyz()).GetPerpendicular(),
                                      Document.ActiveView));
        }
Exemplo n.º 6
0
 public static void SetLeaderElbowPosition(global::Revit.Elements.Tag tag, Point location)
 {
     Autodesk.Revit.DB.Document       doc         = DocumentManager.Instance.CurrentDBDocument;
     Autodesk.Revit.DB.IndependentTag internalTag = (Autodesk.Revit.DB.IndependentTag)tag.InternalElement;
     TransactionManager.Instance.EnsureInTransaction(doc);
     internalTag.LeaderElbow = location.ToXyz();
     TransactionManager.Instance.TransactionTaskDone();
 }
Exemplo n.º 7
0
        /// <summary>
        /// 点投影到线
        /// </summary>
        /// <param name="po"></param>
        /// <param name="l"></param>
        /// <returns></returns>
        public static Point ProjectTo(this Point po, Line l)
        {
            XYZ     dbpo   = po.ToXyz();
            DBcurve dbline = l.ToRevitType();
            XYZ     newpo  = dbline.Project(dbpo).XYZPoint;

            return(Point.ByCoordinates(newpo.X, newpo.Y, newpo.Z));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Place a Revit FamilyInstance given the FamilyType (also known as the FamilySymbol in the Revit API), it's coordinates in world space, and the Level
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="point">Point in meters.</param>
        /// <param name="level">Level to host Family Instance.</param>
        /// <returns></returns>
        public static FamilyInstance ByPointAndLevel(FamilyType familyType, Point point, Level level)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }

            return(new FamilyInstance(familyType.InternalFamilySymbol, point.ToXyz(), level.InternalLevel));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Create a Revit Axonometric (isometric) View from an Eye position and target position and Element
        /// </summary>
        /// <param name="eyePoint">A Point representing the eye point.</param>
        /// <param name="target">A Point representing the target of view.</param>
        /// <param name="element">This argument cannot be null, and it has to be either a
        /// Revit.Elements.Element or  Revit.GeometryObjectsBoundingBox.</param>
        /// <param name="name">The name of the view.</param>
        /// <param name="isolateElement">If this argument is set to true, the element or
        /// bounding box will be isolated in the current view by creating a minimum size
        /// crop box around it.</param>
        /// <returns>An AxonometricView object.</returns>
        public static AxonometricView ByEyePointTargetAndElement(
            Autodesk.DesignScript.Geometry.Point eyePoint,
            Autodesk.DesignScript.Geometry.Point target,
            string name         = DEFAULT_VIEW_NAME,
            Element element     = null,
            bool isolateElement = false)
        {
            if (eyePoint == null)
            {
                throw new ArgumentNullException("eyePoint");
            }

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

            if (name == null)
            {
                name = DEFAULT_VIEW_NAME;
            }

            if (element == null)
            {
                return(new AxonometricView(
                           eyePoint.ToXyz(true),
                           target.ToXyz(true),
                           name,
                           null,
                           isolateElement));
            }
            else
            {
                return(new AxonometricView(
                           eyePoint.ToXyz(true),
                           target.ToXyz(true),
                           name,
                           element.InternalElement,
                           isolateElement));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Place a Revit FamilyInstance given the FamilyType (also known as the FamilySymbol in the Revit API) and its coordinates in world space
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="point">Point in meters.</param>
        /// <returns></returns>
        public static FamilyInstance ByPoint(FamilyType familyType, Point point)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }

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

            return(new FamilyInstance(familyType.InternalFamilySymbol, point.ToXyz()));
        }
Exemplo n.º 11
0
        public PathOfTravel SetWayPoint(Autodesk.DesignScript.Geometry.Point newPosition, int index)
        {
            if (newPosition is null)
            {
                throw new ArgumentNullException("newPosition", Properties.Resources.PointRequired); //Please supply a point geometry.
            }
            if (m_rvtPathOfTravel is null)
            {
                throw new ArgumentException(Properties.Resources.InvalidPathOfTravel);
            }

            TransactionManager.Instance.EnsureInTransaction(Document);

            m_rvtPathOfTravel.SetWaypoint(newPosition.ToXyz(), index);

            TransactionManager.Instance.TransactionTaskDone();

            return(this);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Create a Revit Grid Element in a project between two end points
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static Grid ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end)
        {
            if (Document.IsFamilyDocument)
            {
                throw new Exception(Properties.Resources.GridCreationFailure);
            }

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

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

            var line = Autodesk.Revit.DB.Line.CreateBound(start.ToXyz(), end.ToXyz());

            return(new Grid(line));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a PipePlaceholder by two points.
        /// </summary>
        /// <param name="pipeType">Type of the pipe.</param>
        /// <param name="systemType">Type of the system.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <param name="level">The level.</param>
        /// <returns></returns>
        public static PipePlaceHolder ByPoints(Revit.Elements.Element pipeType, Revit.Elements.Element systemType, Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end, Revit.Elements.Level level)
        {
            Utils.Log(string.Format("PipePlaceHolder.ByPoints started...", ""));

            var oType          = pipeType.InternalElement as Autodesk.Revit.DB.Plumbing.PipeType;
            var oSystemType    = systemType.InternalElement as Autodesk.Revit.DB.Plumbing.PipingSystemType;
            var totalTransform = RevitUtils.DocumentTotalTransform();

            start = start.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point;
            var s = start.ToXyz();

            end = end.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point;
            var e = end.ToXyz();
            var l = level.InternalElement as Autodesk.Revit.DB.Level;

            totalTransform.Dispose();

            Utils.Log(string.Format("PipePlaceHolder.ByPoints completed.", ""));

            return(new PipePlaceHolder(oType, oSystemType, s, e, l));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create a Revit Grid Element in a project between two end points
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static Grid ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end)
        {
            if (Document.IsFamilyDocument)
            {
                throw new Exception("A Grid Element can only be created in a Revit Project");
            }

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

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

            var line = Autodesk.Revit.DB.Line.CreateBound(start.ToXyz(), end.ToXyz());

            return(new Grid(line));
        }
Exemplo n.º 15
0
        public static string AddPoint(global::Revit.Elements.Element roof, Point point)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.RoofBase internalRoof = (Autodesk.Revit.DB.RoofBase)roof.InternalElement;

            string result;

            try
            {
                TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
                internalRoof.SlabShapeEditor.Enable();
                SlabShapeVertex vertex1 = internalRoof.SlabShapeEditor.DrawPoint(point.ToXyz());
                TransactionManager.Instance.TransactionTaskDone();
                result = "Success.";
            }
            catch (Exception)
            {
                result = "not so success.";
            }

            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Create a Revit Perspective View from an Eye position and target position and Bounding Box
        /// </summary>
        /// <param name="eyePoint"></param>
        /// <param name="target"></param>
        /// <param name="boundingBox"></param>
        /// <param name="name"></param>
        /// <param name="isolateElement"></param>
        /// <returns></returns>
        public static PerspectiveView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Autodesk.DesignScript.Geometry.BoundingBox boundingBox, string name, bool isolateElement)
        {
            if (boundingBox == null)
            {
                throw new ArgumentNullException("boundingBox");
            }

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

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

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

            return(new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), boundingBox.ToRevitType(), name, isolateElement));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create a Revit Perspective View from an Eye position and target position and Element
        /// </summary>
        /// <param name="eyePoint"></param>
        /// <param name="target"></param>
        /// <param name="element"></param>
        /// <param name="name"></param>
        /// <param name="isolateElement"></param>
        /// <returns></returns>
        public static PerspectiveView ByEyePointTargetAndElement(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Element element, string name, bool isolateElement)
        {
            if (eyePoint == null)
            {
                throw new ArgumentNullException("eyePoint");
            }

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

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

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

            return(new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), element.InternalElement, name, isolateElement));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Place a Revit family instance given the FamilyType (also known as the FamilySymbol in the Revit API)
        /// on a surface derived from a backing Revit face as reference, a reference direction and a point location where to place the family.
        ///
        /// Note: The FamilyType should be workplane based and the input surface must be created from a Revit Face. The reference direction defines the rotation of the instance on the reference, and thus cannot be perpendicular to the face.
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="face">Surface geometry derived from a Revit face as reference element</param>
        /// <param name="location">Point on the face where the instance is to be placed</param>
        /// <param name="referenceDirection">A vector that defines the direction of placement of the family instance</param>
        /// <returns>FamilyInstance</returns>
        public static FamilyInstance ByFace(FamilyType familyType, Surface face, Point location,
                                            Vector referenceDirection)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }
            if (face == null)
            {
                throw new ArgumentNullException("face");
            }
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }
            if (referenceDirection == null)
            {
                throw new ArgumentNullException("referenceDirection");
            }
            var reference = ElementFaceReference.TryGetFaceReference(face);

            return(new FamilyInstance(familyType.InternalFamilySymbol, reference.InternalReference,
                                      location.ToXyz(), referenceDirection.ToXyz()));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Form a Refernece plane from two end points in the Active view.  The cut vector is the Z Axis.
        /// </summary>
        /// <param name="start">The location where the bubble will be located</param>
        /// <param name="end">The other end</param>
        /// <returns></returns>
        public static ReferencePlane ByStartPointEndPoint( Point start, Point end )
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }

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

            return new ReferencePlane(  start.ToXyz(), 
                                        end.ToXyz(),
                                        (end.ToXyz() - start.ToXyz()).GetPerpendicular(),
                                        Document.ActiveView);
        }