Previous selection set

Discussion in 'AutoCAD' started by srinivasan, Feb 23, 2005.

  1. srinivasan

    srinivasan Guest

    Dear all,

    I am using the selection set to filter required objects,
    which works well and good.The problem i have is after
    making selection with this method the previous selection set
    method selects only the filtered objects and not the exact previous set.but i want to retain the previous selection as in autocad.Is there any other method to do this, or is it possible to make any named selection set the previous one.

    Thanks in advance.
    Sri
     
    srinivasan, Feb 23, 2005
    #1
  2. srinivasan

    Oberer Guest

    Could you explain this a little better? The way I read this is that you create a sel set via vba, then select the same sel set.

    perhaps you could create two sel set objects. After processing, set thisdrawing.activeselectionset to the 1st...
     
    Oberer, Feb 23, 2005
    #2
  3. srinivasan

    srinivasan Guest

    Thanks for your reply.

    Actually i am creating a selection set filtering text objects and performing certain check operations on few texts.

    After completing this check,when i say copy command and say previous it selects all the text objects.So i tried to store the previous selectionset before performing this operation and after completing the check process now i want to assign the selection set which i stored to the previous selection set.
    I couldnt get this.I am looking for a solution for this problem.

    Expecting your reply.

    With regards
    Sri
     
    srinivasan, Feb 24, 2005
    #3
  4. srinivasan

    Oberer Guest

    "Actually i am creating a selection set filtering text objects and performing certain check operations on few texts."
    After completing this check,when i say copy command and say previous it selects all the text objects.
    "So i tried to store the previous selectionset before performing this operation and after completing the check process now i want to assign the selection set which i stored to the previous selection set.
    I couldnt get this.I am looking for a solution for this problem."

    Does this mean you want to copy the entire selection set, or the entities you modified?

    is this similar to what you have?
    Code:
    'return a selection set of text & mtext
    Public Sub test()
    Dim oEnt As AcadEntity
    Dim oEntCopy As AcadEntity
    Dim ssetObj As AcadSelectionSet
    Dim grpCode(0 To 3) As Integer
    Dim dataVal(0 To 3) As Variant
    
    ThisDrawing.StartUndoMark
    'create a new selection set object
    Set ssetObj = vbdPowerSet("SS01")
    
    ' Build a selection set of group codes and values to filter for: Text or Mtext.
    grpCode(0) = -4
    dataVal(0) = "<OR"
    grpCode(1) = 0
    dataVal(1) = "TEXT"
    grpCode(2) = 0
    dataVal(2) = "MTEXT"
    grpCode(3) = -4
    dataVal(3) = "OR>"
    
    'prompt for user to select text
    ssetObj.SelectOnScreen grpCode, dataVal
    
    For Each oEnt In ssetObj
    'your code here
    Set oEntCopy = oEnt.Copy()
    Next
    
    End Sub
    
     
    Oberer, Feb 24, 2005
    #4
  5. srinivasan

    srinivasan Guest

    Thanks Oberer for your reply.

    Yes i am performing a similar task as given by you with a small change.

    Public Sub test()
    Dim oEnt As AcadEntity
    Dim oEntCopy As AcadEntity
    Dim ssetObj As AcadSelectionSet
    Dim grpCode(0 To 3) As Integer
    Dim dataVal(0 To 3) As Variant ThisDrawing.StartUndoMark
    'create a new selection set object
    Set ssetObj = vbdPowerSet("SS01")
    ' Build a selection set of group codes and values to filter for: Text or Mtext.
    grpCode(0) = -4 dataVal(0) = "<OR" grpCode(1) = 0 dataVal(1) = "TEXT" grpCode(2) = 0 dataVal(2) = "MTEXT" grpCode(3) = -4 dataVal(3) = "OR>"
    'prompt for user to select text ssetObj.SelectOnScreen grpCode, dataVal
    For Each oEnt In ssetObj
    if objent.textstring="sample" then
    objent.textstring="Sample object"
    end if
    Next
    End Sub

    after completing this procedure i just issue the command
    copy and in the select objects prompt i just say "previous".
    Now it selects all the text object which i selected using the test procedure.So what i did was stored all the text which satisfied my condition in a objectarray and tried to make that as the previous selection set.

    Thisdrawing.activeselectionset.clear
    Thisdrawing.activeselectionset.additems objectarray

    But still i am not getting the previous selection as i expected,it selects all the text objects.

    Expecting your solution.

    thanks in advance.

    With regards
    Sri
     
    srinivasan, Feb 25, 2005
    #5
  6. srinivasan

    Oberer Guest

    hopefully someone else can help you with this. i haven't tested it anything, but the help says:

    "ActiveSelectionSet

    SelectionSet object; read-only
    The active selection set for the drawing.
    "
     
    Oberer, Feb 25, 2005
    #6
  7. srinivasan

    viswanathan Guest

    Hi,

    I am writing like this :

    Public Sub selectionsettest()
    Set sset1 = ThisDrawing.SelectionSets.Add("ss12")
    Dim ssetcons(0) As Integer
    Dim ssetvalue(0) As Variant
    ssetcons(0) = 0
    ssetvalue(0) = "LWPOLYLINE"
    sset1.SelectOnScreen ssetcons, ssetvalue
    For Each ent1 In sset1
    MsgBox ent1.Handle
    Next ent1
    sset1.Select acSelectionSetPrevious, , , ssetcons, ssetvalue
    For Each ent1 In sset1
    ent1.Color = acYellow
    Next ent1
    sset1.Delete
    End Sub

    Test and Let me know

    viswanathan.s
     
    viswanathan, Mar 17, 2005
    #7
  8. srinivasan

    srinivasan Guest

    That is not what i was looking.

    Actually you are selecting the same entity which was selected by the user.

    Assume that i issued copy command and selected two objects from the drawing and copied it to some other location.
    Now my previous selection set is those two objs i had selected previously.
    I am storing this set in a selection set variable (sset1).

    After which i run a vbafunction and making a selection set(sset2).

    Now the previous elements goes to the selection set objects
    selected by the vba function (sset2).

    Now wanti need is make the sset1 as the previous one.

    Regards
    Sri
     
    srinivasan, Mar 18, 2005
    #8
  9. Sri,
    To paraphrase you, it sounds like you want the same items to be selected by
    the "P" option AFTER your program runs as would have been selected BEFORE
    your program ran. You don't want your program to change the "Previous"
    selection set, correct?

    I tried to find a solution and couldn't. The only idea I could think of was
    to try to create a second selection set at the end of your program, so that
    it would become the "P" selection set. I was going to store the handles of
    the active selection set at the beginning of the macro, and then use a
    filter on entity handles, to make a selection set of those same entities at
    the macro's end. But VBA won't let you make a filter based on handles. And
    neither will the LISP function (ssget), so I couldn't even use SendCommand
    to make a filtered ss. I even tried using (ssget) followed by (handent),
    but these don't work together.

    Maybe someone else knows how to build a selection set of specific entities?
    You could always create a new unique layer, move all the objects onto that
    layer, filter by that layer at the end of your macro, and change the
    entities all back to their original layers. But that's a lot of work.

    James


    drawing and copied it to some other location.
     
    James Belshan, Mar 18, 2005
    #9
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.