Generic Layout
For the Generic Layout functionality, the three generic layout commands are accessible from the Toolbox.GenericLayout
class:
bool Toolbox.GenericLayout.UpdateSiteLayout(
SiteLayout siteLayoutToUpdate,
GenericLayoutSettings genericLayoutSettings);
bool Toolbox.GenericLayout.CreateNewSiteLayoutFromEmpty(
GenericLayoutSettings genericLayoutSettings,
TransformerSpecification transformerSpecification,
string newSiteLayoutName);
bool Toolbox.GenericLayout.CreateNewSiteLayoutFromExisting(
SiteLayout templateSiteLayout,
GenericLayoutSettings genericLayoutSettings,
string newSiteLayoutName);
All 3 functions need a GenericLayoutSettings
object to be defined. This largely replicates the visible functionality in the UI.
An example script for setting up a GenericLayoutSettings
object and using it:
// First, create a new GenericLayoutSettings object
GenericLayoutSettings genericLayoutSettings = new GenericLayoutSettings();
// Then create a GenericLayoutFillOption and add to the settings
GenericLayoutFillOption fillOption = new GenericLayoutFillOption();
// Populate the fill option:
// Set the fill options type to use individual components
fillOption.FillOptionsType = FillOptionsType.UseIndividualComponents;
// Set the component options
FillOptionComponentOptions componentOptions =
fillOption.IndividualComponentsOptions.ComponentOptions;
componentOptions.InverterSpecification =
Workbook.ComponentLibrary.InverterSpecifications.First();
componentOptions.ModuleSpecification = Workbook.ComponentLibrary.ModuleSpecifications.First();
componentOptions.UseDefaultStringSize = true;
componentOptions.DcAcRatio = 1.2;
componentOptions.StringPattern = StringPatternType.Straight;
// Set the layout choice type
fillOption.IndividualComponentsOptions.LayoutChoiceType = LayoutChoiceType.FixedTiltRacks;
// Set the rack layout options
FillOptionRackLayoutOptions rackLayoutOptions =
fillOption.IndividualComponentsOptions.RackLayoutOptions;
rackLayoutOptions.RackSystemSpecification =
Workbook.ComponentLibrary.RackSystemSpecifications.First();
rackLayoutOptions.Azimuth = 180.0;
rackLayoutOptions.Tilt = 35.0;
rackLayoutOptions.Pitch = 7;
rackLayoutOptions.FillOptionsSpacingType = FillOptionsSpacingType.Pitch;
// Now add this fill option to the settings
genericLayoutSettings.FillOptions.Add(fillOption);
// Set up the area limitation
// Make sure you use one of the fill options already in the settings
// object - not a new orphan fill option
genericLayoutSettings.AreaLimitation.LimitToAllLayoutRegionsFillOption =
genericLayoutSettings.FillOptions.First();
genericLayoutSettings.AreaLimitation.AreaLimitationType =
AreaLimitationType.LimitByAllExistingLayoutRegions;
// Set up the electrical limitation
genericLayoutSettings.ElectricalLimitation.ElectricalLimitationType =
ElectricalLimitationType.MaxAcCapacity;
genericLayoutSettings.ElectricalLimitation.MaxAcCapacityInMw = 4.2;
// Choose a site layout to update
SiteLayout siteLayoutToUpdate = Workbook.Domain.SiteLayouts.FirstOrDefault(
s => s.Name == "Site Layout 1");
// Call the generic layout function to update the site layout with the settings
Toolbox.GenericLayout.UpdateSiteLayout(siteLayoutToUpdate, genericLayoutSettings);