Message 1 of 4
Problems selection set

Not applicable
10-25-2000
08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am having some problems using selection sets correctly.
I have written a function which is supposed to check and see if there is any
text within a given rectangle. Basically I am using this to make sure that
I don't write text over existing text, so when I create a new piece of text
I send the bounding box of the new text to this function - if there is
already text anywhere in the box then I either delete the potential new text
or move it somewhere else.
The problem is that the selection set does not work consistently. Sometimes
it never picks up anything in the crossing (even though I know there is text
in the crossing during debug) and sometimes is does work. I am guessing it
has something to do with the creation of the selection set object, resetting
and scope?
After the code fails sometimes in the same session it will suddenly work?
As well, I am not too experienced in the use of On Error ? Sometimes I get
an error indidcating that the selection set already exists so I inserted the
On Error line (which is now commented out).
Can anyone point me in the right direction?
Thanks,
Natan Elsberg
--------------------------------------
The function:
Public Function IsTextInRectangle(corner1 As Variant, corner2 As Variant) As
Boolean
Dim ssetObj As AcadSelectionSet
Dim aobject As AcadObject
Dim aline As AcadLine
'On Error Resume Next
Set ssetObj = oacadApp.ActiveDocument.SelectionSets.Add("zzzzSSET")
Dim bAnswer As Boolean
bAnswer = False
Dim mode As Integer
mode = acSelectionSetCrossing
ssetObj.Select acSelectionSetCrossing, corner1, corner2
'Set aline = moSpace.AddLine(corner1, corner2)
For Each aobject In ssetObj
If aobject.ObjectName = "AcDbText" Then bAnswer = True
Next
ssetObj.Delete
IsTextInRectangle = bAnswer
End Function
I am having some problems using selection sets correctly.
I have written a function which is supposed to check and see if there is any
text within a given rectangle. Basically I am using this to make sure that
I don't write text over existing text, so when I create a new piece of text
I send the bounding box of the new text to this function - if there is
already text anywhere in the box then I either delete the potential new text
or move it somewhere else.
The problem is that the selection set does not work consistently. Sometimes
it never picks up anything in the crossing (even though I know there is text
in the crossing during debug) and sometimes is does work. I am guessing it
has something to do with the creation of the selection set object, resetting
and scope?
After the code fails sometimes in the same session it will suddenly work?
As well, I am not too experienced in the use of On Error ? Sometimes I get
an error indidcating that the selection set already exists so I inserted the
On Error line (which is now commented out).
Can anyone point me in the right direction?
Thanks,
Natan Elsberg
--------------------------------------
The function:
Public Function IsTextInRectangle(corner1 As Variant, corner2 As Variant) As
Boolean
Dim ssetObj As AcadSelectionSet
Dim aobject As AcadObject
Dim aline As AcadLine
'On Error Resume Next
Set ssetObj = oacadApp.ActiveDocument.SelectionSets.Add("zzzzSSET")
Dim bAnswer As Boolean
bAnswer = False
Dim mode As Integer
mode = acSelectionSetCrossing
ssetObj.Select acSelectionSetCrossing, corner1, corner2
'Set aline = moSpace.AddLine(corner1, corner2)
For Each aobject In ssetObj
If aobject.ObjectName = "AcDbText" Then bAnswer = True
Next
ssetObj.Delete
IsTextInRectangle = bAnswer
End Function