Exemplo n.º 1
0
        public ObjectId Commit(Entity Object)
        {
            ObjectId id = AC_blockTableRecord.AppendEntity(Object);

            AC_Tr.AddNewlyCreatedDBObject(Object, true);
            return(id);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     AC_Tr.Commit();
     AC_blockTable.Dispose();
     AC_blockTableRecord.Dispose();
     AC_Tr.Dispose();
 }
Exemplo n.º 4
0
 public void closeObject(Entity Obj)
 {
     Obj.Dispose();
     AC_Tr.Commit();
     AC_blockTable.Dispose();
     AC_blockTableRecord.Dispose();
     AC_Tr.Dispose();
 }
Exemplo n.º 5
0
        /// <summary>
        /// <para>open a Group in the current Autocad Document</para>
        /// <para>Warning: Remember to dispose the Trasanction with AC_Transaction.end_Transaction</para>
        /// <para>Return:</para> <para>Null (if nothing found)</para> <para>Group (if the group name was found)</para>
        /// </summary>
        /// <param name="groupId">Name of the group to search</param>
        /// <param name="mode"> Specific mode for open the group</param>
        /// <returns></returns>
        public Group openGroup(ObjectId groupId, OpenMode mode)
        {
            start_Transaction();
            DBDictionary gd = openGroupDictionary(OpenMode.ForWrite);

            if (gd.Contains(groupId))
            {
                return(AC_Tr.GetObject(groupId, mode) as Group);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// <para>This Function let you open a object with the mode u specify.</para>
 /// <para>Return:</para><para> Null (if nothing was found)</para> <para>Entity (if there is a successful found)</para>
 /// <para>Warning: Remember to dispose the transaction with AC_Transaction.Dispose()</para>
 /// </summary>
 /// <param name="ObjId">The id of the object to open</param>
 /// <param name="mode"> specify the openmode of the object</param>
 /// <returns>null if no object was found, Entity for a succefull found</returns>
 public Entity openObject(ObjectId ObjId, OpenMode mode)
 {
     start_Transaction();
     openBlockTables(OpenMode.ForRead, OpenMode.ForRead);
     foreach (ObjectId id in AC_blockTableRecord)
     {
         if (ObjId == id)
         {
             Entity ent = AC_Tr.GetObject(id, mode) as Entity;
             return(ent);
         }
     }
     Dispose();
     return(null);
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     if (!AC_blockTable.IsDisposed)
     {
         AC_blockTable.Dispose();
     }
     if (!AC_blockTableRecord.IsDisposed)
     {
         AC_blockTableRecord.Dispose();
     }
     if (!AC_Tr.IsDisposed)
     {
         AC_Tr.Commit();
         AC_Tr.Dispose();
     }
 }
Exemplo n.º 8
0
        //GET FUNCTIONS/////////////////////////////////////////////////////////////////////////////////

        public ObjectId getGroupWithTag(string tag)
        {
            start_Transaction();
            DBDictionary gd = openGroupDictionary(OpenMode.ForRead);

            if (gd.Contains(tag))
            {
                AC_Tr.Commit();
                AC_Tr.Dispose();
                return(gd.GetAt(tag));
            }
            else
            {
                AC_Tr.Commit();
                AC_Tr.Dispose();
                return(ObjectId.Null);
            }
        }
Exemplo n.º 9
0
        public ObjectIdCollection getAllObjectsWithDic(string searchPath)
        {
            ObjectIdCollection objs = new ObjectIdCollection();

            start_Transaction();
            AC_Db = AC_Doc.Database;
            openBlockTables(OpenMode.ForRead, OpenMode.ForRead);
            foreach (ObjectId id in AC_blockTableRecord)
            {
                DBObject dbObj = AC_Tr.GetObject(id, OpenMode.ForRead) as DBObject;
                ObjectId dic   = dbObj.ExtensionDictionary;
                if (dic != ObjectId.Null)
                {
                    DBDictionary dbDic = (DBDictionary)AC_Tr.GetObject(dic, OpenMode.ForRead);
                    if (dbDic.Contains(searchPath))
                    {
                        objs.Add(id);
                    }
                }
            }
            AC_Tr.Dispose();
            return(objs);
        }
Exemplo n.º 10
0
 public DBDictionary openGroupDictionary(OpenMode mode)
 {
     return(AC_GroupDictionary = (DBDictionary)AC_Tr.GetObject(AC_Db.GroupDictionaryId, mode));
 }
Exemplo n.º 11
0
 public void end_Transaction()
 {
     AC_Tr.Commit();
     AC_Tr.Dispose();
 }