OK, I cleaned up my code a bit.
Here is a function to draw temp vectors in the normal direction of a surface:
<CommandMethod("THICKEN3D", CommandFlags.Modal)> Public Shared Sub THICKEN3D()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim peo As New PromptEntityOptions(vbLf & "Select surface:")
peo.SetRejectMessage(vbLf & "Needs to be a SURFACE!")
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.Surface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.PlaneSurface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.ExtrudedSurface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.SweptSurface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.LoftedSurface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.RevolvedSurface), True)
peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.NurbSurface), True)
Dim per As PromptEntityResult = ed.GetEntity(peo)
If per.Status <> PromptStatus.OK Then Return
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim btr As BlockTableRecord = TryCast(trx.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim ent As Entity = TryCast(trx.GetObject(per.ObjectId, OpenMode.ForWrite), Entity)
Dim solPlate As New Solid3d With {
.RecordHistory = True
}
Dim Thickness As Double = Nothing
If TypeOf ent Is Autodesk.AutoCAD.DatabaseServices.Surface Then
Try
Dim srf As Autodesk.AutoCAD.DatabaseServices.Surface = TryCast(trx.GetObject(per.ObjectId, OpenMode.ForWrite), Autodesk.AutoCAD.DatabaseServices.Surface)
ExtrusionVectors(srf)
Thickness = SelDbl("Thickness: ")
If Thickness = Nothing Then Exit Sub
solPlate = srf.Thicken(Thickness, False)
btr.AppendEntity(solPlate)
trx.AddNewlyCreatedDBObject(solPlate, True)
Catch ModelingFailure As Autodesk.AutoCAD.Runtime.Exception When ModelingFailure.Message = "eGeneralModelingFailure"
ed.WriteMessage(vbLf & "Probably a self-intersecting surface...")
trx.Abort()
Return
End Try
End If
ent.Erase()
trx.Commit()
End Using
End Sub
Public Shared Sub ExtrusionVectors(srf As Autodesk.AutoCAD.DatabaseServices.Surface)
'https://through-the-interface.typepad.com/through_the_interface/2011/02/gathering-points-defining-3d-autocad-geometry-using-net.html
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim vec_size As Double = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWSIZE") / 10
Dim cross_size As Double = vec_size / 10
Dim nurbs As Autodesk.AutoCAD.DatabaseServices.NurbSurface() = srf.ConvertToNurbSurface
For Each nurb As Autodesk.AutoCAD.DatabaseServices.NurbSurface In nurbs
Dim ustart As Double = nurb.UKnots.StartParameter, uend As Double = nurb.UKnots.EndParameter, uinc As Double = 2 * (uend - ustart) / nurb.UKnots.Count, vstart As Double = nurb.VKnots.StartParameter, vend As Double = nurb.VKnots.EndParameter, vinc As Double = 2 * (vend - vstart) / nurb.VKnots.Count
Dim u As Double = ustart
While u <= uend
Dim v As Double = vstart
While v <= vend
Dim vec As Vector3d = nurb.GetNormal(u, v) * vec_size
If Not vec = Nothing Then
Dim pt2 As Point3d = nurb.Evaluate(u, v).TransformBy(Matrix3d.Displacement(vec))
ed.DrawVector(nurb.Evaluate(u, v), pt2, 6, True)
ed.DrawVector(New Point3d(pt2.X - cross_size, pt2.Y - cross_size, pt2.Z), New Point3d(pt2.X + cross_size, pt2.Y + cross_size, pt2.Z), 6, False)
ed.DrawVector(New Point3d(pt2.X - cross_size, pt2.Y + cross_size, pt2.Z), New Point3d(pt2.X + cross_size, pt2.Y - cross_size, pt2.Z), 6, False)
End If
v += vinc
End While
u += uinc
End While
Next
End Sub