Results 1 to 2 of 2

Thread: Deselect Some of Selected Objects

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2018-07
    Posts
    1
    Login to Give a bone
    0

    Default Deselect Some of Selected Objects

    Hi,
    For a project I need to prevent the user to modify objects which belong to a specific Layer.
    below is my VBA code to do this.I used "SelectionChanged" event to trigger the program. I can loop through objects that are selected by user.The problem starts when I want to deselect the objects that are in "Block" layer. Actually, I can't find any way to deselect them.I will be very glad if you can help me.Many thanks in advance

    Private Sub AcadDocument_SelectionChanged()

    Dim pfSS As AcadSelectionSet
    Dim ssobject As AcadEntity
    Dim msg As String
    msg = vbCrLf

    Set pfSS = ThisDrawing.PickfirstSelectionSet

    For Each ssobject In pfSS

    If ssobject.Layer = "Block" Then

    '' Here I dont know how to deselect!!
    msg = msg & vbCrLf & ssobject.ObjectName

    MsgBox "The Block Object Type Is: " & msg

    End If

    Next ssobject

    End Sub

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,396
    Login to Give a bone
    0

    Default Re: Deselect Some of Selected Objects

    Use the AcadSelectionSet.RemoveItems method. You can't simply execute the method in your For..Each loop because then the selection set will be changing on each loop. Therefore, you need to add the qualifying items to an array of AcadEntity objects. After the For..Each loop completes, then you can run the RemoveItems method and pass it the array of entities to be removed.
    C:> ED WORKING....

Similar Threads

  1. Setting X to selected objects
    By mbrandt5 in forum AutoLISP
    Replies: 4
    Last Post: 2015-08-13, 02:09 PM
  2. Hold down Shift key to deselect Objects not working
    By smooth shoes in forum AutoCAD General
    Replies: 15
    Last Post: 2010-08-18, 09:08 PM
  3. "Nothing Selected" message when Objects are Selected
    By mark.81576 in forum AutoCAD General
    Replies: 4
    Last Post: 2007-04-13, 05:00 PM
  4. Objects not regenerated / selected.
    By nata_hs in forum AutoCAD General
    Replies: 1
    Last Post: 2004-12-30, 01:02 PM
  5. Permanently hiding selected objects (not objects-by-category)
    By cjneedham in forum Revit Architecture - Wish List
    Replies: 2
    Last Post: 2004-06-28, 12:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •