Kenja824
Automotive
- Nov 5, 2014
- 949
I have some code that allows me to select an attribute and a box will pop up showing me certain attributes. Then I can change those attributes to what I wish and hit OK and it will add those attributes to the selected component.
However, this code was originally for a workpart and not for a selected component. When the list pops up with the specific attributes, it is showing me the attributes for the work part and not the component I had selected.
I believe the problem is in this function...
Can someone tell me what needs to change to read the selected component? Or if this code wouldnt change anything, let me know that?
However, this code was originally for a workpart and not for a selected component. When the list pops up with the specific attributes, it is showing me the attributes for the work part and not the component I had selected.
I believe the problem is in this function...
Can someone tell me what needs to change to read the selected component? Or if this code wouldnt change anything, let me know that?
Code:
Private Function readAttribute(ByVal selPart As Part, ByVal attrName As String) As String
Dim attrValue As String = Nothing
Dim iRes As Integer
Dim attrInfor As NXOpen.NXObject.AttributeInformation = Nothing
Dim attrtype As NXOpen.NXObject.AttributeType = NXObject.AttributeType.String
theUFSession.Attr.FindAttribute(selPart.Tag, 5, attrName, iRes)
If iRes <> 0 Then
attrInfor = selPart.GetUserAttribute(attrName, attrtype, 2)
attrValue = attrInfor.StringValue
Else
attrValue = "---"
End If
Return attrValue
End Function