- Private Function GetNewCurves(ByRef myDocuments As AcadDocumentManagerExample,
- ByRef slabRegion As AcadRegion, ByRef updatedSpanLine As Line, ByVal localSpanVector As String, ByRef entForExtension As AcadEntity,
- ByRef jaggedLine As Line, ByVal slabAreaPLine As AcadLWPolyline, ByVal bStretch As Boolean, ByVal PointToTrim As Point3d, ByRef bIsSlabUpdated As Boolean) As DBObjectCollection
- Dim SpanStartX, SpanStartY, SpanEndX, SpanEndY As Double
- Dim ptPrev As Point3d = Point3d.Origin
- Dim ptVertLinePt As Point3d = Point3d.Origin
- Dim curves As DBObjectCollection = New DBObjectCollection()
- Dim Ent As AcadEntity
- Dim lstUpdatedLines As List(Of String) = New List(Of String)
- Try
- 'Get Span coords from Block attributes
- Dim args() As String = localSpanVector.Split(",")
- If args.Length = 4 Then
- SpanStartX = (Val(args(0)) * FImperialScaleFactor)
- SpanStartY = (Val(args(1)) * FImperialScaleFactor)
- SpanEndX = (Val(args(2)) * FImperialScaleFactor)
- SpanEndY = (Val(args(3)) * FImperialScaleFactor)
- End If
- 'Get exploded lines of the region
- If Not slabRegion Is Nothing Then
- 'Get Vertical Lines
- Dim lstVerticalLines As List(Of Line) = GetVerticalLines(slabRegion, SpanStartX, SpanStartY, SpanEndX, SpanEndY, myDocuments)
- 'Explode the region to extend its lines
- Dim unOrderexplodedKr As Object = slabRegion.Explode
- Dim explodedKr As Object = orderexpl(unOrderexplodedKr, myDocuments)
- For ixs As Integer = 0 To UBound(explodedKr)
- If Not ((TypeOf (explodedKr(ixs)) Is AcadRegion) Or (TypeOf (explodedKr(ixs)) Is AcadPoint)) Then
- If TypeOf (explodedKr(ixs)) Is AcadLine Then
- 'Get the points of the line
- Dim line As AcadLine = explodedKr(ixs)
- Dim ptStart As Point3d = New Point3d(line.StartPoint(0), line.StartPoint(1), 0)
- Dim ptEnd As Point3d = New Point3d(line.EndPoint(0), line.EndPoint(1), 0)
- 'Dont extend vertical lines. Just add it in curves array.
- Dim bIsVertical As Boolean = CheckForVerticalLine(line, lstVerticalLines)
- If bIsVertical Then
- If Not lstUpdatedLines.Contains(line.Handle) Then
- curves.Add(New Line(ptStart, ptEnd))
- End If
- Continue For
- End If
- 'Check if the line is a Span
- Dim orgSpanLine As Line2d = New Line2d(New Point2d(SpanStartX, SpanStartY),
- New Point2d(SpanEndX, SpanEndY))
- Dim bSpan As Boolean = False
- If orgSpanLine.GetDistanceTo(New Point2d(ptStart.X, ptStart.Y)) 0 Then
- Dim ptExtendedPt As Point3d = New Point3d(Math.Round(obj(0)), Math.Round(obj(1)), obj(2))
- 'Check if point is on Slab outline and it is a stretch command then dont allow to stretch
- 'OR if point outside Slab outline and it is trim command then dont allow to trim
- Dim res As PointContainment = getPointContainment(slabAreaPLine, ptExtendedPt)
- 'There was issue in trim in a rare scenario, where the intersection point is lying on the slab but result is giving it outsie
- If res = PointContainment.Outside Then
- If bStretch = False Then
- Dim tol As Double = 0.4
- ptExtendedPt = New Point3d(obj(0), obj(1), 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0), obj(1) + tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0), obj(1) - tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) + tol, obj(1), 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) - tol, obj(1), 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) + tol, obj(1) + tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) + tol, obj(1) - tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) - tol, obj(1) + tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- If res = PointContainment.Outside Then
- ptExtendedPt = New Point3d(obj(0) - tol, obj(1) - tol, 0)
- res = getPointContainment(slabAreaPLine, ptExtendedPt)
- End If
- End If
- End If
- If res = PointContainment.Inside Then ' res = PointContainment.OnBoundary Or
- If bStretch = True Then
- GoTo donteditedge
- End If
- ElseIf res = PointContainment.Outside Then
- If bStretch = False Then
- GoTo donteditedge
- End If
- End If
- Dim ptTmp As Point3d = New Point3d(0, 0, 0)
- If (bStretch And ptStart.DistanceTo(ptExtendedPt) > ptEnd.DistanceTo(ptExtendedPt)) _
- Or (bStretch = False And (ptStart.DistanceTo(PointToTrim) > ptEnd.DistanceTo(PointToTrim))) Then
- 'If end point is extended, the take edge from start to extended point
- curves.Add(New Line(ptStart, ptExtendedPt))
- 'Update the next curve and it is curves array
- Dim nextline As AcadLine
- If ixs = UBound(explodedKr) Then
- nextline = explodedKr(0)
- Else
- nextline = explodedKr(ixs + 1)
- End If
- Dim ptNextEndpt As Point3d = New Point3d(nextline.EndPoint(0), nextline.EndPoint(1), 0)
- curves.Add(New Line(ptExtendedPt, ptNextEndpt))
- lstUpdatedLines.Add(nextline.Handle)
- ptTmp = ptNextEndpt
- 'Update Span vector
- If bSpan = True Then
- updatedSpanLine = New Line(ptStart, ptExtendedPt)