예제 #1
0
        public static void CreateLayout(string name)
        {
            _AcAp.Document acDoc   = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcDb.Database acCurDb = acDoc.Database;

            using (_AcDb.Transaction trans = acCurDb.TransactionManager.StartTransaction())
            {
                // Reference the Layout Manager
                _AcDb.LayoutManager acLayoutMgr = _AcDb.LayoutManager.Current;

                // Create the new layout with default settings
                _AcDb.ObjectId objID = acLayoutMgr.CreateLayout(name);

                // Open the layout
                _AcDb.Layout layout = trans.GetObject(objID, _AcDb.OpenMode.ForRead) as _AcDb.Layout;

                // Set the layout current if it is not already
                if (layout.TabSelected == false)
                {
                    acLayoutMgr.CurrentLayout = layout.LayoutName;
                }

                // Output some information related to the layout object
                acDoc.Editor.WriteMessage("\nTab Order: " + layout.TabOrder +
                                          "\nTab Selected: " + layout.TabSelected +
                                          "\nBlock Table Record ID: " +
                                          layout.BlockTableRecordId.ToString());

                // Save the changes made
                trans.Commit();
            }
        }
예제 #2
0
        public void renameLayout(string find, string replace)
        {
            List <string> layouts = new List <string>();

            _Db.DBDictionary lays = _c.trans.GetObject(_c.db.LayoutDictionaryId, _Db.OpenMode.ForWrite) as _Db.DBDictionary;

            foreach (_Db.DBDictionaryEntry item in lays)
            {
                if (item.Key.Contains(find))
                {
                    string name = item.Key;
                    layouts.Add(name);
                }
            }

            if (layouts.Count > 0)
            {
                _Db.LayoutManager lm = _Db.LayoutManager.Current;

                foreach (string lay in layouts)
                {
                    string newname = lay.Replace(find, replace);
                    lm.RenameLayout(lay, newname);
                }


                string       randomName = generateRandomString(40);
                _Db.ObjectId id         = lm.GetLayoutId(randomName);

                if (!id.IsValid)
                {
                    id = lm.CreateLayout(randomName);
                }

                lm.DeleteLayout(randomName);

                lm.Dispose();
            }
        }
예제 #3
0
        /// <summary>

        /// Creates a layout with the specified name and optionally makes it current.

        /// </summary>

        /// <param name="name">The name of the viewport.</param>

        /// <param name="select">Whether to select it.</param>

        /// <returns>The ObjectId of the newly created viewport.</returns>



        public static _AcDb.ObjectId CreateAndMakeLayoutCurrent(

            this _AcDb.LayoutManager lm, string name, bool select = true

            )
        {
            // First try to get the layout



            var id = lm.GetLayoutId(name);



            // If it doesn't exist, we create it



            if (!id.IsValid)
            {
                id = lm.CreateLayout(name);
            }



            // And finally we select it



            if (select)
            {
                lm.CurrentLayout = name;
            }



            return(id);
        }
예제 #4
0
        private _Db.Layout createLayoutandSetActive(string name) //EH?
        {
            string randomName = generateRandomString(20);

            _Db.ObjectId id = layoutManager.GetLayoutId(randomName);

            if (!id.IsValid)
            {
                id = layoutManager.CreateLayout(randomName);
            }
            else
            {
                write("Layout " + randomName + " already exists.");
            }

            _Db.Layout layout = _c.trans.GetObject(id, _Db.OpenMode.ForWrite) as _Db.Layout;
            if (layout.TabSelected == false)
            {
                layoutManager.CurrentLayout = randomName;
            }

            return(layout);
        }