Hi,
I want to set a tag with a script:
Global.getFinder(selection).forEach(function (p) { p.mediniTags = 'not reviewed';});
but I am sure, this will not work, ;-)
How can I manage to create these Tags?
Sven
Hi Sven,
The mediniTags property is a list, so normally "p.mediniTags.add('not reviewed');" would help (like below), but that will not work either in this case, because the mediniTags is a derived property (marked with a "*") in the attributes view, so you cannot directly modify it.
The methods to modify the tags list are currently not made available for scripting, so to my knowledge there is currently no way to change tags via scripting. Maybe Jan may look into this in March.
Regards,
Nils
Hello guys, it feels good to be back.
I have to admit that I also was lost a bit on the tags API. And it is neither obvious how it looks like, now straight forward to implement something, once you know how it looks like.
Anyway, I managed to add a tag after some time, here is my result:
// $EXPERIMENTAL$var BasicEList = bind("org.eclipse.emf.common", "org.eclipse.emf.common.util.BasicEList", false);var element = selection[0];var tags = element.mediniTags;var newTags = new BasicEList();newTags.addAll(tags);newTags.add('foo');element.mediniSetTags(newTags);
As you will see you may execute the script several times but the tag is only once so you do not need to check for existence.
Happy Scripting
Jan
PS: I will add an addTag and removeTag function to our helper.js lib for convenience.
Was needing to do this and found this answer, which works great. Two questions:
Todd,
latest libraries can be found here: Scripting Libraries : Ansys medini analyze Support.
The BasicEList is basically a special immplementation of a Java List class that is used to hold the tag (string) objects. In contrast to other List based API in medini, this one doe snot offer any add/remove functions at the list. Instead the complete list must be prepared and set as one.
I figured that the latest helper.js has no such method, I am sorry.
Will try to provide it. Anyhow, the APi as described above is rather simple so it should be clear how to work with tags without any helper I hope.
Update: we added a few methods to deal with tags (hasTag, addTag, removeTag) to helper.js and uploaded the latets lib to the shared site.
Hello Jan,
When creating an Interface (in my case: a test), I would like the Interface tag to be assigned automatically in the tags section rather than adding it manually. I noticed you mentioned that new methods are now available to achieve this. Could you please confirm whether the script can still be used for that purpose?
Kind regards,
Hiba
Hi Hiba,
When "automatically" means running a script, then yes, you can use the helper.js functions as pointed out by Jan above to check for each "interface" kind part if it has that tag and if not add it.
The library can be found here: https://medini.freshdesk.com/a/solutions/articles/1000273630
I guess the more precise question is, "created by an automation script" or "created by the user". In first case, of course, as Nils mentioned, you can also add the tag but in the later, no.
There is no support to add tags somewhat as side effect of the users work while modelling.