Example #1
0
        Layer()
        {
            m_db = Utils.Db.GetCurDwg();
            string symName = "Jimbo";

            using (TransactionHelper tr = new TransactionHelper(m_db)) {
                tr.Start();

                if (tr.SymbolTableRecExists(typeof(LayerTableRecord), symName))
                {
                    Utils.AcadUi.PrintToCmdLine(string.Format("\nLayer \"{0}\" already exists.", symName));
                    return;
                }

                LayerTableRecord lyr = new LayerTableRecord();
                lyr.Name             = symName;
                lyr.LinetypeObjectId = Utils.SymTbl.GetOrLoadLinetypeId("ZIGZAG", m_db);
                //lyr.Description = "Layer created programmatically by MgdDbg"; // Can't set until after its added to the database!

                lyr.Color = Color.FromRgb(0, 130, 160);

                tr.AddNewSymbolRec(lyr);

                tr.Commit();
                Utils.AcadUi.PrintToCmdLine(string.Format("\nCreated layer \"{0}\".", symName));
            }
        }