Add template drop to a corridor
public bool AddTemplateDrop(Corridor corridor)
{
//Make connection object of ConsensusConnectionEdit to make chnages to dgn
Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = corridor.Connection as
Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit;
if (null == con) return false;
//To save changes made here to dgn
con.StartTransientMode();
//Load template library and get active template
string templateName = "C:\\ProgramData\\Bentley\\OpenRoads Designer CE 10.11\\
Configuration\\Organization-Civil\\_Civil Default Standards - Imperial\\Template Library\\
OpenRoadsTemplatesImperial.itl";
Bentley.CifNET.GeometryModel.SDK.TemplateLibrary templateLibary =
Bentley.CifNET.GeometryModel.SDK.TemplateLibrary.Load(templateName);
if (null == templateLibary) return false;
Bentley.CifNET.GeometryModel.SDK.TemplateDefinition templateDefinition =
templateLibary.ActiveTemplate;
if (null == templateDefinition) return false;
//Create parameters using template for creating template drop
double startDistanceAlong = corridor.StartDistance;
double endDistanceAlong = corridor.EndDistance;
Bentley.CifNET.GeometryModel.SDK.TemplateDropParameters templateDropParams =
new Bentley.CifNET.GeometryModel.SDK.TemplateDropParameters
(templateDefinition, startDistanceAlong, endDistanceAlong); ;
templateDropParams.Interval = 5.0;
templateDropParams.MinStartTransition = 0.0;
templateDropParams.MinStopTransition = 0.0;
templateDropParams.Desription = "Sample Add template drop";
//Add new template drop to corridor
TemplateDrop newTemplateDrop = corridor.AddTemplateDrop(templateDropParams);
if (newTemplateDrop == null) return false;
//To save changes to dgn
con.PersistTransients();
return true;
}
Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit object is required for adding, updating, or removing any changes from current dgn. The con.StartTransientMode() and con.PersistTransients() are used to save the template drop changes to dgn file.
To add a template drop to a corridor, it needs the parameters such as template, the begin station, end station, drop interval, minimum transition before drop and minimum transition after drop.
The drop interval specifies where the template is processed. For the values minimum transition before drop and minimum transition after drop are non-zero, then a transition drop is created at the beginning/end of the template drop with a length greater than or equal to the value given. The actual length is determined by how far it is between the new drop and the drop before/after the new drop. If there is not enough space to meet the minimum, then the previous/next drop is shortened to accommodate the transition. If there is no previous/next drop, then no transition drop is created.
For example, this is a template library path, for library OpenRoadsTemplatesImperial.itl which contains various template definitions.
C:\\ProgramData\\Bentley\\OpenRoads Designer CE 10.11\\Configuration\\Organization-Civil\\_Civil Default Standards - Imperial\\Template Library\\OpenRoadsTemplatesImperial.itl
The template definition includes points and components. The below image shows the sample template named as "4 lanes Crown Pivot" from a ".itl" file. There can be number of points and number of components under template.