adding and deleting time scales

5.53K viewsScripting
0

Same issue different model.

Thgis creates a non destructive method of adding to a time scale where entries may have taken place. The adding of time works but deleting does not. Any ideas what I am doing wrong.

Also documentation would be helpful.

script below and file attached.
——————————————————————-
void perform()
{
def currentConstruction = (int) |Matrix1::Construction|.children.size()
def currentPerformance = (int) |Matrix1::Performance|.children.size()

def desiredConstruction = (int) |Matrix2::Construction|.value;
def desiredPerformance = (int) |Matrix2::Performance|.value;

if(desiredConstruction > currentConstruction)
{
|Matrix1::Construction|.children.createAt(0,(-desiredConstruction)..<(-currentConstruction)).each {name = “”Month “” + name ;}
}
else if(desiredConstruction < currentConstruction)
{
|Matrix1::Construction|.children.get((-currentConstruction)..<(-desiredConstruction)).delete()
}

if(desiredPerformance > currentPerformance)
{
|Matrix1::Performance|.children.create((currentPerformance+1)..desiredPerformance).each {name = “”Month “” + name ;}
}
else if(desiredPerformance < currentPerformance)
{
|Matrix1::Performance|.children.get((desiredPerformance+1)..currentPerformance).delete()
}
}

boolean enabled()
{
return !(|Matrix1::Construction|.children.size() == |Matrix2::Construction|.value
&& |Matrix1::Performance|.children.size() == |Matrix2::Performance|.value);
}

Attachments

script.model
0

Thanks that works, I really would like to see some documentation of scripting so I don’t always have to post.

You are viewing 1 out of 6 answers, click here to view all answers.

Latest Questions