public static void populatepropertysetswithoddata() { DocumentCollection docCol = Application.DocumentManager; Database localDb = docCol.MdiActiveDocument.Database; Editor ed = docCol.MdiActiveDocument.Editor; Document doc = docCol.MdiActiveDocument; CivilDocument civilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument; //Reference ODTables Tables tables = HostMapApplicationServices.Application.ActiveProject.ODTables; DictionaryPropertySetDefinitions dictPropSetDef = new DictionaryPropertySetDefinitions(localDb); using (Transaction tx = localDb.TransactionManager.StartTransaction()) { try { //I need to work with 3d polylines //Change here to add other types of objects HashSet <Entity> ents = new HashSet <Entity>(); ents.UnionWith(localDb.HashSetOfType <Line>(tx)); ents.UnionWith(localDb.HashSetOfType <Spline>(tx)); ents.UnionWith(localDb.HashSetOfType <DBPoint>(tx)); ents.UnionWith(localDb.HashSetOfType <Polyline>(tx)); ents.UnionWith(localDb.HashSetOfType <Polyline3d>(tx)); ents.UnionWith(localDb.HashSetOfType <BlockReference>(tx)); //ents = ents.Where(x => x.Layer == "0-FJV_fremtid").ToHashSet(); foreach (Entity ent in ents) { ObjectIdCollection psIds = PropertyDataServices.GetPropertySets(ent); List <PropertySet> pss = new List <PropertySet>(); foreach (Oid oid in psIds) { pss.Add(oid.Go <PropertySet>(tx, OpenMode.ForWrite)); } using (Records records = tables.GetObjectRecords(0, ent.Id, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, false)) { int recordsCount = records.Count; for (int i = 0; i < recordsCount; i++) { Record record = records[i]; string tableName = record.TableName; //Specific to my implementation if (tableName == "IdRecord") { continue; } PropertySet propertySet = pss.Find(x => x.PropertySetDefinitionName == tableName); if (propertySet == null) { tx.Abort(); ed.WriteMessage($"\nPropertySet with the name {tableName} could not be found!"); return; } Table table = tables[tableName]; FieldDefinitions fDefs = table.FieldDefinitions; int fieldsCount = fDefs.Count; for (int j = 0; j < fieldsCount; j++) { FieldDefinition fDef = fDefs[j]; string fieldName = fDef.Name; int columnIndex = fDefs.GetColumnIndex(fieldName); MapValue value = record[columnIndex]; int psIdCurrent = propertySet.PropertyNameToId(fieldName); propertySet.SetAt(psIdCurrent, GetMapValueData(value)); } } } } } catch (System.Exception ex) { tx.Abort(); ed.WriteMessage(ex.ToString()); return; } tx.Commit(); prdDbg("Finished!"); } }