cancel
Showing results for 
Search instead for 
Did you mean: 

How to create Attributes on a Tabular note or on a object

Pioneer
Pioneer

'Hi,

I need to create some attributes on a Tabular Note.

I know the Tag of it.

 

Recorded a Journal. modified it as a method.

If i pass the object on to that, it creates an Attributes.

This is working if i pass the drawing sheet object, where as if i create a Tabular Note and pass that then, no attribute is created.

 

Can somebody let me know why it is not able to create attribute on a object.

 

public static void CheckAndCreateAttribute_String(Part workPart, NXOpen.NXObject nxObject, string sAttributeName, string sAttributeValue, string sAttributeCategory)
{
	if (sAttributeName.Length == 0) return;
	if (sAttributeValue.Length == 0) sAttributeValue = "";
	Boolean bHasAttribute = nxObject.HasUserAttribute(sAttributeName, NXObject.AttributeType.String, -1);

	if (!bHasAttribute)
	{
		NXObject[] arrObjects = new NXObject[1];
		arrObjects[0] = nxObject;

		AttributePropertiesBuilder attributePropertiesBuilder1;
		attributePropertiesBuilder1 = Session.GetSession().AttributeManager. CreateAttributePropertiesBuilder( workPart, arrObjects, NXOpen.AttributePropertiesBuilder.OperationType.None);
		attributePropertiesBuilder1.SetAttributeObjects(arrObjects);
		attributePropertiesBuilder1.Category = sAttributeCategory;
		attributePropertiesBuilder1.IsArray = false;
		attributePropertiesBuilder1.Title = sAttributeName;
		attributePropertiesBuilder1.DataType = NXOpen.AttributePropertiesBaseBuilder.DataTypeOptions.String; 
		attributePropertiesBuilder1.StringValue = sAttributeValue;
		attributePropertiesBuilder1.Commit();
		attributePropertiesBuilder1.Destroy();
	}
}

 

Regards,

Maddy

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4
2 REPLIES

Re: How to create Attributes on a Tabular note or on a object

Phenom
Phenom

Tabular notes are a bit tricky. There are tabular note objects and tabular note section objects. I think you will need to add the attributes to the "tabular note section" object to make them visible to the user.

Re: How to create Attributes on a Tabular note or on a object

Pioneer
Pioneer

Thanks cowski1,

 

Thats what i was looking for.

 

Regards,

Maddy

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4