Lava Scripting Support for VGS

Vulcan Gantt Scheduler

Use these functions to add or modify resources and add or remove resource allocations.


Error functions

HasError(void) → bool

Use to determine if the executed function returns an error.

1 if the last action has an error.

GetGanttLastError(void) → string

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 = "Gantt error: $error";
}

Flow functions

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() → bool

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

Select functions

SelectActivity(int id) → bool

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(const int_list& ids) → bool

Select multiple visible activities in Gantt by their id's.

1 if it succeeds, 0 if it fails.

@ids = (2, 20, 10); $result - Gantt::SelectActivities(\@ids );

Information functions

GetActivitiesCount(bool total) → int

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.

Activities functions

CreateActivity(const string& activityName) → long

Creates an activity in the project.

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

$activity_id = Gantt::CreateActivity("new_activity");
RemoveActivity(int id) → bool

Remove a single activity reference by id.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemoveActivity(500);
RemoveActivities(const int_list& ids) → bool

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);
RemoveAllActivities(void) → bool

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();
SplitActivity(const int& id, const int& taskBarIndex, const double& proportion, const double& delay) → bool

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);
SplitCurrentActivity(const int& taskBarIndex, const double& proportion, const double& delay) → bool

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);
SplitActivities(const int_list& ids, const double& proportion, const double& delay) → bool

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);
GetSingleAttributeValue(const string& attrName) → string

Get the value of attrName for the selected activity.

Return value: A string with the attribute value.

$result = Gantt::GetSingleAttributeValue("Duration");
GetAttributeValues(const list& attrNames) → list

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(const string& attrName, const string& value) → bool

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");
SetAttributeValue(const string& attrName, const double value) → bool
AddPrecedence(const string& start, const string& end, const string& type, double lag) → bool

Add a precedence between two activities.

Parameters:

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(const string& start, const string& end) → bool

Remove a precedence between two activities.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemovePrecedence("14.2", "25"); 
GetPredecessorList(int id) → list

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(int id) → list

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()

Project functions

Save(const string& filename) → bool

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");
GetActivityTypeNames(void) → list

Get the list of activity types available in the project.

Return value: An array with the activity type names.

@results = Gantt::GetActivityTypeNames();
GetAttributeNames(void) → list

Get the list of all attributes available in the project.

Return value:An array with the attribute names.

@results = Gantt::GetAttributeNames();
GetAttributeTypes(const list& attrNames) → list
GetCalendarNames(void) → list

Get a list of all calendars available in the project.

Return value: An array with the calendar names.

@results = Gantt::GetCalendarNames();
GetFilterNames(void) → list

Get a list of filters available in the project.

Return value: An array with the filter names.

@result = Gantt::GetFilterNames();
GetLookupTableNames(void) → list

Get a list of lookup tables available in the project.

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

@result = Gantt::GetLookupTableNames();
GetPeriodNames(void) → list

Get a list of period definitions available in the project.

Return value: A list with period definition names.

@result = Gantt::GetPeriodNames(); 
GetPrecedenceGroupNames(void) → list
GetReportNames(void) → list

Get a list of available reports in the project.

Return value: An array with the report definition names.

@result = Gantt::GetReportNames();
GetResourceNames(void) → list

Get a list of available resources in the project.

Return value: An array with the resource definition names.

@result = Gantt::GetResourceNames();
SetActivityType(const string& activityTypeName) → bool
ApplyCalendar(const string itemName) → bool

Set the global calendar for the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::ApplyCalendar("Default Calendar");
ApplyFilter(const string& filterName) → bool

Set the filter in the project as the current filter.

1 if it succeeds, 0 if it fails.

$result = Gantt::ApplyFilter("Ore");
ApplyPeriod(const string itemName) → bool

Set the current period definition in the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::ApplyPeriod("Forecast"); 
ApplyPrecedenceGroup(const string itemName) → bool
ApplyReport(const string reportName) → bool

Set the current summary report in the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::ApplyReport("Totals");
GetCurrentFilter(void) → string
ClearFilter(void) → bool

Clear the current filter

1 if it succeeds, 0 if it fails.

$result = Gantt::ClearFilter();
Note

You can get the same result if you use ApplyFilter with an empty name.

$result = Gantt::ApplyFilter("");
ClearPeriod(void) → bool

Clear the current period definition in the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::ClearPeriod();
ClearPrecedenceGroup(void) → bool

Clear the current precedence group definition.

1 if it succeeds, 0 if it fails.

$result = Gantt::ClearPrecedenceGroup () ;
ClearReport(void) → bool

Remove the current summary report in the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::ClearReport();
ClearLevelingDelays(const bool& keepStartEnd) → bool

Clears the levelling delays.

Parameter:

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);
ClearLevelingDelaysSelection(const bool& keepStartEnd, const int_list& ids) → bool

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);
RemoveCalendar(const string& name) → bool

Remove a calendar from the project.

Note:  Some calendars cannot be removed if they are used. For example the global calendar of the project, or a calendar currently being used by a resource.

1 if it succeeds, 0 if it fails.

$result = Gantt::ApplyCalendar("Maintenance"); 
RemoveFilter(const string& name) → bool

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

1 if it succeeds, 0 if it fails.

$result = Gantt::RemoveFilter("Ore");
RemoveLookupTable(const string& name) → bool

Remove a lookup table from the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemoveLookupTable("Translation");
RemovePeriod(const string& name) → bool

Remove a period definition from the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemovePeriod("Forecast");
RemoveReport(const string& name) → bool

Remove a report in the report collection from the project.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemoveReport("Totals");
RemoveResource(const string& name) → bool

Remove a resource from the project collection.

1 if it succeeds, 0 if it fails.

$result = Gantt::RemoveResource("Mucking");
AddFilter(const string& filterName, const string& filterString) → bool

Add a filter to the filter collection.

1 if it succeeds, 0 if it fails.

$result = Gantt::AddFilter("No Au", "[ATT:Au]- 0");
AddLookupTable(const string& name, const string& values) → bool

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",); 
AddPrecedenceGroup(const string& name, int lineStyle, int lineColor, bool isApplied) → bool

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

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.

linecolour - 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);
AddResource(const string& name, const string& calendarName) → bool

Will add a resource.

name - name of resource

calendarName - name of calendar

AddResourceWithRateCapacity(const string& name, const string calendarName, const double& rate, const int& capacity) → bool

name - name of resource

calendarName - name of calendar

rate - rate of the activity

capacity - capacity of resource

ResourceSetCalendar(const string& name, const string& calendarName) → bool

Will set the calendar.

name - name of resource

calendarName - name of calendar

ResourceSetDefaultRate(const string& resourceName, const double& rate) → bool

See note below

Will set the default rate of an activity.

resourceName - name of resource

rate - rate of the activity

ResourceSetDefaultRateAndMethod(const string& resourceName, const double& rate) → bool

See note below

Will set the default rate and method of a resource.

resourceName - name of resource

rate - rate of the activity

ResourceSetDefaultCapacity(const string& resourceName, const int& capacity) → bool

See note below

Will set the default capacity of a resource.

resourceName - name of resource

capacity - capacity of the resource

ResourceSetDefaultCapacityAndMethod(const string& resourceName, const int& capacity) → bool

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(const string& resourceName, const string& rateExpression) → bool
ResourceAddVariableRateItemActivityTypeRate(const string& resourceName, const string& activityTypeName) → bool

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

resourceName - name of resource

activityTypeName - name of the activity type

ResourceAddVariableRateItem(const string& resourceName, const string& activityTypeName, const double& rate) → bool

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(const string& resourceName, const string& activityTypeName) → bool

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

resourceName - name of resource

activityTypeName - name of the activity type

ResourceAddVariableCapacityItem(const string& resourceName, const string& startDate, const int& capacity) → bool

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(const string& resourceName, const string& startDate) → bool

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

resourceName - name of resource

startDate - start date

GetDateFormat(void) → string

Returns the date format.

GetLookupTableValues(const string& name) → string

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(const string& name, const string& values) → bool

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); 
ExportCurrentReport(const string& path) → bool
ExportActivitiesToCSV(const string& path, bool useActivityFilter) → bool
FindUAID(long id) → bool
GetUAID(void) → long
AddResourceToActivity(const string& resourceName, const string& activityTypeName, const string& activityName) → bool

Will add a resource to an activity.

resourceName - name of resource

activityTypeName - name of the activity type

activityName - name of activity

AddResourceToActivityById(const string& resourceName, const long& id) → bool

Will add a resource to an activity using the ID.

resourceName - name of resource

id - ID of activity

RemoveResourceFromActivity(const string& resourceName, const string& activityTypeName, const string& activityName) → bool

Will remove a resource from an activity.

resourceName - name of resource

activityTypeName - name of the activity type

activityName - name of activity

RemoveResourceFromActivityById(const string& resourceName, const long& id) → bool

Will remove a resource from an activity using the ID.

resourceName - name of resource

id - ID of activity

AddResourceToActivities(const string& resourceName) → bool

Will add a resource to an activity.

resourceName - name of resource

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

Note:  Will add the resource to all displayed activities.

RemoveResourceFromActivities(const string& resourceName) → bool

Will remove a resource from an activity.

resourceName - name of resource

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

Note:  Will remove the resource from all displayed activities.

GetProjectFilename(bool shortPath) → string
SetPauseUserInterface(const bool& pause) → bool

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);
VerifyReservesSetup() → bool
RequestReserves(const bool& allActivities) → void
ReservesResults() → string
GetReservesByActivityAtt(const string& activityType, const string& activityName, const string& attributeName) → list
ActivityAttDates(const string& activityType, const string& activityName, const string& attributeName) → list
SetupReserveAtt(const string& specFile, const string& blockModel, const bool& useResolution, const bool& accountForDoubleCounting) → bool
AddSpatialPrecedenceRule(const string& name, const string& group, const bool& clear, const double& minimumMinable, const bool& closest, const double& precedenceLag, const string& precedenceType) → bool
UpdateSpatialPrecedenceRule(const string& name, const string& group, const bool& clear, const double& minimumMinable, const bool& closest, const double& precedenceLag, const string& precedenceType) → bool
UpdateSpatialPrecedenceRule(const string& name, const bool& clear, const double& minimumMinable, const bool& closest, const double& precedenceLag, const string& precedenceType) → bool
UpdateSpatialPrecedenceRulePredecessor(const string& name, const string& filter, const string& activityType) → bool
UpdateSpatialPrecedenceRulePredecessorFilter(const string& name, const string& filter) → bool
UpdateSpatialPrecedenceRulePredecessorActivityType(const string& name, const string& activityType) → bool
UpdateSpatialPrecedenceRuleSuccessor(const string& name, const string& filter, const string& activityType) → bool
UpdateSpatialPrecedenceRuleSuccessorFilter(const string& name, const string& filter) → bool
UpdateSpatialPrecedenceRuleSuccessorActivityType(const string& name, const string& activityType) → bool
UpdateSpatialPrecedenceRuleDistanceLag(const string& name, const double& minimumMinable) → bool
UpdateSpatialPrecedenceRuleNoDistanceLag(const string& name) → bool
RunSpatialPrecedenceRules(const list& spatialPrecedenceRules, const string& logFile) → bool
RunSpatialPrecedenceRule(const string& spatialPrecedenceRule, const string& logFile) → bool
GetSpatialPrecedenceRulesResult() → string
AddSummaryReport(const string& name) → bool
SummaryReportSetResultType(const string& reportName, const bool& completed) → bool
SummaryReportSetDefaultResultType(const string& reportName) → bool
SummaryReportAddReportItem(const string& reportName, const string& name, const string& attName, const string& weightName) → bool
SummaryReportAddReportItemExpression(const string& reportName, const string& name, const string& expression) → bool
SummaryReportRemoveReportItem(const string& reportName, const string& name) → bool
SummaryReportUpdateReportItem(const string& reportName, const string& name, const string& attName, const string& weightName) → bool
SummaryReportUpdateReportItemExpression(const string& reportName, const string& name, const string& expression) → bool
SummaryReportSetRowResult(const bool& useAverage) → bool
SummaryReportClearRowResult(void) → bool
UpdateLevelingSetup(const string& startDate, const string& endDate, const bool& clearPrevious, const int& minimumSplitDays, const int& minimumSplitHours) → bool
RunLeveling(const string& logFile) → string
Close(const bool& save) → void