Exemple #1
0
        public static void AddToAT_SUB(ObjectId NewSub, ObjectId Container)
        {
            bool   NewSubExisted = false;
            Editor ed            = Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                AT_SUB at_sub = AT_SUB.SelectBySelectedObjectId(Container);
                foreach (ObjectId oi in at_sub.SubIdCollection)
                {
                    if (NewSub == oi)
                    {
                        NewSubExisted = true;
                    }
                }
                if (NewSubExisted == false)
                {
                    at_sub.SubIdCollection.Add(NewSub);
                    at_sub.Insert();
                }
            }
            catch
            {
                AT_SUB at_sub = new AT_SUB(Container);
                at_sub.SubIdCollection.Add(NewSub);
                at_sub.Insert();
            }
            //ed.writeMessage("SubInserted Finished\n");
        }
Exemple #2
0
        public static void RemoveFromAT_SUB(ObjectId OldSub, ObjectId Container)
        {
            Editor ed            = Application.DocumentManager.MdiActiveDocument.Editor;
            bool   OldSubExisted = false;

            try
            {
                AT_SUB at_sub = AT_SUB.SelectBySelectedObjectId(Container);
                foreach (ObjectId oi in at_sub.SubIdCollection)
                {
                    if (OldSub == oi)
                    {
                        at_sub.SubIdCollection.Remove(oi);
                        OldSubExisted = true;
                    }
                }


                //if (OldSubExisted == true)
                //{

                if (at_sub.SubIdCollection.Count > 0)
                {
                    at_sub.Insert();
                }
                else
                {
                    //int a = 0;
                    Delete(Container, "AT_SUB");
                }

                //}
            }
            catch (System.Exception ex)
            {
                //ed.WriteMessage("Error RemoveFromAT_SUB: " + ex.Message + "\n");
            }
        }