Here's a JavaScript for you that does
exactly what you want. I have tested it.
As configured, it assumes you have created the first 'route' with the name Line0.
You configure things at the start - such as the number of lines and their spacing.
See the plugin User Manual to understand the OCPN interfacing.
You can modify as required - enjoy!
Code:
name = "Line"
number = 3; // number of parallel lines to add
space = 1; // line spacing in nm
// find base line
baseName = name + "0";
routeGUIDs = OCPNgetRouteGUIDs();
found = false;
for (i = 0; i < routeGUIDs.length; i++){
route = OCPNgetRoute(routeGUIDs[i]);
if (route.name == baseName) {
found = true;
break;
}
}
if (!found) throw("Cannot find base line ", baseName);
if (route.waypoints.length != 2) throw("Route " + route.name + " does not comprise just two waypoints");
// calculate the vector to move each waypoint
linebearing = OCPNgetVectorPP(route.waypoints[0].position, route.waypoints[1].position);
vector = {bearing: (linebearing.bearing+90)%360, distance: space};
// create extra lines
for (i = 1; i <= number; i++){
route.name = name + i;
start = route.waypoints[0].position;
end = route.waypoints[1].position;
route.waypoints[0].position = OCPNgetPositionPV(start, vector);
route.waypoints[1].position = OCPNgetPositionPV(end, vector);
delete route.waypoints[0].GUID; //need to delete this so new waypoint created
delete route.waypoints[1].GUID;
OCPNaddRoute(route);
}