示例#1
0
        static public void GetObjectMng()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect custom object: ");

            peo.SetRejectMessage("\nInvalid selection...");
            peo.AddAllowedClass(typeof(asdkCustomCircleMgd), true);

            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK)
            {
                return;
            }

            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                asdkCustomCircleMgd entity = Tx.GetObject(per.ObjectId, OpenMode.ForWrite)
                                             as asdkCustomCircleMgd;

                entity.ColorIndex = 1;

                Tx.Commit();
            }
        }
示例#2
0
        static public void AddObjectMng()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            PromptPointOptions ppo = new PromptPointOptions("\nSelect center: ");

            PromptPointResult ppr = ed.GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = Tx.GetObject(db.BlockTableId, OpenMode.ForRead)
                                as BlockTable;

                BlockTableRecord model = Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
                                         as BlockTableRecord;

                asdkCustomCircleMgd entity = new asdkCustomCircleMgd();

                entity.setCenter(ppr.Value);
                entity.setRadius(3.0);
                entity.gc2AcString("My Test String");
                entity.convertFromMgdObjectId(model.Id);

                model.AppendEntity(entity);
                Tx.AddNewlyCreatedDBObject(entity, true);

                Tx.Commit();
            }
        }