How can I loop through text objects in a drawing and filter out text strings containing double quotation marks (eg 12" - 12 inches).
Thanks
How can I loop through text objects in a drawing and filter out text strings containing double quotation marks (eg 12" - 12 inches).
Thanks
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
You only need to search your SS collection'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]
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
paul,
are you suggesting the following?
is the err.clear necessary? i didn't think it would get cleared after the function...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
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?
is the err.clear necessary? i didn't think it would get cleared after theCode: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
function...
ACADV14: Search text and zoom on it!
DWG- DWF Search Engine