Lava Scripting Support

Gantt module functions by category

Error functions

HasError()

Use to determine if the executed function returns an error.

1 if the last action has an error.

GetGanttLastError()

Get the text of last error for a function that has an error.

The localized string with the error description.

Gantt::Save(““); if(Gantt::HasError()) { $error - Gantt::GetGanttLastError(); $errorMsg - "Gantterror: $error"; }

Project Setup functions

Activity Type

GetActivityTypeNames()

Get the list of activity types available in the project.

Return value: An array with the activity type names.

@results - Gantt::GetActivityTypeNames();
Split()

Description : Parse out attributes from a triangulation's name based on the delimiter.

Return value: User defined character.

@results- Gantt::SPLIT(attribute, delimeter, bin)

In the example of an attribute called Activity Name and an example name being 3-SE105-EXT-1

Zone: SPLIT( [ATT:Activity Name], '-', 1) that would return 3
Area: SPLIT( [ATT:Activity Name], '-', 2) that would return SE105
Type: SPLIT( [ATT:Activity Name], '-', 3) that would return EXT
Room: SPLIT( [ATT:Activity Name], '-', 4) that would return 1

Attributes

GetAttributeNames()

Get the list of all attributes available in the project.

Return value:An array with the attribute names.

@results - Gantt::GetAttributeNames();

Calendar

GetCalendarNames()

Get a list of all calendars available in the project.

Return value: An array with the calendar names.

@results - Gantt::GetCalendarNames();
RemoveCalendar(calendarName)

Remove a calendar in the project.

Some calendars cannot be removed if they are used, like the global calendar of the project or used by a resource.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyCalendar("Maintenance");  
ApplyCalendar(calendarName)

Set the global calendar for the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyCalendar("Default Calendar");

File

Save(projectName)

Save as the project in the projectName file. If the project name is empty the file will be saved in the original file.

1 if it succeeds, 0 if it fails.

$result - Gantt::Save("LavaDemo.vgantt");

Filter Definition

GetFilterNames()

Get a list of filters available in the project.

Return value: An array with the filter names.

@result - Gantt::GetFilterNames();
ApplyFilter(filterName)

Set the filter in the project as the current filter.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyFilter("Ore");
ClearFilter()

Clear the current filter

1 if it succeeds, 0 if it fails.

$result - Gantt::ClearFilter();

We can get the same result if we use ApplyFilter with an empty name.

$result - Gantt::ApplyFilter("");
AddFilter(filterName,filterExpression)

Add a filter to the filter collection.

1 if it succeeds, 0 if it fails.

$result - Gantt::AddFilter("No Au", "[ATT:Au]- 0");
RemoveFilter(filterName)

Remove the named filter from the filter collection in the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemoveFilter("Ore");

Lookup Table Definition

GetLookupTableNames()

Get a list of lookup tables available in the project.

Return value: An array with the lookup table definition names.

@result - Gantt::GetLookupTableNames();
AddLookupTable(tableName, tableValues)

Add a new lookup table with its values to the project.

Note:  The expression format is defined by the following rules:

Key lines are separated by return (\n).

Values are separated by tabs (\t).

It is not a requirement that all rows have the same number of columns

Key_1{TAB}Value_11{TAB}Value_12{TAB}value_13{TAB}……..{TAB}Value_1n{ENTER} Key_2{TAB}Value_21{TAB}Value_22{TAB}value_23{TAB}……..{TAB}Value_xn{ENTER} Key_3{TAB}Value_31{TAB}Value_32{ENTER} … Key_m{TAB}Value_m1{TAB}Value_m2{TAB}value_m3{TAB}……..{TAB}Value_mz{ENTER}

1 if it succeeds, 0 if it fails.

For this table

Key

Value 1

Value 2

Value 3

Value 4

Value 5

Key1

0

1

2

3

4

Key2

4

5

6

Key3

78

2.6

r

tableValues"Key1\t0\t1\t2\t3\t4\nKey2\t4\t5\t6\nKey3\t78\t2.6\tr"; $result - Gantt::AddLookupTable("Table 1",); 
GetLookupTableValues(tableName)

Get the values from an existent lookup table in the project.

Return value: A string with the lookup table definition values. The tableValues has the same format as described in AddLookupTable.

$result - Gantt::Clear GetLookupTableValues("Translation"); 
SetLookupTableValues(tableName, tableValues)

Set the values to an existent lookup table.

1 if it succeeds, 0 if it fails.

tableValues"Key1\t0\t1\t2\t3\t4\nKey2\t4\t5\t6\nKey3\t78\t2.6\tr"; $result - Gantt::ClearFilter("Table 1",tableValues); 
RemoveLookupTable(tableName)

Remove a lookup table from the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemoveLookupTable("Translation");

Period Definition

GetPeriodNames()

Get a list of period definitions available in the project.

Return value:An array with the period definition names.

@result - Gantt::GetPeriodNames(); 
ApplyPeriod(periodName)

Set the current period definition in the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyPeriod("Forecast"); 
ClearPeriod()

Clear the current period definition in the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::ClearPeriod();
RemovePeriod(periodName)

Remove a period definition from the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemovePeriod("Forecast");

Precedence Group Definition

GetPrecedenceGroupNames()

Get a list of precedence group definitions available in the project.

Return value:An array with the Precedence group definition names.

$result - Gantt::GetPrecedenceGroupNames();
ApplyPrecedenceGroup(groupName)

Set the current precedence group definition.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyPrecedenceGroup("Developmentto Stoping"); 
ClearPrecedenceGroup()

Clear the current precedence group definition.

1 if it succeeds, 0 if it fails.

$result - Gantt::ClearPrecedenceGroup () ;
AddPrecedenceGroup(groupName, lineStyle, colour, isApplied)

Add a precedence group definition to the project and set it current.

Where:

group Name - is the name for the new group.

lineStyle - is a value defining the line style for the precedence in the group. Valid values are between 0 and 4.

colour - is an integer from 0 to 65535 equivalent to an RGB color.

isApplied - is a value 0 or 1 that indicates if the group is applied or not.

1 if it succeeds, 0 if it fails.

$result - Gantt::AddPrecedenceGroup("Group1", 1, 1500, 1);

Report Definition

GetReportNames()

Get a list of available reports in the project.

Return value: An array with the report definition names.

@result - Gantt::GetReportNames();
ApplyReport(reportName)

Set the current summary report in the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::ApplyReport("Totals");
ClearReport()

Remove the current summary report in the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::ClearReport();
RemoveReport(reportName)

Remove a report in the report collection from the project.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemoveReport("Totals");

Resource Definition

GetResourceNames()

Get a list of available resources in the project.

Return value: An array with the resource definition names.

@result - Gantt::GetResourceNames();
RemoveResource(resourceName)

Remove a resource from the project collection.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemoveResource("Mucking");

Activities Functions

Attribute

GetSingleAttributeValue(attrName)

Get the value of attrName for the selected activity.

Return value: A string with the attribute value.

$result - Gantt::GetSingleAttributeValue("Duration");
GetAttributeValues(attrNameListReference)

Get a list of values corresponding to the list of attribute names for the selected activity.

Return value: An array with the attribute values, with the same size of attrNameListReference.

@results - Gantt::GetAttributeValues(\@fields);

SetAttributeValue(attrName, attrValue)

Set the value for the attrName on the selected activity.

1 if it succeeds, 0 if it fails.

$result- Gantt::SetAttributeValue("Start", "5/10/2015 8:00");

Create an Activity

CreateActivity(id)

Descirption: Creates an activity in the project.

Return value: The activity id if successful.  -1 if the create fails.

$activity_id - Gantt::CreateActivity("new_activity");

The first parameter is the name to call the new activity.

Edit

RemoveAllActivities()

Remove all visible activities. Note: if no filter is active, this function will remove all activities in the project.

1 if it succeeds, 0 if it fails.

Gantt::ApplyFilter(“waste”); $result - Gantt::RemoveAllActivities();
RemoveActivity(id)

Remove a single activity reference by id.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemoveActivity(500);
RemoveActivities(idListReference)

Remove a list of activities referenced by a list of Id.

1 if it succeeds, 0 if it fails.

@ids - (27, 32, 36); $result - Gantt::RemoveActivities(\@ids);

Flow

This group of instructions creates a loop between the visible activities.

Rewind()

Go to the first visible activity.

Next()

Go to the next visible activity.

IsEof()

Return true if the activity is the last visible activity.

Return value: All the functions return the same value: 1 end of activities, 0 not end of activities.

Gantt::ApplyFilter("Back Stoping");
$result - Gantt::Rewind();
		
		for(my $count - 1; !Gantt::IsEof(); Gantt::Next(), $count++)
		{
		$value - Gantt::GetSingleAttributeValue("Duration");
		Printf(“activity $count duration - $value);
			Gantt::SetAttributeValue("Priority", "100");
		}

Information

GetActivitiesCount(total)

Get the activities count in the project.

total is defined as: 0 for only visible activities or 1 for all activities.

Return value:The number of activities all or visible.

$result - Gantt::GetActivitiesCount(1); #all activities.

Precedence

GetPredecessorList(actId)

Get a list of predecessors for the activity referenced by its Id.

Return value:A string with the list of precedence with the following format:

StartActivityId.BarId{TAB}EndActivityId.BarId{TAB}PrecedenceGroupName{ENTER}  
$result - Gantt::GetPredecessorList("14");
GetSuccessorList(actId)

Get a list of successors for the activity referenced by its Id.

Return value: A string with the list of precedence with the following format:

StartActivityId.BarId{TAB}EndActivityId.BarId{TAB}PrecedenceGroupName{ENTER}  
$result - Gantt::GetSuccessorList("14");

Note:  The result has the same format as GetPredecessorList

AddPrecedence(actStart, actEnd, type, lag)

Add a precedence between two activities.

The parameters are:

actStart

The start activity of the precedence, with the format actId.BarId

actEnd

The end activity of the precedence, with the format actId.BarId

type

The type of the precedence SS (start-start), SF (start-finish), FF (finish-finish) or FS (finish-start).

lag

The time lag for the precedence. The unit is defined in the Duration format of the Project setup.

1 if it succeeds, 0 if it fails.

result - Gantt::AddPrecedence("14.2", "25", "SS", 0);

This instruction will create a precedence between the activity 14 bar 2 to activity 25 (it has only one bar). The precedence is Start-Start with no lag.

RemovePrecedence()

Remove a precedence between two activities.

1 if it succeeds, 0 if it fails.

$result - Gantt::RemovePrecedence("14.2", "25");  

Selection

SelectActivity(id)

Select a visible activity by its Id. (see column Id in Gantt grid).

1 if it succeeds, 0 if it fails.

$result - Gantt::SelectActivity(3);
SelectActivities(idListReference)

Select multiple visible activities in Gantt by its Id.

1 if it succeeds, 0 if it fails.

@ids - (2, 20, 10); $result - Gantt::SelectActivities(\@ids );
bool ClearLevelingDelays(const bool& keepStartEnd)

Description: Clears the levelling delays.

Parameters:

keepStartEnd - Whether to keep the start & end dates.

Return value: true if it succeeds, false if it fails.

my $keepDates = 1; my $result = Gantt::ClearLevelingDelays($keepDates);
bool ClearLevelingDelaysSelection(const bool& keepStartEnd, const int_&list ids)

Description: Clears the levelling delays on the activities specified by "ids".

Parameters:

keepStartEnd - Whether to keep the start & end dates.

ids - The activities to select (ids).

Return value: true if it succeeds, false if it fails.

my $keepDates = 1; my @ids = (1, 2, 3, 4); my $result = Gantt::ClearLevelingDelaysSelection($keepDates, \@ids);
bool SetPauseUserInterface(const bool& pause)

Description: Pause or activate the VGS user interface. While paused the ribbon will be grayed out and the gantt chart replaced with button to re-enable the user interface.

Parameters:

pause - Whether to pause (true) or unpause (false).

Return value: true if it succeeds, false if it fails.

# Pause the UI

my $result = Gantt::SetPauseUserInterface(1);

# Do other actions without the UI updates slowing down the processing

# Re-enable the UI

$result = Gantt::SetPauseUserInterface(0);
bool SplitActivity(const int& id, const int& taskBarIndex, const double& proportion, const double& delay)

Description - Splits the activity bar specified by the id and taskBarIndex combination.

Parameters:

id - The id of the activity to split.

taskBarIndex - The 0-based index of the task bar to split.

proportion - The location of the split in the specified task bar.

delay - The delay, in days, applied to the new task bar and any subsequent bars for the activity.

Return value: true if it succeeds, false if it fails.

my $id = 1;my $barIndex = 0; my $proportion = 0.5; my $delay = 1; my $result = Gantt::SplitActivity($id, $barIndex, $proportion, $delay);
bool SplitCurrentActivity(const int& taskBarIndex, const double& proportion, const double& delay)

Description: Splits the activity bar specified by the current activity and taskBarIndex. The Current Activity can be set with the SelectActivity or SelectActivities methods. The Rewind and Next methods move the current activity through the selection from SelectActivities.

Parameters:

taskBarIndex - The 0-based index of the task bar to split.

proportion - The location of the split in the specified task bar.

delay - The delay, in days, applied to the new task bar and any subsequent bars for the activity.

Return value: true if it succeeds, false if it fails.

my $barIndex = 0; my $proportion = 0.5; my $delay = 1; my $result = Gantt::SplitCurrentActivity($barIndex, $proportion, $delay);
bool SplitActivities(const int_list& ids, const double& proportion, const double& delay)

Description: Splits the activities specified by ids.

Parameters:

ids - List of ids specifying activities to act upon.

proportion - The proportion to split at (proportion of Work for the activity being split).

delay - The delay, in days, applied to the new task bar and any subsequent bars for the activity.

Return value: true if it succeeds, false if it fails.

my @ids = (1, 2, 3, 4); my $proportion = 0.5; my $delay = 1;my $result = Gantt::SplitCurrentActivity(\@ids, $proportion, $delay);

Methods to add or modify resources

AddResource(name, calendarName)

Will add a resource.

name - name of resource

calendarName - name of calendar

AddResourceWithRateCapacity(name, calendarName, rate, capacity)

Will add a resource with rate and capacity.

name - name of resource

calendarName - name of calendar

rate - rate of the activity

capacity - capacity of resource

ResourceSetDefaultRate(resourceName, rate)

See note below

Will set the default rate of an activity.

resourceName - name of resource

rate - rate of the activity

ResourceSetDefaultRateAndMethod(resourceName, rate)

See note below

Will set the default rate and method of a resource.

resourceName - name of resource

rate - rate of the activity

ResourceSetDefaultCapacity(resourceName, capacity)

See note below

Will set the default capacity of a resource.

resourceName - name of resource

capacity - capacity of the resource

ResourceSetDefaultCapacityAndMethod(resourceName, capacity)

See note below

Will set the default capacity and method of a resource.

resourceName - name of resource

capacity - capacity of the resource

Note

In VGS, a Resource has a rate and a capacity. However, the rate and capacity can be defined in more than one way. For both rate and capacity there is a default value which is the simple case in which it is the only value used. The first method (ResourceSetDefault) will set this value but not change the Rate Method or Capacity Method. The second method (ResourceSetDefaultAndMethod) will set the value and change the Rate Method or Capacity Method to use the new value.

Rate Method

There are 3 ways the rate can be defined in a Resource,

Default - Single value for any activity using the resource

Expression Rate - An expression defines the rate. This can use VGS Attributes and/or Attributes from Vulcan.

Use Variable Rate - The rate is defined by Activity Type

Capacity Method

There are 2 ways the capacity can be defined in a Resource.

Default - Single value for any activity using the resource

Variable Capacity - The capacity is, effectively, defined for a date range.

ResourceSetRateExpression(resourceName, rateExpression)

Will set the rate expression for the resource.

resourceName - name of resource

rateExpression - expression specifying the formula calculating the rate of the resource

ResourceAddVariableRateItemActivityTypeRate(resourceName, activityTypeName)

Will set the variable rate for the selected activity type using the default rate defined in the activity type.

resourceName - name of resource

activityTypeName - name of the activity type

ResourceAddVariableRateItem(resourceName, activityTypeName, rate)

Will add a variable for the rate of the selected activity type and assign the rate.

resourceName - name of resource

activityTypeName - name of the activity type

rate - rate of the activity

ResourceRemoveVariableRateItem(resourceName, activityTypeName)

Will remove a variable for the rate of selected activity type.

resourceName - name of resource

activityTypeName - name of the activity type

ResourceAddVariableCapacityItem(resourceName, startDate, capacity)

Will add a variable to store the capacity of the resource, and assign the start date and capacity.

resourceName - name of resource

startDate - start date

capacity - capacity of the resource

ResourceRemoveVariableCapacityItem(resourceName, startDate)

Will remove the variable used to store the capacity of the resource.

resourceName - name of resource

startDate - start date

ResourceSetCalendar(name, calendarName)

Will set the calendar.

name - name of resource

calendarName - name of calendar

GetDateFormat()

Returns the date format.

Methods to modify resource allocations

AddResourceToActivity(resourceName, activityTypeName, activityName)

Will add a resource to an activity.

resourceName - name of resource

activityTypeName - name of the activity type

activityName - name of activity

Note:  Will work with an empty activityTypeName value if the activityName is unique within the project.

AddResourceToActivityById(resourceName, id)

Will add a resource to an activity using the ID.

resourceName - name of resource

id - ID of activity

RemoveResourceFromActivity(resourceName, activityTypeName, activityName)

Will remove a resource from an activity.

resourceName - name of resource

activityTypeName - name of the activity type

activityName - name of activity

Note:  Will work with an empty activityTypeName value if the activityName is unique within the project.

RemoveResourceFromActivityById(resourceName, id)

Will remove a resource from an activity using the ID.

resourceName - name of resource

id - ID of activity

AddResourceToActivities(resourceName)

Will add a resource to an activity.

resourceName - name of resource

Note:  Will add the resource to all displayed activities.

RemoveResourceFromActivities(resourceName)

Will remove a resource from an activity.

resourceName - name of resource

Note:  Will remove the resource from all displayed activities.

Related topics

Introduction

Running a Lava Script

Functions

Classes

Example

GPAN