For loop stops at step 200

For loop stops at step 200

erhan.lale
Contributor Contributor
739 Views
3 Replies
Message 1 of 4

For loop stops at step 200

erhan.lale
Contributor
Contributor

I have really simple document. There is only 1116 circles on one layer.

I want to transfer radius of each circle and wrote really simple VBA code:

 

Sub radiusOfCircles()
    Dim ent As AcadEntity
    For Each ent In ThisDrawing.ModelSpace
      If TypeOf ent Is AcadCircle Then
        Debug.Print ent.Radius
      End If
    Next
End Sub

 I wanted do copy from debug window. If I run it, I get only 199 objects. I have no idea why.

0 Likes
Accepted solutions (2)
740 Views
3 Replies
Replies (3)
Message 2 of 4

fkellogg
Advocate
Advocate
Accepted solution

Can you not simply do a Data Extraction?

fkellogg_0-1701363766781.png

 

Message 3 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

It's a limitation of the IDE. Acad also has this limitation. The command line (F2) history can only store 400 lines. Write the data to Excel instead.

Sub radiusOfCircles()

    Dim xl As Excel.Application
    Dim wb As Excel.Workbook
    Dim sht As Excel.Worksheet
    Set xl = GetXL()
    Set wb = xl.Workbooks.Add
    Set sht = wb.Worksheets(1)
    sht.Name = "circles"
    Dim i As Integer
    
    sht.Cells(1, "A").Value = "Handle"
    sht.Cells(1, "B").Value = "Radius"
    i = 2
    
    Dim ent As AcadEntity
    For Each ent In ThisDrawing.ModelSpace
      If TypeOf ent Is AcadCircle Then
        sht.Cells(i, "A").Value = ent.Handle
        sht.Cells(i, "B").Value = ent.radius
      End If
      i = i + 1
    Next
    wb.SaveAs "C:\Temp\RadiusOfCircles.xlsx"
    Set sht = Nothing
    Set wb = Nothing
    Set xl = Nothing
End Sub
Public Function GetXL() As Application
    On Error Resume Next
    Dim xlApp As Application
    Set xlApp = GetObject(, "Excel.Application")
    If xlApp Is Nothing Then
        Set xlApp = CreateObject("Excel.Application")
    End If
    Set GetXL = xlApp
End Function

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 4 of 4

fkellogg
Advocate
Advocate

@erhan.lale 

Thanks for the Solution!

The extent of my knowledge of lisp code is the defun: C thing.

My acaddoc.lsp file is chock full of ways to bypass tedious keystrokes and dialog boxes.

 

(defun C:cc0 ( ) (command "chamfer" "distance" 0 0 "chamfer" "polyline" )
(princ "Polyline Chamfer at Distance 0-0" )(princ) )

(defun C:f116 ( ) (command "fillet" "radius" ".6875" "fillet" "Multiple" )
(princ "Multiple Fillet At 11/16 Inch " )(princ) )

(defun C:n ( ) (command "move" "p")
(princ "Move Previous" )(princ) )

 

All that other code is just gibberish to me. No offense intended.

 

Cheers!

CFK

0 Likes