AutoCAD VBA 3D Extrude Example 6. (user form project)

Submitted by CAAadmin on Tue, 04/03/2018 - 10:03
autocad vba macro 3d extrusion

Use VBA USer form to create 3D extrsion in Autocad

Refer previous articles (to create userform project)

autocad 3d vba

VBA Code  (Reference : AutoCAD 2004 VBA: A Programmer's Reference, By Joe Sutphin)

Private Sub CommandButton1_Click()
Dim varCenter(0 To 2) As Double
Dim dblRadius As Double
Dim dblHeight As Double
Dim dblTaper As Double
Dim strInput As String
Dim varRegions As Variant
Dim objEnts() As AcadEntity
Dim objEnt As Acad3DSolid
Dim varItem As Variant
Dim rad As Integer
Dim height As Integer
On Error Resume Next
''values from text boxes
rad = TextBox1.Text
height = TextBox2.Text
'' define center point
varCenter(0) = 0: varCenter(1) = 0: varCenter(2) = 0
'' draw the entities
With ThisDrawing.ModelSpace
'' draw the outer region (circle)
ReDim objEnts(0)
Set objEnts(0) = .AddCircle(varCenter, rad) ' radius
'' create the region
varRegions = .AddRegion(objEnts)
'' extrude the solid
Set objEnt = .AddExtrudedSolid(varRegions(0), height, 0) '10 extrude height and 0 taper angle
'' update the extruded solid
End With

If Err Then MsgBox Err.Description
'' delete the temporary geometry
For Each varItem In objEnts
For Each varItem In varRegions
ThisDrawing.SendCommand "_shade" & vbCr
End Sub

Paste above code