Why am I not able to read the user attributes assigned to a Datum CSYS? Here is a snippet of code in which I loop through a work part's features looking for a specific name, then I try to get the attributes.
For Each temp As Features.Feature In workPart.Features If temp.Name = nameToFind Then test1 = temp found1 = True Exit For End If Next If found1 Then Dim myObject() As NXOpen.NXObject = test1.GetEntities() myAttributes = test1.GetUserAttributes()
This approach works great for Points but doesn’t work with Datum CSYS. I think this may be a problem on the NX side??? Here is a comparison of the NX generated information between a Point and Datum CSYS with user attributes.
Point – User Attributes (note, the feature attributes are clearly defined)
Datum CSYS – User Attributes (note, feature attributes are listed but not clearly defined with a title compared to the above)
When I run the code above, I am able to pull the user attributes out of Point but not Datum CSYS. The above seems to be the only logical reason why to me…
Solved! Go to Solution.
Check the object type & subtype of what you find.
Actually, first thing I'd do is remove the "exit for", put a counter in & see how many objects match the name (and what each object type & subtype are).
Could be you're not finding what you think you are looking for...
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
Does your code generate the attribute report? If so, could you show the code that writes to the listing window (or other location)? It doesn't seem to be included in the code snippet that was posted.
Were the attributes assigned to the datum csys feature or to the datum csys object itself? Objects and features can each have their own set of independent attributes. Make sure that you are applying them to and querying them from the correct type.
I list out the name and feature name in the listing window after I recieve a name match as you can see below. I repeated portions of the snippet above so you can follow the flow of the code more easily. The code does not generate the attribute report but as I debug and run through the loop I note the the variable attributeLength does not get populated as it passes through the Datum CSYS.
I believe they were assigned to the feature as it was performed by right clicking and selecting properties from the feature listed in the Part Navigator. Forgive me I am new to NX, but how can one tell the difference between a feature and an object?
I have attached the Information on the feature that is found when right clicking on the feature in the Part Navigator and selecting Information.
For Each temp As Features.Feature In workPart.Features If temp.Name = nameToFind Then test1 = temp found1 = True Exit For End If Next If found1 Then Dim myObject() As NXOpen.NXObject = test1.GetEntities() myAttributes = Nothing attributeLength = Nothing myAttributes = test1.GetUserAttributes() attributeLength = myAttributes.Length For Each obj As NXObject In myObject If TypeOf (obj) Is NXOpen.Point Then Dim feat As NXOpen.Point = obj Dim myCoordfeat As Point3d myCoordfeat = feat.Coordinates lw.WriteFullline(test1.Name & "-" & test1.GetFeatureName & ": " & myCoordfeat.ToString)
I figured out the issue, thanks @cowski1, your post was the key. When setting attributes on a Datum CSYS, in the Property dialogue box you can select to apply to the object or the feature as shown below. Changed it to apply to the feature and code works as intended.
If you apply the attributes in interactive NX, make sure that you check the Context -> apply to option. I'm running NX 9, when I right click on a datum csys, it seems to default to object rather than feature. If your code isn't reporting attributes on a particular datum csys feature, it would indicate to me that perhaps the properties were applied to the object rather than the feature. You can check this by right clicking on the datum csys and toggling between the feature and object attributes.
Edit: glad you got it working...