| Author |
Message |
junno
Guest
|
Posted:
Thu Mar 31, 2005 8:25 pm Post subject:
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
|
|
| Back to top |
|
 |
Oberer
Guest
|
Posted:
Thu Mar 31, 2005 9:42 pm Post subject:
Re: Text Search |
|
|
| 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
|
|
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Thu Mar 31, 2005 11:00 pm Post subject:
Re: Text Search |
|
|
| Quote: | '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@jiveforum2.autodesk.com...
| Quote: | | 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
|
|
|
|
| Back to top |
|
 |
Oberer
Guest
|
Posted:
Fri Apr 01, 2005 6:04 pm Post subject:
Re: Text Search |
|
|
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... |
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Fri Apr 01, 2005 6:42 pm Post subject:
Re: Text Search |
|
|
Hey Oberer,
here is one example
http://discussion.autodesk.com/thread.jspa?messageID=380944
check out this thread bunch of samples:
http://discussion.autodesk.com/thread.jspa?messageID=4152045
your can criticize how I did it...;-)
gl
Paul
"Oberer" <nospam@address.withheld> wrote in message
news:18371171.1112360720914.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | 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... |
|
|
| Back to top |
|
 |
|
|
|
|