16
Moderator
#1

autocad extrusion command with VBA

code under download section
   


Reply


0
Junior Member
#2
Hi,

I'm very new to AutoCAD VBA programming. I have made some code to draw a flat polyline using coordinates, now i want to extrude it by a text box value.

I was looking for the download section to see how this works but cant seem to see it at all... any help would be massively appreciated.

Iain
Reply


16
Moderator
#3
(07-08-2021, 04:20 PM)ennayess Wrote: Hi,

I'm very new to AutoCAD VBA programming. I have made some code to draw a flat polyline using coordinates, now i want to extrude it by a text box value.

I was looking for the download section to see how this works but cant seem to see it at all... any help would be massively appreciated.

Iain

Hi Iain

please set up the form according to video, and use below code

VBA Code
Private Sub CommandButton1_Click()
Me.Hide
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
objEnt.Update
End With


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



Forum Jump:


Users browsing this thread:
2 Guest(s)