surface Offset on the sections sample lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code works if the surface is of the CorridorSurface type, if a TinSurface is selected, an error occurs, what is wrong in the code?
Private Function ObterLargurasSecoes(alinID As ObjectId, sufID As ObjectId, estaca As Double, larguraMax As Double, ByRef LE As Double, ByRef LD As Double) As Boolean
' Documents
Dim acadDoc As Document = acApp.DocumentManager.MdiActiveDocument
Dim civilDoc As CivilDocument = CivilApplication.ActiveDocument
Dim ed As Editor = acadDoc.Editor
Using tr2 As Transaction = acadDoc.TransactionManager.StartTransaction
' Get the alignment
Dim alin As Alignment = tr2.GetObject(alinID, OpenMode.ForRead)
' Create a group of points with the external vertices of the sample line
Dim grupoDePontos2D As New Point2dCollection()
' Define the coordinates for the left side
Dim esteLE As Double = Nothing
Dim norteLE As Double = Nothing
alin.PointLocation(estaca, -larguraMax, esteLE, norteLE)
Dim pontoLE As New Point2d(esteLE, norteLE)
grupoDePontos2D.Add(pontoLE)
' Define the coordinates for the right side
Dim esteLD As Double = Nothing
Dim norteLD As Double = Nothing
alin.PointLocation(estaca, larguraMax, esteLD, norteLD)
Dim pontoLD As New Point2d(esteLD, norteLD)
grupoDePontos2D.Add(pontoLD)
' Create a temporary sample line group
Dim slGrupID As ObjectId = SampleLineGroup.Create("AlX_x-x_GrLixo " & alin.Name, alinID)
Dim slGrup As SampleLineGroup = tr2.GetObject(slGrupID, OpenMode.ForWrite)
' Create a sample line
Dim SlID As ObjectId = SampleLine.Create("AlX_x-x_slLixo", slGrupID, grupoDePontos2D)
' Get the section sources available for the SampleLineGroup and choose the surface
Dim sectionSources As SectionSourceCollection = slGrup.GetSectionSources()
For Each sectionSource As SectionSource In sectionSources
If sectionSource.SourceId = sufID Then
sectionSource.IsSampled = True
Exit For
End If
Next
' Get the sample line
Dim sl As SampleLine = tr2.GetObject(SlID, OpenMode.ForRead)
' Get the collection of sections in the sample line; there will be only one
Dim slIDs As ObjectIdCollection = sl.GetSectionIds()
' Get the section
Dim secao As Autodesk.Civil.DatabaseServices.Section = tr2.GetObject(slIDs(0), OpenMode.ForWrite)
Try
LE = secao.LeftOffset
Catch
LE = Nothing
End Try
Try
LD = secao.RightOffset
Catch
LD = Nothing
End Try
' Do not commit to avoid creating the auxiliary sample line
End Using
' Return false if no values are found
If LD = Nothing And LE = Nothing Then
Return False
Else
Return True
End If
End Function
Link copied