I would like to expand on using Visual Basic for AutoCAD so I am going to get something rolling.
First if you are new to this like I am you will have to go to the menu to find it seen here:
Now I like scripts that use input forms called “dialog boxes” but not all scripts or macros will require it
but to make one once in the VBA editor all you do is insert a new user form.
The “command buttons” and the “input text box” will have to be created in this form by you and each be named;
these names will have to be in the code, once the user form is created double click the “command button”
and a "code" module will automatically pop up. Here is some basic code that creates a circle
no need for a user form to run this example:
'VBA code starts here:
Option Explicit
Sub Example_AddCircle()
' This example creates a circle in model space
Dim circleObj As AcadCircle
Dim centerPoint(0 To 2) As Double
Dim radius As Double
' Define the circle
centerPoint(0) = 15#: centerPoint(1) = 15#: centerPoint(2) = 0#
radius = 5#
' Create the Circle object in model space
Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
ZoomAll
End Sub
'VBA code ends here
Here is the buttons to run this code once the VBA editor is activated and a new module is opened up,
then cut and pate the above code in and use this button, have fun!
Home