예제 #1
0
 RadialArray()
 {
     if (m_revitApp.ActiveUIDocument.Selection.GetElementIds().Count > 0)
     {
         Autodesk.Revit.DB.View view = m_revitApp.ActiveUIDocument.Document.ActiveView;
         XYZ axisDir = null;
         if (view is View3D)
         {
             SketchPlane sp = view.SketchPlane;
             if (sp == null)
             {
                 return;
             }
             axisDir = sp.GetPlane().Normal;
         }
         else
         {
             axisDir = view.ViewDirection;
         }
         if (axisDir == null)
         {
             return;
         }
         Line axisLine = Line.CreateBound(XYZ.Zero, XYZ.Zero.Add(axisDir));
         Autodesk.Revit.DB.RadialArray.Create(
             m_revitApp.ActiveUIDocument.Document,
             m_revitApp.ActiveUIDocument.Document.ActiveView,
             m_revitApp.ActiveUIDocument.Selection.GetElementIds(),
             4, axisLine, 30.0, ArrayAnchorMember.Last);
     }
 }
예제 #2
0
        RoomArea()
        {
            Revit.Creation.Document doc         = m_revitApp.ActiveUIDocument.Document.Create;
            SketchPlane             sketchPlane = Utils.Geometry.GetWorldPlane(m_revitApp);

            RevitLookup.Test.Forms.Levels lev = new RevitLookup.Test.Forms.Levels(m_revitApp);
            if (lev.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Level curLevel = lev.LevelSelected;

            if (curLevel == null)
            {
                MessageBox.Show("No Level was selected.");
                return;
            }

            // Get the plan topology of the active doc first
            PlanTopology            planTopo = m_revitApp.ActiveUIDocument.Document.get_PlanTopology(curLevel);
            ICollection <ElementId> roomIds  = planTopo.GetRoomIds();

            if (roomIds.Count > 0)
            {
                IEnumerator <ElementId> setIter = roomIds.GetEnumerator();
                while (setIter.MoveNext())
                {
                    Room room = m_revitApp.ActiveUIDocument.Document.GetElement(setIter.Current) as Room;
                    if (null != room)
                    {
                        Autodesk.Revit.DB.View view          = m_revitApp.ActiveUIDocument.Document.ActiveView;
                        LocationPoint          locationPoint = room.Location as LocationPoint;

                        Double area = room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble();

                        Double roundedArea = Math.Round(area, 2);

                        // providing an offset so that the Room Tag and the Area Tag dont overlap. Overlapping leads to an
                        // alignment related assert.

                        XYZ offset = new XYZ(5.0, 0, 0);

                        /// align text middle and center
                        TextAlignFlags align   = TextAlignFlags.TEF_ALIGN_MIDDLE ^ TextAlignFlags.TEF_ALIGN_CENTER;
                        TextNote       txtNote = m_revitApp.ActiveUIDocument.Document.Create.NewTextNote(view, offset + locationPoint.Point, GeomUtils.kXAxis,
                                                                                                         view.ViewDirection, .25,
                                                                                                         align, roundedArea.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("No rooms found in the Active Document", "RevitLookup", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


            // TBD: Tried to play around with PlanCircuits and there seems to be a problem with the IsRoomLocated property.
            // arj 1/23/07

            //Revit.PlanCircuitSet circSet = planTopo.Circuits;
            //Revit.PlanCircuitSetIterator setIters = circSet.ForwardIterator();

            //while (setIters.MoveNext())
            //{
            //    Revit.PlanCircuit planCircuit = setIters.Current as Revit.PlanCircuit;

            //    if (null != planCircuit)
            //    {
            //
            //        if (planCircuit.IsRoomLocated) // throws an exception always "Attempted to read or write protected memory.
            // This is often an indication that other memory is corrupt."
            //        {
            //        }
            //    }
            //}
        }