There is the break distance that you specify and then some constant. You need to get the new view width but also take into account that you need to use the distance from the start of the view.
I was using the following code but the code was not necessary anymore so I also stopped at some point.
It might require some tweaking of the +/- defaultGap etc (and its c#), but below might help. I was creating multiple horizontal breaks in a long view. The BreakInfo class has the startCoord and the breakLength in 'mm'. The startcoord is the distance from the minimum x to the start of the break.
public static void CreateBreakOperation(DrawingView v) // List<BreakInfo> breaks,
{
var dwg = (DrawingDocument)Inv.Application.ActiveDocument;
var sht = dwg.ActiveSheet;
var tg = Inv.Application.TransientGeometry;
foreach (BreakOperation breakOp in v.BreakOperations)
{
breakOp.Delete();
}
// define the breakoperations
var breakInfos = new List<BreakInfo>()
{
new BreakInfo(100.0,100.0),
new BreakInfo(300.0,100.0),
new BreakInfo(600.0,200.0),
};
// break the view at specified locations
var previousGaps = 0.0;
var i = 1;
foreach (var breakInfo in breakInfos)
{
Logger.Info($"Width before break {i} = {v.Width * 10} mm");
// calculate new left x coord of view
var leftPoint = v.Center.X - v.Width / 2;
Logger.Info($"Left point X: {leftPoint}");
// calculate new starting coord taking into account previous breaks
double newStartCoord = breakInfo.StartCoord - previousGaps;
double scaled = (newStartCoord * v.Scale);
Logger.Info($"previous gaps: {previousGaps}");
Logger.Info($"new start coord: {newStartCoord}");
Logger.Info($"new start coord scaled: {scaled}");
// determine start/endpoint factoring in the scale
// gap should not be scaled
var startPoint = tg.CreatePoint2d(leftPoint + scaled, v.Center.Y);
var endPoint = tg.CreatePoint2d(leftPoint + scaled + (breakInfo.BreakLength * v.Scale) + (breakInfo.DefaultGap) / 2 , v.Center.Y);
Logger.Info($"break info: startpoint = {breakInfo.StartCoord}, length {breakInfo.BreakLength}");
var mSpaceStartPoint = tg.CreatePoint(0, 0, breakInfo.StartCoord);
var vSpaceStartPoint = v.ModelToSheetSpace(mSpaceStartPoint);
// calculate new starting coord taking into account previous breaks
var actualStartPoint = tg.CreatePoint2d(vSpaceStartPoint.X, v.Center.Y);
var actualEndPoint = tg.CreatePoint2d(vSpaceStartPoint.X + (breakInfo.BreakLength * v.Scale), v.Center.Y);
Logger.Info($"actual startpoint: x = {actualStartPoint.X}, y = {actualStartPoint.Y}");
Logger.Info($"actual endpoint: x = {actualEndPoint.X}, y = {actualEndPoint.Y}");
Logger.Info($"adjusted startpoint: x = {startPoint.X}, y = {startPoint.Y}");
Logger.Info($"adjusted endpoint: x = {endPoint.X}, y = {endPoint.Y}");
// add the break operation with default values
v.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation,
startPoint,
endPoint,
BreakStyleEnum.kStructuralBreakStyle);
Logger.Info($" ======= ");
// add this gap to previous gaps to start the next break at the right position
previousGaps += breakInfo.BreakLength;
i++;
}
}
}
public class BreakInfo
{
public double DefaultGap = .6;
public double StartCoord;
public double BreakLength;
public BreakInfo(double startCoord, double breakLength)
{
StartCoord = startCoord;
BreakLength = breakLength;
}
}