Example #1
0
        /// <summary>
        /// Return the neighbouring room to the given one
        /// on the other side of the midpoint of the given
        /// boundary segment.
        /// </summary>
        Room GetRoomNeighbourAt(
            BoundarySegment bs,
            Room r)
        {
            Document doc = r.Document;

            //Wall w = bs.Element as Wall;// 2015
            Wall w = doc.GetElement(bs.ElementId) as Wall;// 2016

            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);
        }
Example #2
0
        Stream(ArrayList data, Autodesk.Revit.DB.BoundarySegment boundSeg)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Autodesk.Revit.DB.BoundarySegment)));

            data.Add(new Snoop.Data.Object("Curve", boundSeg.GetCurve()));
            data.Add(new Snoop.Data.Object("Element", boundSeg.ElementId));
        }
Example #3
0
        public SegmentData(Autodesk.Revit.DB.BoundarySegment segment)
        {
            SegmentObj = segment;
#if RELEASE2015
            BoundaryCurve = segment.Curve;
#else
            BoundaryCurve = segment.GetCurve();
#endif

#if RELEASE2015
            if (null == segment.Element)
            {
                VisibleCurves.Add(BoundaryCurve);
            }
#else
            if (ElementId.InvalidElementId != segment.ElementId)
            {
                VisibleCurves.Add(BoundaryCurve);
            }
#endif
        }
        /// <summary>
        /// Return the neighbouring room to the given one
        /// on the other side of the midpoint of the given
        /// boundary segment.
        /// </summary>
        Room GetRoomNeighbourAt( 
            BoundarySegment bs,
            Room r)
        {
            Document doc = r.Document;

              //Wall w = bs.Element as Wall;// 2015
              Wall w = doc.GetElement( bs.ElementId ) as Wall;// 2016

              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;
        }