routine to extract object that meet certain criteria

Discussion in 'AutoCAD' started by jbryant4, Feb 24, 2005.

  1. jbryant4

    jbryant4 Guest

    i am in need of a routine that will search my selection for circle radius = 21.3 and will put the coordinates of those circles in a text file or an excel file...any ideas?
     
    jbryant4, Feb 24, 2005
    #1
  2. jbryant4

    Jeff Mishler Guest

    Well, here's how to get the object data you want:
    Sub circ_rad()
    Dim ss As AcadSelectionSet
    Dim dxfCode(1) As Integer
    Dim dxfVal(1) As Variant
    Dim ent As AcadEntity
    Dim circ As AcadCircle
    Dim cen

    Set ss = ThisDrawing.PickfirstSelectionSet
    dxfCode(0) = 0: dxfVal(0) = "CIRCLE"
    dxfCode(1) = 40: dxfVal(1) = 21.3

    ss.Select acSelectionSetAll, , , dxfCode, dxfVal
    For Each ent In ss
    Set circ = ent
    cen = circ.Center
    Debug.Print "Center X = " & cen(0); ", Center y = " & cen(1); ", Center
    Z = " & cen(2)
    Next
    End Sub
     
    Jeff Mishler, Feb 24, 2005
    #2
  3. jbryant4

    jbryant4 Guest

    i copied the routine, opened up the VB editor, pasted the copied text and ran...where does the output go to?
     
    jbryant4, Feb 24, 2005
    #3
  4. jbryant4

    MP Guest

    view|immediate (ctl + g)
    debug.print means print to immediate window

    ran...where does the output go to?
     
    MP, Feb 24, 2005
    #4
  5. jbryant4

    jbryant4 Guest

    so when i run the routine, i should see the info in the ACAD text box? I am new to all of this, so your patience is greatly appreciated
     
    jbryant4, Feb 24, 2005
    #5
  6. jbryant4

    Jeff Mishler Guest

    No, in the VBAIDE press CTRL G to bring up the immediate window and it will
    be shown there. This was merely an example to show you how to get the data.
    To display it in acad, you could add this line below the Debug.Print.....
    line:
    circ.Highlight True
    MsgBox "Center X = " & cen(0) & ", Center y = " & cen(1) & ", Center Z =
    " & cen(2)
    circ.Highlight False

    You will need additional code, most of which can be found in the help files
    and example code, to export to a text or excel file.
     
    Jeff Mishler, Feb 24, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.