Cancel
Showing results for
Did you mean:

# NX Expression List - Casting the output of nth()

Legend

I have a list expression containing angles.

`(List) mylist = {10, 20, 30}`

And I have an offset angle

`[degrees] alpha = 50`

Now I want to use the sum of one of the list angles and alpha in another expression, e.g.

`test = cos(alpha + nth(1,mylist))`

This raises an error, as the list element is per default interpreted as Length, and i cant add Length and Angle.

I know I could create an extra expression

`[degrees] myelement = nth(1,mylist)`

and perform the addition, but when doing this for a long list this clutters my expressions with extra stuff.

Is there a way to cast the type of the expression? Or tell nth to return an angle?

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX11 | RHEL7 | Python
4 REPLIES

# Re: NX Expression List - Casting the output of nth()

Gears Esteemed Contributor

What dimensionality did you use for the "test" expression? It should probably be "constant" instead of "Length".

# Re: NX Expression List - Casting the output of nth()

Legend
Ah thanks! Because the cos is later multiplied by a length, the proper result is a length - but changing it to constant made it work.
Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX11 | RHEL7 | Python

# Re: NX Expression List - Casting the output of nth()

Gears Esteemed Contributor

If this is part of a larger expression that results in a length, then the expression should be defined as a length. However, the result of the "nth" function is then interpreted as a length as well, giving rise to the error you encountered. NX should be able to convert the units by appending [degrees] after the value, but this doesn't seem to work in conjunction with the "nth" function.

I would suggest that you contact GTAC and open an incident report. They can open an 'enhancement request' to improve this situation in a future version of NX. For now, the only work-around I see is to use the 'extra' expression to convert the list value to the desired dimensionality or use a constant type expression to represent the length, which isn't ideal.

# Re: NX Expression List - Casting the output of nth()

Legend

So I contacted GTAC. After some back and forth, it is now an official problem report.

The poor GTAC guy probably deals with so many PEBKAC bugs each day that it took some time for him to see the actual problem, and not just a user trying to subtract an angle and a length and wondering why it didn't work.

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX11 | RHEL7 | Python