Text Search

Discussion in 'AutoCAD' started by junno, Mar 31, 2005.

  1. junno

    junno Guest

    How can I loop through text objects in a drawing and filter out text strings containing double quotation marks (eg 12" - 12 inches).
    Thanks
     
    junno, Mar 31, 2005
    #1
  2. junno

    Oberer Guest

    Code:
    Public Sub getTextToModify()
    Dim ssetObj As AcadSelectionSet
    Dim grpCode(0) As Integer
    Dim dataVal(0) As Variant
    Dim oEnt As AcadEntity
    
    '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) = 0
    dataVal(0) = "TEXT,MTEXT"
    
    'prompt for user to select text
    ssetObj.SelectOnScreen grpCode, dataVal
    'ssetObj.Select acSelectionSetAll, , , grpCode, dataVal
    
    For Each oEnt In ssetObj
    If InStr(1, oEnt.TextString, """") = 0 Then
    'text with no quotes
    MsgBox oEnt.TextString
    End If
    Next
    End Sub
    
    
    'Simple sel set object creation function.
    'vba will return an error if the sel set object already exists
    'in the SSETS collection
    Public Function vbdPowerSet(strName As String) As AcadSelectionSet
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
    Set objSelCol = ThisDrawing.SelectionSets
    For Each objSelSet In objSelCol
    If objSelSet.Name = strName Then
    objSelCol.Item(strName).Delete
    Exit For
    End If
    Next
    Set objSelSet = objSelCol.Add(strName)
    Set vbdPowerSet = objSelSet
    End Function
    
     
    Oberer, Mar 31, 2005
    #2
  3. 'Simple sel set object creation function.
    You only need to search your SS collection
    if you need to grab the SS if it exists, then use,
    clear or such. I used to do the same until set
    stright, by this group...;-)

    Since your deleting it anyway, you could use
    the following.


    function
    on error resume next
    delete selset
    add selset
    end function

    gl
    Paul

     
    Paul Richardson, Mar 31, 2005
    #3
  4. junno

    Oberer Guest

    paul,
    are you suggesting the following?

    Code:
    Public Function vbdPowerSet2(strName As String) As AcadSelectionSet
    On Error Resume Next
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
    Set objSelCol = ThisDrawing.SelectionSets
    objSelCol.Item(strName).Delete
    Set objSelSet = objSelCol.Add(strName)
    Set vbdPowerSet2 = objSelSet
    If Err.Number <> 0 Then Err.Clear
    End Function
    
    is the err.clear necessary? i didn't think it would get cleared after the function...
     
    Oberer, Apr 1, 2005
    #4
  5. Paul Richardson, Apr 1, 2005
    #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.