Function main has not been found :(

I waswriting a simple script to delete all attributes with „pro_id” substringinside. I wrote a script, tried it, found a mistake, tried to run this onceagain and got very interesting message.

My scriptand message are shown in attachment.

Note: project names have been obscured for purpose.

function main(){
var i,j;
var Ent;
var Attr;
for (i=0; i<MyModel.Entities.Count; i++)
{
Ent = MyModel.Entities.GetObject(i);
for (j=0; j<Ent.Attributes.Count; j++)
{
Attr = Ent.Attributes.GetObject(j);
if (Attr.Name.indexOf(‘pro_id’) != -1)
{
Ent.Attributes.delete(j);
}
}
}
}

Just in case you don’t know:

You can’t just delete an Attribute from an Entity Attributes list with
Ent.Attributes.delete(j);

Even if you succeed, your model will be corrupted. You must call the Delete method of the Attribute:
if (Attr.Name.indexOf(‘pro_id’) != -1) Attr.Delete();

But thanks for bringing up an issue with scripting, looks like an internal bug…

Hello Michal,

What you required was not available in Beta 3.1.3.55, but it IS available in the new build - Beta 3.1.3.56.

Please update your Beta.
http://modeling.inside.quest.com/ann.jspa?annID=150

Please find attached a corrected script for you.

In case of any questions or troubles, please write us back.

Vladka + TDM Team
Script_Michal.js (820 Bytes)