示例#1
0
        public ObjectId Commit(Entity Object)
        {
            ObjectId id = AC_blockTableRecord.AppendEntity(Object);

            AC_Tr.AddNewlyCreatedDBObject(Object, true);
            return(id);
        }
示例#2
0
        /// <summary>
        /// <para>Add a group to the current autocad document</para>
        /// <para>Return: Group</para>
        /// </summary>
        /// <param name="name">Group name</param>
        /// <param name="DbObjs">Object Collection to associate with group</param>
        /// <param name="autorename"><para>if a group has already the specified name</para>
        /// <para>This let the function assign an unique generated name</para></param>
        /// <returns></returns>
        public ObjectId addGroup(string name, DBObjectCollection DbObjs, bool autorename)
        {
            Group grp = new Group(name, true);
            ObjectIdCollection ids = new ObjectIdCollection();

            start_Transaction();
            DBDictionary gd = openGroupDictionary(OpenMode.ForWrite);

            if (gd.Contains(name))
            {
                if (autorename)
                {
                    name = name + "_" + Guid.NewGuid().ToString();
                }
                else
                {
                    return(ObjectId.Null);
                }
            }
            gd.SetAt(name, grp);
            AC_Tr.AddNewlyCreatedDBObject(grp, true);

            openBlockTables(OpenMode.ForRead, OpenMode.ForWrite);
            foreach (Entity ent in DbObjs)
            {
                ObjectId id = Commit(ent);
                ids.Add(id);
            }
            grp.InsertAt(0, ids);
            gd.Dispose();
            Dispose();

            return(grp.ObjectId);
        }