Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Namespace SolidCreation
Public Class Commands
<CommandMethod("SAP")> _
Public Sub SweepAlongPath()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
' Ask the user to select a region to extrude
Dim peo1 As New PromptEntityOptions(vbLf & "Select profile or curve to sweep: ")
peo1.SetRejectMessage(vbLf & "Entity must be a region, curve or planar surface.")
peo1.AddAllowedClass(GetType(Region), False)
peo1.AddAllowedClass(GetType(Curve), False)
peo1.AddAllowedClass(GetType(PlaneSurface), False)
Dim per As PromptEntityResult = ed.GetEntity(peo1)
If per.Status <> PromptStatus.OK Then
Return
End If
Dim regId As ObjectId = per.ObjectId
' Ask the user to select an extrusion path
Dim peo2 As New PromptEntityOptions(vbLf & "Select path along which to sweep: ")
peo2.SetRejectMessage(vbLf & "Entity must be a curve.")
peo2.AddAllowedClass(GetType(Curve), False)
per = ed.GetEntity(peo2)
If per.Status <> PromptStatus.OK Then
Return
End If
Dim splId As ObjectId = per.ObjectId
Dim pko As New PromptKeywordOptions(vbLf & "Sweep a solid or a surface?")
pko.AllowNone = True
pko.Keywords.Add("SOlid")
pko.Keywords.Add("SUrface")
pko.Keywords.[Default] = "SOlid"
Dim pkr As PromptResult = ed.GetKeywords(pko)
Dim createSolid As Boolean = (pkr.StringResult = "SOlid")
If pkr.Status <> PromptStatus.OK Then
Return
End If
' Now let's create our swept surface
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
&n