Example #1
0
        public void fHideOtherLayers()
        {
            Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                // Get the current document and database, and start a transaction
                Document acDoc   = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;

                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    // This example returns the layer table for the current database
                    LayerTable acLyrTbl;
                    acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId,
                                                 OpenMode.ForRead) as LayerTable;


                    if (!Layers.CurrentLayer().Contains("!FDS"))
                    {
                        Utils.Init();
                        Layers.SetLayer("!FDS_OBST[inert](0)");
                    }

                    // Step through the Layer table and print each layer name
                    foreach (ObjectId acObjId in acLyrTbl)
                    {
                        LayerTableRecord acLyrTblRec;
                        acLyrTblRec = acTrans.GetObject(acObjId, OpenMode.ForWrite) as LayerTableRecord;

                        if (!acLyrTblRec.Name.Contains("!FDS_"))
                        {
                            acLyrTblRec.IsOff = true;
                        }
                    }
                    acTrans.Commit();
                }
                return;
            }
            catch (System.Exception e)
            {
                ed.WriteMessage("\nProgram exception: " + e.ToString());
                return;
            }
        }
Example #2
0
        public void fCONVERTLAYERS()
        {
            Document acDoc   = acApp.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            ed.WriteMessage("convertLayers\n");

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // This example returns the layer table for the current database
                LayerTable acLyrTbl;
                acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead) as LayerTable;

                // Step through the Layer table and print each layer name
                foreach (ObjectId acObjId in acLyrTbl)
                {
                    LayerTableRecord acLyrTblRec;
                    acLyrTblRec = acTrans.GetObject(acObjId, OpenMode.ForWrite) as LayerTableRecord;
                    if (acLyrTblRec.Name.Contains("_EK_geom"))
                    {
                        string layName  = acLyrTblRec.Name.Substring(9, acLyrTblRec.Name.Length - 12);
                        string level    = acLyrTblRec.Name.Substring(acLyrTblRec.Name.Length - 3);
                        int    levelInt = Int32.Parse(level);
                        if (acLyrTblRec.Name.Contains("FDS_hole"))
                        {
                            acLyrTblRec.Name = "!FDS_HOLE(" + levelInt.ToString() + ")";
                        }
                        else
                        {
                            acLyrTblRec.Name = "!FDS_OBST[" + layName + "](" + levelInt.ToString() + ")";
                        }
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_curt"))
                    {
                        string level    = acLyrTblRec.Name.Substring(acLyrTblRec.Name.Length - 3);
                        int    levelInt = Int32.Parse(level);

                        acLyrTblRec.Name = "!FDS_OBST[FDS_curt](" + levelInt.ToString() + ")";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_supl"))
                    {
                        acLyrTblRec.Name = "!FDS_OBST[FDS_supl](0)";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_fire"))
                    {
                        // _EK_fire_1
                        string layName = acLyrTblRec.Name.Substring(4, acLyrTblRec.Name.Length - 4);
                        acLyrTblRec.Name = "!FDS_FIRE[" + layName + "]";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_slcf"))
                    {
                        // _EK_slcf_TEMPERATURE
                        string layName = acLyrTblRec.Name.Substring(9, acLyrTblRec.Name.Length - 9);
                        acLyrTblRec.Name = "!FDS_SLCF[" + layName + "]";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_devc"))
                    {
                        // _EK_devc_t
                        string layName = acLyrTblRec.Name.Substring(9, acLyrTblRec.Name.Length - 9);
                        acLyrTblRec.Name = "!FDS_DEVC[" + layName + "]";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_went_kratka"))
                    {
                        // _EK_went_kratka_5000_+01
                        string layName  = acLyrTblRec.Name.Substring(16, acLyrTblRec.Name.Length - 20);
                        string level    = acLyrTblRec.Name.Substring(acLyrTblRec.Name.Length - 3);
                        int    levelInt = Int32.Parse(level);

                        acLyrTblRec.Name = "!FDS_VENT[" + layName + "](" + levelInt.ToString() + ")";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_mesh"))
                    {
                        acLyrTblRec.Name = "!FDS_MESH";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_open"))
                    {
                        acLyrTblRec.Name = "!FDS_MESH[open]";
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_jetf"))
                    {
                        if (acLyrTblRec.Name.Contains("_EK_jetf_devc"))
                        {
                            acLyrTblRec.Name = "!FDS_JETF[jetfan]";
                        }
                        else
                        {
                            acLyrTblRec.Name = "!FDS_JETF[jetfan]";
                        }
                    }
                    else if (acLyrTblRec.Name.Contains("_EK_pomoc"))
                    {
                        acLyrTblRec.Name = "!FDS_COMMENTS";
                    }

                    Layers.SetLayer("0");
                    // Usun nieuzywane warstwy
                    ObjectIdCollection layIds = new ObjectIdCollection();

                    foreach (ObjectId id in acLyrTbl)
                    {
                        layIds.Add(id);
                    }

                    //this function will remove all
                    //layers which are used in the drawing file
                    acCurDb.Purge(layIds);

                    foreach (ObjectId id in layIds)
                    {
                        DBObject obj = acTrans.GetObject(id, OpenMode.ForWrite);
                        obj.Erase();
                    }
                }
                // Save the new object to the database
                acTrans.Commit();
            }
        }