NXObject.SetUserAttribute()は、文字列属性、整数属性、実数値属性などの複数のタイプを含む、NXObjectオブジェクトの属性を設定するために使用されます。
aggedObject[] taggedObjects = _FaceSelect.GetSelectedObjects();
Face face = (Face)taggedObjects[0];
//根据属性信息添加属性
NXObject.AttributeInformation attributeInformation = new NXObject.AttributeInformation();
attributeInformation.Type = NXObject.AttributeType.String;
attributeInformation.Title = "Attribute_Face_1";
attributeInformation.StringValue = "Attribute_1_string";
face.SetUserAttribute(attributeInformation,Update.Option.Now);
//添加int属性
string intTitle = "IntAttributeTitle";
int intValue = 1;
face.SetUserAttribute(intTitle,0,intValue,Update.Option.Now);
//添加double属性
string doubleTitle = "DoubleAttributeTitle";
double doubleValue = 2.1;
face.SetUserAttribute(doubleTitle,0,doubleValue,Update.Option.Now);
//添加字符串属性
string stringTitle = "StringAttributeTitle";
string stringValue = "stringValue";
face.SetUserAttribute(stringTitle,0,stringValue,Update.Option.Now);
追加すると、サーフェスプロパティに次のように表示されます。
顔のすべての属性を表示するには、NXObject.AttributeInformation [] attributeInformation1 = face.GetUserAttributes();を使用します。
NXObject.AttributeInformation[] attributeInformation1 = face.GetUserAttributes();
UFUi theUFUi = theUFSession.Ui;
theUFUi.OpenListingWindow();
int i = 0;
foreach(var ai in attributeInformation1)
{
if (ai.Type == NXObject.AttributeType.String)
{
theUFUi.WriteListingWindow(i++.ToString() + " " + ai.Title + " "+ai.StringValue+"\n");
}
else if(ai.Type==NXObject.AttributeType.Integer)
{
theUFUi.WriteListingWindow(i++.ToString()+" "+ai.Title+" "+ai.IntegerValue.ToString()+" \n");
}
else if (ai.Type == NXObject.AttributeType.Real)
{
theUFUi.WriteListingWindow(i++.ToString() + " " + ai.Title + " " + ai.RealValue.ToString() + " \n");
}
}
属性の削除、NXObject.Delete ***()
public void DeleteAllAttributesByType(AttributeType type);
public void DeleteAllAttributesByType(AttributeType type, Update.Option option);
public void DeleteAttributeByTypeAndTitle(AttributeType type, string title, Update.Option option);
public void DeleteAttributeByTypeAndTitle(AttributeType type, string title);
public void DeleteUserAttribute(AttributeType type, string title, bool deleteEntireArray, Update.Option option);
public void DeleteUserAttributes(AttributeType type, Update.Option option);
public void DeleteUserAttributes(AttributeIterator iterator, Update.Option option);