Selectoin Set Erase problem

Discussion in 'AutoCAD' started by Pat Bjork, Apr 9, 2004.

  1. Pat Bjork

    Pat Bjork Guest

    I am trying to write a program to clean up drawing files. I have most of my
    program running fine but am having problems with erasing all of the objects
    from paperspace. When i run the program I get the following error: Runtime
    error -2145320958(8021002) Invalid Entity Name. When I select debug it
    hightlights the line that reads PspaceObj.Erase. I have included the code
    below. If I change all of the paperspace entries to modelspace it works
    fine. Does anyone know why this is not working for paperspace?

    With ThisDrawing.Utility

    Dim pspaceObj As AcadSelectionSet
    Set pspaceObj = ThisDrawing.SelectionSets.Add("PspaceObjects")
    ReDim ssobjs(0 To ThisDrawing.PaperSpace.count - 1) As AcadEntity
    Dim I As Integer

    For I = 0 To ThisDrawing.PaperSpace.count - 1
    Set ssobjs(I) = ThisDrawing.PaperSpace.Item(I)
    Next

    'add the array of objects to the selection set
    pspaceObj.AddItems ssobjs
    'erase the objects in the selection set
    pspaceObj.Erase

    End With

    Thanks,

    Pat
     
    Pat Bjork, Apr 9, 2004
    #1
  2. The most likely cause is that your code is trying
    to erase the paperspace viewport, which you can't
    do.

    You're going to need to find out which entity is
    the paper space viewport, but doing that is somewhat
    difficult.

    The best way to get around the problem is by
    erasing each entity individually, and ignoring
    the error that occurs when you try to erase the
    paper space viewport.

    Dim Entity As AcadEntity
    On Error Resume Next
    For Each Entity in ThisDrawing.Paperspace
    Entity.Erase
    Next Entity




    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Apr 9, 2004
    #2
  3. Pat Bjork

    Pat Bjork Guest

    Thanks Tony. Sometime I try to make things too difficult. I put in your
    little piece of code and it does exactly what I want.

    Thanks again,

    Pat
     
    Pat Bjork, Apr 9, 2004
    #3
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.