Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have cobbled together a script that will take a large drawing view and break it in multiple places without hiding any important features (including hidden holes or hidden line ends).
The two issues I have are:
- It seems that the script avoids hidden holes correctly, but ignores visible holes.
- The script seemingly hides some hidden lines correctly, but ignores others.
Starting Position
Why does it only hide some of the long horizontal hidden lines?
Good first break
Good second break
Why did the break override the holes here?
Final break
The breaks managed to avoid the hidden holes in the middle part, but overran the holes on the right.
Any suggestions? I have attached my sample part.
Sub Main()
CreateBreakoperationInDrawingView()
End Sub
Public Sub CreateBreakoperationInDrawingView()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oDrawingView As DrawingView
oDrawingView = oDrawDoc.SelectSet.Item(1)
Dim NumOfBreaks = 0
Dim oCurves As DrawingCurvesEnumerator = oDrawingView.DrawingCurves
For Each oC As DrawingCurve In oCurves
If oC.CurveType = CurveTypeEnum.kLineSegmentCurve Then
Try
If EqualWithinTolerance(oC.EndPoint.Y , oC.StartPoint.Y, 0.01) And oC.Segments(1).HiddenLine = True And Abs(oC.StartPoint.X-oC.EndPoint.X) > 10 Then
oC.Segments(1).Visible = False
oC.Segments(2).Visible = False
oC.Segments(3).Visible = False
End If
Catch
End Try
End If
Next
While NumOfBreaks < 5 And oDrawingView.Width > 40
MessageBox.Show("Message", "Title")
Dim oCenter As Double
oCenter = oDrawingView.Center.Y
Dim X_Values = New Double() {}
For Each oC As DrawingCurve In oCurves
Try
X_Values = X_Values.Concat({oC.StartPoint.X}).ToArray
Catch
End Try
Try
X_Values = X_Values.Concat({oC.EndPoint.X}).ToArray
Catch
End Try
Try
If oC.CurveType <> CurveTypeEnum.kLineSegmentCurve Then
X_Values = X_Values.Concat({oC.MidPoint.X }).ToArray
End If
Catch
End Try
Next
Array.Sort(X_Values)
Dim Max_Gap As Double = 0
Dim Break_End As Point2d
Dim Break_Start As Point2d
For i = 0 To (X_Values.Length - 2)
If (X_Values(i + 1) - X_Values(i)) > Max_Gap Then
Max_Gap = X_Values(i + 1) -X_Values(i)
Break_End = ThisApplication.TransientGeometry.CreatePoint2d(X_Values(i + 1) -1,oCenter)
Break_Start = ThisApplication.TransientGeometry.CreatePoint2d(X_Values(i) +1, oCenter)
End If
Next
Dim oBreakOperation As BreakOperation
oBreakOperation = oDrawingView.BreakOperations.Add(kHorizontalBreakOrientation, Break_Start, Break_End, kStructuralBreakStyle, 5)
NumOfBreaks += 1
End While
oDrawingView.Position = ThisApplication.TransientGeometry.CreatePoint2d(20, 22.5)
End Sub
Solved! Go to Solution.