Beispiel #1
0
        /// <summary>
        /// Finds the angle of the longest bounrady segment of the first wall enclosing a room
        /// </summary>
        /// <param name="r">room used to find boundary</param>
        /// <returns>the angle in radians to rotate the elevation marker by</returns>
        public double AngletoRotateElev(Room r)
        {
            IList <IList <BoundarySegment> > segmentList = r.GetBoundarySegments(new SpatialElementBoundaryOptions());

            IList <BoundarySegment> wallList = segmentList[0];

            BoundarySegment segment = null;

            foreach (BoundarySegment wbs in wallList)
            {
                if (segment == null)
                {
                    segment = wbs;
                }

                else if (wbs.GetCurve().Length > segment.GetCurve().Length)
                {
                    segment = wbs;
                }
            }

            XYZ EP1 = segment.GetCurve().GetEndPoint(0);
            XYZ EP2 = segment.GetCurve().GetEndPoint(1);

            Debug("segment" + segment);
            Debug("EP1" + EP1);
            Debug("EP2" + EP2);

            double angleLineEP1EP2 = Math.Atan2((EP2.Y) - (EP1.Y), (EP2.X) - (EP1.X));

            Debug("angleLineEP1EP2" + angleLineEP1EP2);

            return(angleLineEP1EP2);
        }
Beispiel #2
0
        Room GetRoomNeighbourAt(BoundarySegment bs, Room r)
        {
            Document doc = r.Document;

            Element e = doc.GetElement(bs.ElementId);
            Wall    w = e as Wall;

            double wallThickness = w.Width;

            double wallLength = (w.Location as
                                 LocationCurve).Curve.Length;

            Transform derivatives = bs.GetCurve()
                                    .ComputeDerivatives(0.5, true);

            XYZ midPoint = derivatives.Origin;

            Debug.Assert(
                midPoint.IsAlmostEqualTo(
                    bs.GetCurve().Evaluate(0.5, true)),
                "expected same result from Evaluate and derivatives");

            XYZ tangent = derivatives.BasisX.Normalize();

            XYZ normal = new XYZ(tangent.Y, tangent.X * (-1), tangent.Z);

            XYZ p = midPoint + wallThickness * normal;

            Room otherRoom = doc.GetRoomAtPoint(p);

            if (null != otherRoom)
            {
                if (otherRoom.Id == r.Id)
                {
                    normal = new XYZ(tangent.Y * (-1),
                                     tangent.X, tangent.Z);

                    p = midPoint + wallThickness * normal;

                    otherRoom = doc.GetRoomAtPoint(p);

                    Debug.Assert(null == otherRoom ||
                                 otherRoom.Id != r.Id,
                                 "expected different room on other side");
                }
            }
            return(otherRoom);
        }
        Stream(ArrayList data, BoundarySegment boundSeg)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(BoundarySegment)));

            data.Add(new Snoop.Data.Object("Curve", boundSeg.GetCurve()));
            data.Add(new Snoop.Data.Object("Element", boundSeg.ElementId));            
        }
Beispiel #4
0
        /// <summary>
        /// Appends a list of the room's near-corner points to a pre-existing list.
        /// </summary>
        /// <remarks>
        /// A near-corner point is offset from the room boundaries by 1.5 ft (18 inches). The points are calculated geometrically and some situations may not return
        /// all logical near-corner points, or may return points which are inside furniture, casework or other design elements.   Only the first boundary region of the room is
        /// currently processed.
        /// </remarks>
        /// <param name="room"></param>
        /// <param name="nearCornerPoints"></param>
        /// <returns></returns>
        private static void AppendRoomNearCornerPoints(Room room, List <XYZ> nearCornerPoints)
        {
            IList <IList <BoundarySegment> > segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions());

            if (segments == null || segments.Count == 0)
            {
                return;
            }

            // First region only
            IList <BoundarySegment> firstSegments = segments[0];
            int numSegments = firstSegments.Count;


            for (int i = 0; i < numSegments; i++)
            {
                BoundarySegment seg1 = firstSegments.ElementAt(i);
                BoundarySegment seg2 = firstSegments.ElementAt(i == numSegments - 1 ? 0 : i + 1);

                Curve curve1 = seg1.GetCurve();
                Curve curve2 = seg2.GetCurve();

                Curve offsetCurve1 = curve1.CreateOffset(-1.5, XYZ.BasisZ);
                Curve offsetCurve2 = curve2.CreateOffset(-1.5, XYZ.BasisZ);

                IntersectionResultArray intersections = null;
                SetComparisonResult     result        = offsetCurve1.Intersect(offsetCurve2, out intersections);

                // First intersection only
                if (result == SetComparisonResult.Overlap && intersections.Size == 1)
                {
                    nearCornerPoints.Add(intersections.get_Item(0).XYZPoint);
                }
            }
        }
Beispiel #5
0
        Stream(ArrayList data, BoundarySegment boundSeg)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(BoundarySegment)));

            data.Add(new Snoop.Data.Object("Curve", boundSeg.GetCurve()));
            data.Add(new Snoop.Data.Object("ElementId", boundSeg.ElementId));
        }
Beispiel #6
0
        private Room getOtherRoom(Room r1, BoundarySegment seg, XYZ point)
        {
            // we already know what one of the rooms is attached to a boundary segment.
            // this attempts to find the other.
            Curve crv = seg.GetCurve();

            XYZ vector = crv.GetEndPoint(1).Subtract(crv.GetEndPoint(0)).Normalize();

            XYZ otherVector = XYZ.BasisZ;

            if (vector.IsAlmostEqualTo(XYZ.BasisZ))
            {
                otherVector = XYZ.BasisY;
            }
            XYZ perp = vector.CrossProduct(otherVector).Normalize();

            XYZ       testp1    = point.Add(perp.Multiply(0.25));
            XYZ       testp2    = point.Add(perp.Negate().Multiply(0.25));
            Parameter phaseParm = r1.get_Parameter(BuiltInParameter.ROOM_PHASE);
            Phase     p         = _doc.GetElement(phaseParm.AsElementId()) as Phase;

            Room roomP1 = _doc.GetRoomAtPoint(testp1, p);
            Room roomP2 = _doc.GetRoomAtPoint(testp2, p);

            if ((roomP1 != null) && (roomP1.Id != r1.Id))
            {
                return(roomP1);
            }
            if ((roomP2 != null) && (roomP2.Id != r1.Id))
            {
                return(roomP2);
            }

            return(null);
        }
Beispiel #7
0
        private void fetchSegmentElemInfo(RoomObject obj, BoundarySegment seg, Level refLevel, Segment target)
        {
            Curve crv = seg.GetCurve();

            target.Curve    = crv;
            target.Length   = crv.ApproximateLength;
            target.MidPoint = crv.Evaluate(0.5, true);

            Element e = obj.Document.GetElement(seg.ElementId);

            if (e is RevitLinkInstance)
            {
                RevitLinkInstance inst = e as RevitLinkInstance;
                Document          doc  = inst.GetLinkDocument();
                e = null;
                if (doc != null)
                {
                    e = doc.GetElement(seg.LinkElementId);
                }
            }

            if (e == null)
            {
                target.ElementType = "UNKNOWN!?";
                target.Thickness   = 0;
                return;
            }

            target.ElementType = e.Category.Name;
            if (e is Wall)
            {
                Wall w = e as Wall;
                target.Thickness  = w.WallType.Width;
                target.IsExterior = (w.WallType.Function == WallFunction.Exterior);
                target.WallKind   = w.WallType.Kind;
            }
            else
            {
                target.Thickness = 0;
            }
        }
 /// <summary>
 /// 根据BoundarySegment获取与房间交界的墙段的长度
 /// </summary>
 /// <param name="boundarySegment">墙段</param>
 /// <returns></returns>
 public double GetWallLength(BoundarySegment boundarySegment)
 {
     return(boundarySegment.GetCurve().Length);
 }
Beispiel #9
0
 public MyBoundarySegment(BoundarySegment b)
 {
     Curve     = b.GetCurve();
     ElementId = b.ElementId;
 }
Beispiel #10
0
 public static Curve GetSegmentCurve(this BoundarySegment s)
 {
     return(s.GetCurve());
 }