Hi All,
I’m seeking knowledge/assistance on using the NoMagic API to work with structured expressions that query the model.
Currently I have a structured expression (SE) that is a ‘Find’ operation that uses/defines criteria for all of type, scope, and properties . I would like to set that SE to the query property of a SmartPackage using a script/Macro. Preferably, that code would not use the AutomatonMacroAPI since I have the understanding that this feature will/has become unsupported.
I can set a SE to the property using the StereotypesHelper.setStereotypePropertyValue method. If the SE is “simplistic” (e.g. simple navigation or standard Find without defining property criteria), then there are no issues; it works. But if the SE is “complex”, then Cameo throws an expression evaluation failure immediately after execution of my code has completed. The CSM.log file doesn’t seem to have the resolution to indicate where it failed on the expression. I’ve found that “complex” SEs are at least ones that include nested operations (filter, find that defines property values), but there may also be others. In the “simple” case, the specification window for the SmartPackage shows the value of the query property as the name of the SE, which is typical/standard. In the “complex” case the value oddly shows as the XML string.
I’m building my SEs manually: first constructing the SE using the Cameo desktop client UI by specifying my criteria for querying the model, then doing a Copy-Whole, and finally pasting into my editor and assigning a string variable to the XML. At first, I thought maybe there were characters that needed to be escaped in the string besides single/double quotes as needed, but I’m at a dead-end there - this does not seem to be the issue. Ultimately, it ~seems~ like the value of the query property should be an object that is typed somehow as a structured expression rather than as a string of XML … but I haven’t been able to figure out how to code-up an SE using the API.
I’ve also attempted a different approach without success: recording a macro while building a "complex" SE in the UI and then running that macro again on the same element for which I just built the SE. The result is the same, “complex” SEs yield an expression evaluation failure. This leads me to believe either there is a defect, like maybe in the expression evaluation engine or the function that provides the XML representation of a SE or other, OR there is something unique about a SmartPackage, or ... I’m just in left-field somehow when working w/ SEs via the OpenAPI !
Cameo 2022x Refresh 2
Thanks!
- Calvin
