Breaking Drawing View - Very Strange Behavior

Breaking Drawing View - Very Strange Behavior

aelqabbany
Advocate Advocate
514 Views
2 Replies
Message 1 of 3

Breaking Drawing View - Very Strange Behavior

aelqabbany
Advocate
Advocate

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:

  1. It seems that the script avoids hidden holes correctly, but ignores visible holes.
  2. The script seemingly hides some hidden lines correctly, but ignores others.

Starting Position

Break View 1.png

 Why does it only hide some of the long horizontal hidden lines?

Break View 2.png

 Good first break

Break View 3.png

 Good second break

Break View 4.png

Why did the break override the holes here?

Break View 5.png

 Final break

Break View 6.png

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

 

0 Likes
Accepted solutions (1)
515 Views
2 Replies
Replies (2)
Message 2 of 3

aelqabbany
Advocate
Advocate

It seems that for some Line Drawing curves, the first segment can be visible whereas the second segment can be hidden, which is why the prior code was skipping over them.

 

This code has resolved the issue:

 

For Each oC As DrawingCurve In oCurves
Try
If oC.CurveType = CurveTypeEnum.kLineSegmentCurve And EqualWithinTolerance(oC.EndPoint.Y, oC.StartPoint.Y, 0.01) And Abs(oC.StartPoint.X - oC.EndPoint.X) > 10 Then
		For Each oLineSegment As DrawingCurveSegment In oC.Segments
			If oLineSegment.HiddenLine = True Then
				oLineSegment.Visible = False
			End If
		Next
	End If
Catch
End Try
Next

 

0 Likes
Message 3 of 3

aelqabbany
Advocate
Advocate
Accepted solution

Apparently, the circles that were being overridden were not circles after all, but curves of the type kCircularArcCurve and kEllipticalArcCurve, which don't have a midpoint.

 

This has resolved the other issue:

 

	For Each oC As DrawingCurve In oCurves
		Try
			X_Values = X_Values.Concat({oC.Segments(1).StartPoint.X}).ToArray
		Catch
		End Try
		Try
			X_Values = X_Values.Concat({oC.Segments(1).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

 

 

0 Likes