Пример #1
0
        private static bool ModifyBlockTableRecordField(BlockTableRecord obj, string fieldName, string fieldValue)
        {
            using (var tr = CurrentDatabase.TransactionManager.StartTransaction())
            {
                if (!obj.HasFields)
                {
                    return(false);
                }

                var fields = ((Field)tr.GetObject(obj.GetField(), OpenMode.ForRead)).GetChildren();

                var requestedField = fields.FirstOrDefault(f => f.Equals(fieldName));

                var fieldCode = requestedField.GetFieldCode(FieldCodeFlags.AddMarkers | FieldCodeFlags.FieldCode);

                var newField = new Field(fieldValue);

                obj.SetField(fieldCode, newField);

                tr.Commit();
            }

            return(obj.FieldValueEquals(fieldName, fieldValue));
        }