Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim acEd As Editor = acDoc.Editor
Using acLockDoc As DocumentLock = acDoc.LockDocument()
Dim per As PromptEntityResult
Dim peo As PromptEntityOptions = New PromptEntityOptions(vbLf & "Select path: ")
peo.SetRejectMessage(vbLf & "Wrong Entity.")
peo.AddAllowedClass(GetType(Curve), False)
per = acEd.GetEntity(peo)
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Try
Dim pathEnt As Curve = TryCast(acTrans.GetObject(per.ObjectId, OpenMode.ForRead), Curve)
Dim acBlkTbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite)
Dim acBlkTblRec As BlockTableRecord = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim sweepEnt As Polyline = New Polyline()
sweepEnt.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
sweepEnt.AddVertexAt(1, New Point2d(0, 0.1), 0, 0, 0)
sweepEnt.AddVertexAt(2, New Point2d(0.1, 0.1), 0, 0, 0)
sweepEnt.AddVertexAt(3, New Point2d(0.1, 0), 0, 0, 0)
sweepEnt.AddVertexAt(4, New Point2d(0, 0), 0, 0, 0)
Dim ent3D As New Solid3d()
Dim sob As SweepOptionsBuilder = New SweepOptionsBuilder()
sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath
sob.BasePoint = pathEnt.StartPoint
sob.Bank = True
ent3D.CreateSweptSolid(sweepEnt, pathEnt, sob.ToSweepOptions())
acBlkTblRec.AppendEntity(ent3D)
acTrans.AddNewlyCreatedDBObject(ent3D, True)
acTrans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox("Error: " & ex
.Message & vbCrLf
& "Source: " & ex
.Source & vbCrLf
& "Status: " & ex
.ErrorStatus) End Try
End Using
End Using