Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating setting part attributes at instance level.

Status
Not open for further replies.

mmiscool

Electrical
Joined
Sep 14, 2012
Messages
34
Location
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.

 
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.

Part and Inventory Search

Sponsor

Back
Top