Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.3K Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

[?] Use WSMSetValues for setting records and replaceable packages?

POSTED BY: Eric Smith
3 Replies

Unfortunately there is currently no way to set values from WSMLink to an expression. WSMSetValues only takes literals (numbers, booleans and strings). There is also currently no way to redeclare things (which I assume is what you want for the Medium).

We'd like to add this in a future version, but haven't designed how it would work yet.

Today I recommend that you use Model Center for changes like these.

A really bad workaround would be to fetch the Modelica string, make the modifications yourself using string manipulation, and then evaluate the Modelica string. I don't recommend it, but below are the pieces you would need.

Be careful, you can easily destroy your models using this.

str = WSMModelData[model, "ModelicaString"]
(* Do string manipulation here *)
newstr = ...
(* If your model is not on top level you need to prepend a "within A.B.C;" to newstr,
  where the A.B.C is the path to the package the model is placed *)
WSMLink`Library`EvaluateModelicaInput[newstr]
POSTED BY: Malte Lenz

Awesome, I figured I'd have to do some text editing, but I didn't know about WSMLink'Library'EvaluateModelicaInput. Just now I was just able to script about 30 records and use within to put them where I needed them. Thanks!

POSTED BY: Eric Smith

Glad it helped.

As usual, the functions in the WSMLink`Library` context are undocumented and therefore unsupported, so they might stop working in future releases.

POSTED BY: Malte Lenz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard