NX Open Programmer's Guide > Compiling and linking non-ASCII characters > Editing expressions
Editing expressions
If you edit an expression by using APIs, the expression comment may get deleted if the comment is not added to the expression value (RHS — right-hand side). This applies, for example, to the GRIP statement EXPEDT as well as to the NX Open ExpressionCollection and Expression classes.
If the comment is not added to the formula or right-hand side during editing, then the comment is deleted without any notification or response to the user.
Practical implication
When writing NX Open code that programmatically edits an Expression object's formula/value (its RHS), any existing trailing comment on that expression is silently lost unless your code explicitly re-appends the comment text as part of the new value string you set. There is no callback, exception, or warning — the comment is simply gone. Any NX Open program that edits expressions in bulk (e.g. driven from a spreadsheet or external data source) should defensively read back the existing comment (if preserving comments matters) before overwriting the expression's value, and reattach it to the new value string.
Related Topics
- Development Cycle Considerations
- Journals
- Compiling and linking Overview
- NX Open and redo (see
update-manager-and-undo.md)
Note on scope
This is the only dedicated page on expression editing found in the NX Open Programmer's Guide book itself; it covers a specific comment-preservation gotcha rather than the full Expression/ExpressionCollection API surface (members, units, expression types, suppression, etc.). The full class-level API reference for NXOpen.Expression and NXOpen.ExpressionCollection (properties, methods, constructors) lives in the language-specific API references (nxopen-cpp-reference, nxopen-dotnet-reference, nxopen-java-reference, nxopen-python-reference), which are covered separately.
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/xid1312901 · retrieved 2026-07-07