Consulting

Results 1 to 5 of 5

Thread: autocadvba - place circle on the poinr of a polygon?

  1. #1

    autocadvba - place circle on the poinr of a polygon?

    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!

  2. #2
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,168
    Location
    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.

    [VBA]
    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)
    Next
    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)
    Next
    End If
    Next
    ThisDrawing.Regen acActiveViewport
    Set mCrcle = Nothing
    Set mLWPline = Nothing
    Set mPline = Nothing
    End Sub

    [/VBA]

  3. #3
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I don't understand how you control the radius or diameter of the circles?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,168
    Location
    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.

    [VBA]

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

    [/VBA]

  5. #5
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •