How do I step through every entity in a drawing?

Discussion in 'AutoCAD' started by tsigwing, Apr 2, 2004.

  1. tsigwing

    tsigwing Guest

    Including members of blocks including attributes as well as all block definitions?

    We have some old drawings that have layers that are a real pain to get rid of. For example a block definition has the seqend on a layer, and that is the only place the layer exists, so I have to dxfout, change the layer and re-open the drawing. Would like to be able to step through the drawing to change these layers.
     
    tsigwing, Apr 2, 2004
    #1
  2. tsigwing

    Jackrabbit Guest

    [pre]
    Public Sub UpdateAllBlocks()
    Dim Block As AcadBlock
    Dim Entity As AcadEntity

    For Each Block In ThisDrawing.Blocks
    For Each Entity In Block
    '
    ' Do your stuff here.
    '
    Next Entity
    Next Block

    ThisDrawing.PurgeAll
    End Sub
    [/pre]
     
    Jackrabbit, Apr 2, 2004
    #2
  3. tsigwing

    oreois Guest

    Will this also step through all lines, circles, viewports...
     
    oreois, Apr 2, 2004
    #3
  4. tsigwing

    Jeff Mishler Guest

    Yes, because *Modelspace and *Paperspace and all layouts are stored as
    blocks.

    As a test, start a new drawing drawing, add a few entities to model space &
    change their colors to something other than "bylayer". Copy those entities
    to the 2 (if using the default setup) paperspace layouts, then run the Sub
    "UpdateAllBlocks" that Jackrabbit posted, adding the line "Entity.Color =
    acBylayer" where it says "Do your stuff here".

    All instances will be changed to bylayer.

    HTH,
    Jeff

     
    Jeff Mishler, Apr 2, 2004
    #4
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.