FieldDefinition.Set 方法用于为文档要素图层的属性字段设置字段定义。 无法更新现有字段的字段类型或者修改 web 要素图层字段定义。
声明
public bool Esri.ArcGISForAutoCAD.FieldDefinition.Set(Document doc, string flName, string name, string sublayerName = null, int? length = null, IConvertible value = null, bool? readOnly = null)
参数
| 类型 | 名称 | 描述 | 必填 |
|---|---|---|---|
文档 | doc | 要进行操作的 AutoCAD 文档。 | 必填 |
string | flName | 工程图中现有的要素图层名称。 | 必填 |
string | name | 字段名称。 | 必填 |
string | sublayerName | 工程图中现有的要素图层子图层名称。 当设置子图层的字段定义时,仅设置默认值。 | 可选 |
int | length | 仅适用于文本字段的字段长度。 | 可选(设置为 UI 默认值) |
IConvertible | value | 默认字段值。 | 可选(设置为 UI 默认值) |
bool | readOnly | 指定新字段是否为只读。 true = 只读 | 可选 |
返回
| 类型 | 值描述 |
|---|---|
bool | 如果已成功设置字段定义,则为 true |
错误条件备注
如果参数无效,则此方法可能会抛出异常或者返回 false 或 null。
示例
打印在 Parks 要素图层中更新 Location 字段的定义成功。// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
// Update the field definition
var success = Esri.ArcGISForAutoCAD.FieldDefinition.Set(doc, "Parks", "Location", null, 254, "CA");
// Print the success
doc.Editor.WriteMessage(success.ToString());
/* Example output
True
*/
另请参阅
esri_fielddef_set - 此 AutoLISP 函数用于设置字段定义。