Пример #1
0
        public static void ExportLoops(
            string filepath,
            IWin32Window owner_window,
            string caption,
            Document doc,
            Dictionary <int, JtLoops> loops)
        {
            Bitmap bmp = GeoSnoop.DisplayLoops(loops.Values);

            GeoSnoop.DisplayImageInForm(owner_window,
                                        caption, false, bmp);

            using (StreamWriter s = new StreamWriter(filepath))
            {
                s.WriteLine(caption);

                List <int> keys = new List <int>(loops.Keys);
                keys.Sort();
                foreach (int key in keys)
                {
                    ElementId id = new ElementId(key);
                    Element   e  = doc.GetElement(id);

                    s.WriteLine(
                        "{{\"name\":\"{0}\", \"id\":\"{1}\", "
                        + "\"uid\":\"{2}\", \"svg_path\":\"{3}\"}}",
                        e.Name, e.Id, e.UniqueId,
                        loops[key].SvgPath);
                }
                s.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// Upload the selected rooms and the furniture
        /// they contain to the cloud database.
        /// </summary>
        public static void UploadRoom(
            IntPtr hwnd,
            Document doc,
            Room room)
        {
            BoundingBoxXYZ bb = room.get_BoundingBox(null);

            if (null == bb)
            {
                Util.ErrorMsg(string.Format("Skipping room {0} "
                                            + "because it has no bounding box.",
                                            Util.ElementDescription(room)));

                return;
            }

            JtLoops roomLoops = GetRoomLoops(room);

            ListLoops(room, roomLoops);

            List <Element> furniture
                = GetFurniture(room);

            // Map symbol UniqueId to symbol loop

            Dictionary <string, JtLoop> furnitureLoops
                = new Dictionary <string, JtLoop>();

            // List of instances referring to symbols

            List <JtPlacement2dInt> furnitureInstances
                = new List <JtPlacement2dInt>(
                      furniture.Count);

            int nFailures;

            foreach (FamilyInstance f in furniture)
            {
                FamilySymbol s = f.Symbol;

                string uid = s.UniqueId;

                if (!furnitureLoops.ContainsKey(uid))
                {
                    nFailures = 0;

                    JtLoops loops = GetSolidPlanViewBoundaryLoops(
                        f, true, ref nFailures);

                    if (0 < nFailures)
                    {
                        Debug.Print("{0}: {1}",
                                    Util.ElementDescription(f),
                                    Util.PluralString(nFailures,
                                                      "extrusion analyser failure"));
                    }
                    ListLoops(f, loops);

                    if (0 < loops.Count)
                    {
                        // Assume first loop is outer one

                        furnitureLoops.Add(uid, loops[0]);
                    }
                }
                furnitureInstances.Add(
                    new JtPlacement2dInt(f));
            }
            IWin32Window revit_window
                = new JtWindowHandle(hwnd);

            string caption = doc.Title
                             + " : " + doc.GetElement(room.LevelId).Name
                             + " : " + room.Name;

            Bitmap bmp = GeoSnoop.DisplayRoom(roomLoops,
                                              furnitureLoops, furnitureInstances);

            GeoSnoop.DisplayImageInForm(revit_window,
                                        caption, false, bmp);

            //DbUpload.DbUploadRoom( room, furniture,
            //  roomLoops, furnitureLoops );
        }