Toad World® Forums

Function main has not been found :(


#1

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.

scriptinghasdied.jpeg


#2

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);
}
}
}
}


#3

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…


#4

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)