コード例 #1
0
        Stream(ArrayList data, PlanCircuit planCircuit)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PlanCircuit)));

            data.Add(new Snoop.Data.Double("Area", planCircuit.Area));
            /// TBD: This always throws an exception
            /// 01/24/07
            try {
                data.Add(new Snoop.Data.Bool("Is room located", planCircuit.IsRoomLocated));
            }
            catch (System.Exception ex) {
                data.Add(new Snoop.Data.Exception("Is room located", ex));
            }
            data.Add(new Snoop.Data.Int("Side num", planCircuit.SideNum));
        }
コード例 #2
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Document doc = e.ObjToSnoop as Document;

            if (doc != null)
            {
                Stream(snoopCollector.Data(), doc);
                return;
            }

            Selection sel = e.ObjToSnoop as Selection;

            if (sel != null)
            {
                Stream(snoopCollector.Data(), sel);
                return;
            }

            Settings settings = e.ObjToSnoop as Settings;

            if (settings != null)
            {
                Stream(snoopCollector.Data(), settings);
                return;
            }

            Category cat = e.ObjToSnoop as Category;

            if (cat != null)
            {
                Stream(snoopCollector.Data(), cat);
                return;
            }

            PaperSize paperSize = e.ObjToSnoop as PaperSize;

            if (paperSize != null)
            {
                Stream(snoopCollector.Data(), paperSize);
                return;
            }

            PaperSource paperSource = e.ObjToSnoop as PaperSource;

            if (paperSource != null)
            {
                Stream(snoopCollector.Data(), paperSource);
                return;
            }

            PrintSetup prnSetup = e.ObjToSnoop as PrintSetup;

            if (prnSetup != null)
            {
                Stream(snoopCollector.Data(), prnSetup);
                return;
            }

            PrintParameters prnParams = e.ObjToSnoop as PrintParameters;

            if (prnParams != null)
            {
                Stream(snoopCollector.Data(), prnParams);
                return;
            }

            PlanTopology planTopo = e.ObjToSnoop as PlanTopology;

            if (planTopo != null)
            {
                Stream(snoopCollector.Data(), planTopo);
                return;
            }

            PlanCircuit planCircuit = e.ObjToSnoop as PlanCircuit;

            if (planCircuit != null)
            {
                Stream(snoopCollector.Data(), planCircuit);
                return;
            }

            PrintManager printManager = e.ObjToSnoop as PrintManager;

            if (printManager != null)
            {
                Stream(snoopCollector.Data(), printManager);
                return;
            }
        }
コード例 #3
0
ファイル: Room.cs プロジェクト: regnstr/Regnstrom-Nodes
        /// <summary>
        /// Moves the rooms from one level to another. NOTE: This node produces an error about the room having a negative height, but by pressing "Adjust Limits..." the rooms will be moved correctly.
        /// </summary>
        /// <param name="room">The room to move.</param>
        /// <param name="view">The target view (level) to move to.</param>
        /// <returns></returns>
        public static Revit.Elements.Room ChangeLevel(Revit.Elements.Room room, Revit.Elements.Views.FloorPlanView view)
        {
            var dDoc = DocumentManager.Instance.CurrentDBDocument;
            var cDoc = dDoc.Create;

            // Extract the Revit objects from the view and room
            var iView = view.InternalElement as Autodesk.Revit.DB.ViewPlan;
            var iRoom = room.InternalElement as Autodesk.Revit.DB.Architecture.Room;

            // Retrieve the target level for the rooms
            var targetLevel = iView.GenLevel;
            var baseLevel   = iRoom.Level;


            // For testing purposes
            var returnList = new List <dynamic>();

            // Get the target topology and plan circuits
            var topology = dDoc.get_PlanTopology(targetLevel);
            var circuits = topology.Circuits;


            /* Match the old room position with the new one
             */

            bool        targetFound = false;
            PlanCircuit targetPC    = null;

            foreach (PlanCircuit pc in circuits)
            {
                Autodesk.Revit.DB.UV  uv  = pc.GetPointInside();
                Autodesk.Revit.DB.XYZ xyz = new XYZ(uv.U, uv.V, baseLevel.Elevation);
                targetFound = iRoom.IsPointInRoom(xyz);

                if (targetFound)
                {
                    targetPC = pc;
                    break;
                }
            }

            if (!targetFound)
            {
                return(null);
            }


            /* Unplace the old room
             */

            TransactionManager.Instance.EnsureInTransaction(dDoc);

            iRoom.Unplace();

            TransactionManager.Instance.TransactionTaskDone();


            /* Place the new room
             */

            TransactionManager.Instance.EnsureInTransaction(dDoc);

            var newRoom = cDoc.NewRoom(iRoom, targetPC);

            TransactionManager.Instance.TransactionTaskDone();

            //dDoc.Regenerate();

            return(newRoom.ToDSType(true) as Revit.Elements.Room);
        }