Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Automating setting part attributes at instance level.

Status
Not open for further replies.

mmiscool

Electrical
Sep 14, 2012
34
0
0
US
I am trying to do automatic assignment of part attributes but need them to be applied at the level above the part.

Normally I do this by right clicking on the object that I want to set the attribute to and then selecting properties. Then I go to the attributes tab and make sure that the context is set to instance.

The code in the link provided can set an attribute at the component context but I am having trouble figuring out how to make it happen for the instance. Any help would be appreciated.

 
Replies continue below

Recommended for you

The code in the link was written for NX 7.5, things changed a bit in NX 8. The following code will assign a single string attribute to the object (you'll need a reference to the instance). Change the title and string value as needed.

Code:
Dim myObject as NXObject
myObject = {reference to your object}

Dim objects1(0) As NXObject
objects1(0) = myObject
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, AttributePropertiesBuilder.OperationType.None)

attributePropertiesBuilder1.IsArray = False

attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String

attributePropertiesBuilder1.Title = "test"

attributePropertiesBuilder1.StringValue = "test value"

Dim nXObject3 As NXObject
nXObject3 = attributePropertiesBuilder1.Commit()

attributePropertiesBuilder1.Destroy()

www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top