View Full Version : autocadvba - place circle on the poinr of a polygon?

02-19-2006, 10:32 PM
my task is : select a polygon and then place circle with specified radius on all the points of a polygon autoimatically.

can anyone help..?? Thanks a lot!

03-18-2006, 11:28 AM
Hi clarence_cad,

Are you at Autodesk's VBA customazation dicussion group?

The below sub will take an active selection set and place circles at each vertex.

Sub CircleAtPlineVertex()
Dim mCrcle As AcadCircle, mTmp As AcadEntity, mN As Long, mX(2) As Double, mY(2) As Double
Dim mI As Long, mPline As Acad3DPolyline, mLWPline As AcadLWPolyline
For mI = ThisDrawing.ActiveSelectionSet.Count - 1 To 0 Step -1
If InStr(1, ThisDrawing.ActiveSelectionSet(mI).ObjectName, "3dPolyline") > 0 Then
Set mPline = ThisDrawing.ActiveSelectionSet.Item(mI)
For mN = 0 To UBound(mPline.Coordinates, 1) Step 3
mX(0) = mPline.Coordinates(mN)
mX(1) = mPline.Coordinates(mN + 1)
mX(2) = mPline.Coordinates(mN + 2)
Set mCrcle = ThisDrawing.ModelSpace.AddCircle(mX, 2)
ElseIf InStr(1, ThisDrawing.ActiveSelectionSet(mI).ObjectName, "Polyline") > 0 Then
Set mLWPline = ThisDrawing.ActiveSelectionSet.Item(mI)
For mN = 0 To UBound(mLWPline.Coordinates, 1) Step 2
mY(0) = mLWPline.Coordinates(mN)
mY(1) = mLWPline.Coordinates(mN + 1)
mY(2) = 0
Set mCrcle = ThisDrawing.ModelSpace.AddCircle(mY, 2)
End If
ThisDrawing.Regen acActiveViewport
Set mCrcle = Nothing
Set mLWPline = Nothing
Set mPline = Nothing
End Sub

03-28-2006, 11:11 AM
I don't understand how you control the radius or diameter of the circles?

03-28-2006, 11:23 AM
In the below statement mY is the array of points and 2 is the radius. On the 2 I could have used anything, it was just on my sample drawing 2 worked without overlapping.

Set mCrcle = ThisDrawing.ModelSpace.AddCircle(mY, 2)

03-28-2006, 11:28 AM
Thanks Tommy, I'm gonna add that comment to the code so when I come back later I'll know what we did to change the radius.