Esempio n. 1
0
        private static Layout GetModelSpaceLayout(this Document doc)
        {
            var layouts = CADDatabaseUtilities.GetAllLayouts();

            var model = layouts.FirstOrDefault(lay => lay.LayoutName.ToUpper() == "MODEL");

            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a named layout if existing or creates it if it doesn't
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="layoutName"></param>
        /// <returns>Returns a DBObject as a Layout</returns>
        public static Layout GetLayout(this Document doc, string layoutName)
        {
            try
            {
                var existing = CADDatabaseUtilities
                               .GetAllLayouts()
                               .Single(l => l.LayoutName.Equals(layoutName));

                return(existing);
            }

            catch (Exception e)
            {
                return(doc.CreateNewLayout(layoutName));
            }
        }
Esempio n. 3
0
        public static void RemoveAllEmptyLayouts()
        {
            using (var tr = CurrentDatabase.TransactionManager.StartTransaction())
            {
                var layouts = CADDatabaseUtilities.GetAllLayouts();

                if (!layouts.Any())
                {
                    return;
                }

                foreach (var layout in layouts)
                {
                    if (layout.IsEmpty())
                    {
                        LayoutManager.Current.DeleteLayout(layout.LayoutName);
                    }
                }

                tr.Commit();
            }
        }