Submitted by Vicky Bhausaheb... on Mon, 06/08/2020 - 02:12
Forums:
Hello,
I manually put values for two attribue, now i need to multiply those values and save on Child level in new Attribute.
How Can I do this?
Please help on same.
re: multiply attribute values
Were the existing attributes saved as "number" type, "string" type, or something else?
If they were created as "number" attributes, you can get the values with code similar to that shown below:
Const attributeName As String = "TEST"
Dim attributeInfo As NXObject.AttributeInformation
Dim testVal As Double
If workPart.HasUserAttribute(attributeName, NXObject.AttributeType.Real, -1) Then
attributeInfo = workPart.GetUserAttribute(attributeName, NXObject.AttributeType.Real, -1)
testVal = attributeInfo.RealValue
lw.WriteLine("attribute value: " & testVal.ToString)
Else
lw.WriteLine("the work part does not have a number attribute named: " & attributeName)
End If
Once you have the 2 values, you can multiply them together and assign the value to a new attribute. If all the attributes are assigned to the same part, you might be able to create an expression that will update when the attribute values change and assign the updated value to an attribute.
How to Update the new value
How to Update the new value to new attribute?
is there any Method?
re: Set Attribute
In general, the .SetUserAttribute method is used to create an attribute on an object. If you record a journal while creating an attribute on the desired object, you will get some useful code to start with. Assigning an attribute to the work part would look something like this:
workPart.SetUserAttribute(_attributeTitle, -1, _attributeValue, Update.Option.Later)