Determining if a block name is in an array

Discussion in 'AutoCAD' started by JoeMagas, Jun 1, 2004.

  1. JoeMagas

    JoeMagas Guest

    Any assistance would be appricated:

    I am importing into VBA an AutoLisp list called "block_database"

    objSelSet is a selection set with various blocks in it.

    I want to check if the block name of the blocks in objselset is NOT in varLispList if so remove it friom the selection set.

    Dim V As Vlax
    Dim ent As AcadEntity
    varLispList = V.GetLispList("block_database")
    For Each ent In objSelSet
    entname = ent.Name
    <missing stuff goes here>
    Next

    I'm not sure how to check the block name with the array.

    Thanks,
    Joe
     
    JoeMagas, Jun 1, 2004
    #1
  2. JoeMagas

    Jürg Menzi Guest

    Joe

    Something like this?
    '...
    Dim V As Vlax
    Dim ent As AcadEntity
    varLispList = V.GetLispList("block_database")
    For Each ent In objSelSet
    entname = ent.Name
    If IsInArray(varLispList, entname) then
    Debug.Print entname & " in array..."
    Else
    Debug.Print entname & " not in array..."
    End If
    Next
    '...
    ' -----
    Public Function IsInArray(CurArr As Variant, CurVal As Variant) As Boolean

    Dim ArrCnt As Long

    IsInArray = False

    For ArrCnt = LBound(CurArr) To UBound(CurArr)
    If CurArr(ArrCnt) = CurVal Then
    IsInArray = True
    Exit For
    End If
    Next ArrCnt

    End Function
    ' -----

    Cheers
     
    Jürg Menzi, Jun 1, 2004
    #2
  3. JoeMagas

    JoeMagas Guest

    Thanks a million, Juerg it works great except....

    Trying to remove from the selection set any entity that does not appear in the array...


    Dim V As Vlax
    Dim ent As AcadEntity
    Set V = New Vlax
    varLispList = V.GetLispList("block_database")

    For Each ent In objSelSet
    entname = ent.Name
    entarray = entname(0)
    If IsInArray(varLispList, entname) Then
    MsgBox entname & " is in array"
    Else
    objSelSet.RemoveItems (entarray) '<- Problem is here.
    End If
    Next


    Thanks again for help,
    Joe
     
    JoeMagas, Jun 1, 2004
    #3
  4. JoeMagas

    Jürg Menzi Guest

    Joe

    Glad to help you...

    Maybe you could explain me what you like to do, otherwise
    try this:
    '...
    Dim V As Vlax
    Dim ent As AcadEntity
    Dim entarray(0) as AcadEntity
    Set V = New Vlax
    varLispList = V.GetLispList("block_database")

    For Each ent In objSelSet
    entname = ent.Name
    Set entarray(0) = ent
    If IsInArray(varLispList, entname) Then
    MsgBox entname & " is in array"
    Else
    objSelSet.RemoveItems entarray
    End If
    Next
    '...

    Cheers
     
    Jürg Menzi, Jun 1, 2004
    #4
  5. JoeMagas

    JoeMagas Guest

    Works great thanks again.

    Joe
     
    JoeMagas, Jun 2, 2004
    #5
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.