private static bool SetPlotSettings(string loName, string device, string pageSize, string styleSheet, double?scaleNumerator, double?scaleDenominator, short?plotRotation)
        {
            _AcAp.Document      doc       = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcDb.Database      db        = doc.Database;
            _AcEd.Editor        ed        = doc.Editor;
            _AcDb.LayoutManager layoutMgr = _AcDb.LayoutManager.Current;

            var layoutId = layoutMgr.GetLayoutId(loName);

            if (!layoutId.IsValid)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Layout '{0}' existiert nicht!", loName));
            }

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var layout = (_AcDb.Layout)tr.GetObject(layoutId, _AcDb.OpenMode.ForWrite);

                layout.SetPlotSettings(device, pageSize, styleSheet, scaleNumerator, scaleDenominator, plotRotation);

                tr.Commit();
            }

            return(true);
        }
Exemple #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();
            }
        }
        /// <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);
        }
Exemple #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);
        }