Community
Hello everyone!
I need to create a widening from the API, I have the following code.
<CommandMethod("LaneWidening")> Public Sub LaneWidening() Dim optSelect As New PromptEntityOptions(vbCrLf + "Select Offset Alignment") optSelect.SetRejectMessage(vbCrLf + "Must be an OffsetAlignment.") optSelect.AddAllowedClass(GetType(Alignment), True) Dim res As PromptEntityResult = ed.GetEntity(optSelect) If res.Status = PromptStatus.OK Then Using trans As Transaction = db.TransactionManager.StartTransaction alignment = trans.GetObject(res.ObjectId, OpenMode.ForWrite)
Dim rc As AlignmentRegionCollection Dim ra As AlignmentRegion Dim trc As AlignmentTransitionCollection Dim tent As AlignmentTransition Dim tsal As AlignmentTransition Dim stain As Double Dim staen As Double Dim station As Double
stain = 100 staen = 200 station = (stain + staen) / 2
alignment.OffsetAlignmentInfo.AddWidening(stain, staen, 5)
rc = alignment.OffsetAlignmentInfo.Regions trc = alignment.OffsetAlignmentInfo.Transitions For Each ra In rc If station > ra.StartStation And station < ra.EndStation Then tent = ra.EntryTransition tsal = ra.ExitTransition tent.TransitionType = Autodesk.Civil.TransitionType.Linear tsal.TransitionType = Autodesk.Civil.TransitionType.Linear tent.TransitionDescription.Length = 5 tent.TransitionDescription.StartStation = 100 tsal.TransitionDescription.Length = 5 Exit For
End If
Next trans.Commit() End Using
End If End Sub End Class
But I need to change the type of transition (linear, curve-line-curve, curve-curve-reverse curve, curve-reversecurve) and parameters depending on the type of transition, see figure below.
Is this possible? Someone can help me with an example.
Thank you very much.
Best regards,
Mauro Vega
AutoCAD Civil 3D 2018.2
Intel Core i7-6700HQ CPU 2.6 GHZ
32 GB RAM 2133 MHz
NVIDIA Quadro M3000M
Windows 10 Pro 64 Bits
Solved! Go to Solution.
Hello everyone,
I solve it in the following way.
<CommandMethod("LaneWidening")> Public Sub LaneWidening() Dim optSelect As New PromptEntityOptions(vbCrLf + "Select Offset Alignment") optSelect.SetRejectMessage(vbCrLf + "Must be an OffsetAlignment.") optSelect.AddAllowedClass(GetType(Alignment), True) Dim res As PromptEntityResult = ed.GetEntity(optSelect) If res.Status = PromptStatus.OK Then Using trans As Transaction = db.TransactionManager.StartTransaction alignment = trans.GetObject(res.ObjectId, OpenMode.ForWrite) Dim rc As AlignmentRegionCollection Dim ra As AlignmentRegion Dim trc As AlignmentTransitionCollection Dim tent As AlignmentTransition Dim tsal As AlignmentTransition Dim stain As Double Dim staen As Double Dim station As Double
Dim lita As LinearTransitionDescription
Dim lclt As LinearTransitionDescription stain = 100 staen = 200 station = (stain + staen) / 2 rc = alignment.OffsetAlignmentInfo.Regions trc = alignment.OffsetAlignmentInfo.Transitions For Each ra In rc If station > ra.StartStation And station < ra.EndStation Then tent = ra.EntryTransition tsal = ra.ExitTransition tent.TransitionType = Autodesk.Civil.TransitionType.Linear tsal.TransitionType = Autodesk.Civil.TransitionType.Linear lita = tent.TransitionDescription
lita.StartStation = stain
lita.Length = 5
lita.StartStation = stain
lclt = tsal.TransitionDescription
lclt.EndStation = staen + 5
lclt.Length = 5 Exit For End If Next trans.Commit() End Using End If End Sub End Class
Regards!
Can't find what you're looking for? Ask the community or share your knowledge.