Results 1 to 5 of 5

Thread: Text Search

  1. #1
    junno Guest

    Text Search

    How can I loop through text objects in a drawing and filter out text strings containing double quotation marks (eg 12" - 12 inches).
    Thanks

  2. #2
    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

  3. #3
    Paul Richardson Guest
    '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
    [/code]
    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

    "Oberer" <nospam@address.withheld> wrote in message
    news:5935664.1112287389246.JavaMail.jive@jiveforum 2.autodesk.com...
    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

  4. #4
    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...

  5. #5
    Paul Richardson Guest
    Hey Oberer,

    here is one example
    http://discussion.autodesk.com/threa...ssageID=380944

    check out this thread bunch of samples:
    http://discussion.autodesk.com/threa...sageID=4152045
    your can criticize how I did it...;-)

    gl
    Paul
    "Oberer" <nospam@address.withheld> wrote in message
    news:18371171.1112360720914.JavaMail.jive@jiveforu m2.autodesk.com...
    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...

Similar Threads

  1. Search new design variables
    By Stéfan Robert in forum Cadence
    Replies: 5
    Last Post: 07-13-2005, 05:10 AM
  2. Dwg text search capture
    By Rake in forum AutoCAD
    Replies: 3
    Last Post: 04-19-2005, 10:33 PM
  3. ACADV14: Search text and zoom on it!
    By Dietz Franz in forum AutoCAD
    Replies: 1
    Last Post: 04-06-2005, 10:12 AM
  4. DWG- DWF Search Engine
    By ctrl alt f in forum AutoCAD
    Replies: 0
    Last Post: 02-11-2005, 10:46 PM
  5. Replies: 1
    Last Post: 12-17-2004, 06:54 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
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum