/// <summary>Добавляем ObjectData-атрибуты к примитиву чертежа</summary>
        /// <param name="wid"> ObjectId примитива </param>
        /// <param name="wr"> Данные атрибутов </param>
        /// <param name="wTbl"> Таблица ObjectData </param>
        public void AddAttr(ObjectId wid, Data.MyRecord wr, Autodesk.Gis.Map.ObjectData.Table wTbl)
        {
            if (wTbl == null)
            {
                return;
            }
            var acDoc = Application.DocumentManager.MdiActiveDocument;

            using (acDoc.LockDocument())
            {
                using (var acTrans = acDoc.Database.TransactionManager.StartTransaction())
                {
                    using (var odRecord = Record.Create())
                    {
                        wTbl.InitRecord(odRecord);
                        for (var i = 0; i < wTbl.FieldDefinitions.Count; i++)
                        {
                            var fdef = wTbl.FieldDefinitions[i];
                            var fval = wr.SearchField(fdef.Name);
                            if (fval != null)
                            {
                                if (!fval.IsGeom)
                                {
                                    odRecord[i].Assign(fval.GetString());
                                }
                            }
                        }
                        wTbl.AddRecord(odRecord, wid);
                        acTrans.Commit();
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Добавляем ObjectData-атрибуты к примитиву чертежа
 /// </summary>
 /// <param name="wid"> ObjectId примитива </param>
 /// <param name="wr"> Данные атрибутов </param>
 /// <param name="wTbl"> Таблица ObjectData </param>
 public void AddAttr(ObjectId wid, Data.MyRecord wr, Autodesk.Gis.Map.ObjectData.Table wTbl)
 {
     AppServ.Document acDoc = AppServ.Application.DocumentManager.MdiActiveDocument;
     using (AppServ.DocumentLock acLckDoc = acDoc.LockDocument())
     {
         using (Transaction acTrans = acDoc.Database.TransactionManager.StartTransaction())
         {
             using (Record odRecord = Record.Create())
             {
                 wTbl.InitRecord(odRecord);
                 FieldDefinition fdef;
                 Data.FieldValue fval;
                 for (int i = 0; i < wTbl.FieldDefinitions.Count; i++)
                 {
                     fdef = wTbl.FieldDefinitions[i];
                     fval = wr.SearchField(fdef.Name);
                     if (fval != null)
                     {
                         if (!fval.IsGeom)
                         {
                             odRecord[i].Assign(fval.GetString());
                         }
                     }
                 }
                 wTbl.AddRecord(odRecord, wid);
                 acTrans.Commit();
             }
         }
     }
 }