Select using XData Filter, only works with lwpolyline, is it a bug?

Select using XData Filter, only works with lwpolyline, is it a bug?

Anonymous
Not applicable
738 Views
8 Replies
Message 1 of 9

Select using XData Filter, only works with lwpolyline, is it a bug?

Anonymous
Not applicable
Hi,

I'm trying to select entities using XData, it's only working with polylines,
if the XData is attached to a different entity type, it won't work.

The following code will attach XData to any entity


Public Function AddXDATA()
Dim returnObj As AcadObject
ReDim xtype(0 To 1) As Integer
ReDim xdata(0 To 1) As Variant
Dim basePoint(0 To 2) As Double

ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
xtype(0) = 1001: xdata(0) = "AAA"
xtype(1) = 1000: xdata(1) = "888"
returnObj.SetXDATA xtype, xdata
End Function



This code will only work if the above code was applied to a polyline


Public Function FindEntByXData()
Dim tempsset1 As AcadSelectionSet Dim filterType1(1) As Integer
Dim filterData1(1) As Variant
filterType1(0) = 1001: filterData1(0) = "AAA"
filterType1(1) = 1000: filterData1(1) = "888"
Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
tempsset1.Clear
tempsset1.Select acSelectionSetAll, , , filterType1, filterData1
tempsset1.Delete
End Function


Your help will be deeply appreciated

Best regards

Wael Bakr
0 Likes
739 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
The fact that it works at all would be a bug. You cannot
filter on extended entity data, except for the application
name (1001 group).

"Wael Bakr" wrote in message
news:33DB8402915423682698CF4299337487@in.WebX.maYIadrTaRb...
> Hi,
>
> I'm trying to select entities using XData, it's only working with
polylines,
> if the XData is attached to a different entity type, it won't work.
>
> The following code will attach XData to any entity
>
>
> Public Function AddXDATA()
> Dim returnObj As AcadObject
> ReDim xtype(0 To 1) As Integer
> ReDim xdata(0 To 1) As Variant
> Dim basePoint(0 To 2) As Double
>
> ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
> xtype(0) = 1001: xdata(0) = "AAA"
> xtype(1) = 1000: xdata(1) = "888"
> returnObj.SetXDATA xtype, xdata
> End Function
>
>
>
> This code will only work if the above code was applied to a polyline
>
>
> Public Function FindEntByXData()
> Dim tempsset1 As AcadSelectionSet Dim filterType1(1) As Integer
> Dim filterData1(1) As Variant
> filterType1(0) = 1001: filterData1(0) = "AAA"
> filterType1(1) = 1000: filterData1(1) = "888"
> Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
> tempsset1.Clear
> tempsset1.Select acSelectionSetAll, , , filterType1, filterData1
> tempsset1.Delete
> End Function
>
>
> Your help will be deeply appreciated
>
> Best regards
>
> Wael Bakr
>
>
0 Likes
Message 3 of 9

Anonymous
Not applicable
Hi Wael,
sure enuf, like Tony says looks like you found a bug, in that plines work
different than other objs. I only tried lwplines, lines and circles though
so there would be lots of other possibilities to check. But since "AAA" is
your "program name" then if you just make Xtype(0) and eliminate the 1000
code you'll get all the entities that have "AAA" xdata in your sel set.
Then if you want to select specific elements of data (looking for the "888"
specifically, then you can search that sel set to find those matches.
I assume since you got this far you know how to GetXdata from the items in
your sel set once you have it?
Good luck,
I'm also starting to work on some xdata routines, if I get anything working
before you do I'll let you know.
Mark

Wael Bakr wrote in message
news:33DB8402915423682698CF4299337487@in.WebX.maYIadrTaRb...
> Hi,
>
> I'm trying to select entities using XData, it's only working with
polylines,
> if the XData is attached to a different entity type, it won't work.
>
> The following code will attach XData to any entity
>
>
> Public Function AddXDATA()
> Dim returnObj As AcadObject
> ReDim xtype(0 To 1) As Integer
> ReDim xdata(0 To 1) As Variant
> Dim basePoint(0 To 2) As Double
>
> ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
> xtype(0) = 1001: xdata(0) = "AAA"
> xtype(1) = 1000: xdata(1) = "888"
> returnObj.SetXDATA xtype, xdata
> End Function
>
>
>
> This code will only work if the above code was applied to a polyline
>
>
> Public Function FindEntByXData()
> Dim tempsset1 As AcadSelectionSet Dim filterType1(1) As Integer
> Dim filterData1(1) As Variant
> filterType1(0) = 1001: filterData1(0) = "AAA"
> filterType1(1) = 1000: filterData1(1) = "888"
> Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
> tempsset1.Clear
> tempsset1.Select acSelectionSetAll, , , filterType1, filterData1
> tempsset1.Delete
> End Function
>
>
> Your help will be deeply appreciated
>
> Best regards
>
> Wael Bakr
>
>
0 Likes
Message 4 of 9

Anonymous
Not applicable
Thanks Mark, appreciate that.

At the moment I'm thinking of registering the 888 as another application and
query using both application, I hope this will be faster than searching in a
selection set.

Best regards

Wael Bakr



"MP" wrote in message
news:FC6E370C07A75EA5BB582AE2F0B38E29@in.WebX.maYIadrTaRb...
> Hi Wael,
> sure enuf, like Tony says looks like you found a bug, in that plines work
> different than other objs. I only tried lwplines, lines and circles though
> so there would be lots of other possibilities to check. But since "AAA"
is
> your "program name" then if you just make Xtype(0) and eliminate the 1000
> code you'll get all the entities that have "AAA" xdata in your sel set.
> Then if you want to select specific elements of data (looking for the
"888"
> specifically, then you can search that sel set to find those matches.
> I assume since you got this far you know how to GetXdata from the items in
> your sel set once you have it?
> Good luck,
> I'm also starting to work on some xdata routines, if I get anything
working
> before you do I'll let you know.
> Mark
>
> Wael Bakr wrote in message
> news:33DB8402915423682698CF4299337487@in.WebX.maYIadrTaRb...
> > Hi,
> >
> > I'm trying to select entities using XData, it's only working with
> polylines,
> > if the XData is attached to a different entity type, it won't work.
> >
> > The following code will attach XData to any entity
> >
> >
> > Public Function AddXDATA()
> > Dim returnObj As AcadObject
> > ReDim xtype(0 To 1) As Integer
> > ReDim xdata(0 To 1) As Variant
> > Dim basePoint(0 To 2) As Double
> >
> > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
> > xtype(0) = 1001: xdata(0) = "AAA"
> > xtype(1) = 1000: xdata(1) = "888"
> > returnObj.SetXDATA xtype, xdata
> > End Function
> >
> >
> >
> > This code will only work if the above code was applied to a polyline
> >
> >
> > Public Function FindEntByXData()
> > Dim tempsset1 As AcadSelectionSet Dim filterType1(1) As Integer
> > Dim filterData1(1) As Variant
> > filterType1(0) = 1001: filterData1(0) = "AAA"
> > filterType1(1) = 1000: filterData1(1) = "888"
> > Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
> > tempsset1.Clear
> > tempsset1.Select acSelectionSetAll, , , filterType1, filterData1
> > tempsset1.Delete
> > End Function
> >
> >
> > Your help will be deeply appreciated
> >
> > Best regards
> >
> > Wael Bakr
> >
> >
>
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
Hi Tony,

I guess you are right as this is the only explanation to it.

Thanks for your help


Best regards

Wael Bakr

"Tony Tanzillo" wrote in message
news:9BAD69E8EB1B74292DE0DAF0313E4CF0@in.WebX.maYIadrTaRb...
> The fact that it works at all would be a bug. You cannot
> filter on extended entity data, except for the application
> name (1001 group).
>
> "Wael Bakr" wrote in message
> news:33DB8402915423682698CF4299337487@in.WebX.maYIadrTaRb...
> > Hi,
> >
> > I'm trying to select entities using XData, it's only working with
> polylines,
> > if the XData is attached to a different entity type, it won't work.
> >
> > The following code will attach XData to any entity
> >
> >
> > Public Function AddXDATA()
> > Dim returnObj As AcadObject
> > ReDim xtype(0 To 1) As Integer
> > ReDim xdata(0 To 1) As Variant
> > Dim basePoint(0 To 2) As Double
> >
> > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
> > xtype(0) = 1001: xdata(0) = "AAA"
> > xtype(1) = 1000: xdata(1) = "888"
> > returnObj.SetXDATA xtype, xdata
> > End Function
> >
> >
> >
> > This code will only work if the above code was applied to a polyline
> >
> >
> > Public Function FindEntByXData()
> > Dim tempsset1 As AcadSelectionSet Dim filterType1(1) As Integer
> > Dim filterData1(1) As Variant
> > filterType1(0) = 1001: filterData1(0) = "AAA"
> > filterType1(1) = 1000: filterData1(1) = "888"
> > Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
> > tempsset1.Clear
> > tempsset1.Select acSelectionSetAll, , , filterType1, filterData1
> > tempsset1.Delete
> > End Function
> >
> >
> > Your help will be deeply appreciated
> >
> > Best regards
> >
> > Wael Bakr
> >
> >
>
>
0 Likes
Message 6 of 9

Anonymous
Not applicable
Hi Tony:
I was having the same problem but even on filtering
on application name only the or and and filtering
doesn't work properly.
I tried to search for a filter in this way
Public Function AddXDATA()
Dim tempsset1 As AcadSelectionSet
Dim filtertype(0 To 3) As Integer
Dim filterdata(0 To 3) As Variant
filtertype(0) = -4: filterdata(0) = " filtertype(1) = 1001: filterdata(1) = "888"
filtertype(2) = 1001: filterdata(2)="999"
filtertype(3) = -4: filterdata(3)="or>"
Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
tempsset1.Clear
tempsset1.Select acSelectionSetAll, ,filterType,filterdata
tempsset1.count
tempsset1.delete
End Function

The tempsset1.count always is one instead of two
although i am sure that there are two entities
representing these application names.

Please any one tell me why?
0 Likes
Message 7 of 9

Anonymous
Not applicable
Nermeen,
see if this works

Dim dxfCode(0 to 0) as Integer
Dim dxfData(0 to 0) as Variant

dxfCode(0) = 1001
dxfData(0) = "888,999"

there are lots of posts in google regarding multi selections but I think
this is the general method
I don't know why the lisp/dxf style doesn't work in vb but I've seen this
issue talked about many times on the ng and it just doesn't seem to work for
anyone.

good luck,
Mark

"nermeen" wrote in message
news:f0e54a9.4@WebX.maYIadrTaRb...
> Hi Tony:
> I was having the same problem but even on filtering
> on application name only the or and and filtering
> doesn't work properly.
> I tried to search for a filter in this way
> Public Function AddXDATA()
> Dim tempsset1 As AcadSelectionSet
> Dim filtertype(0 To 3) As Integer
> Dim filterdata(0 To 3) As Variant
> filtertype(0) = -4: filterdata(0) = " > filtertype(1) = 1001: filterdata(1) = "888"
> filtertype(2) = 1001: filterdata(2)="999"
> filtertype(3) = -4: filterdata(3)="or>"
> Set tempsset1 = acadDoc.SelectionSets.Add("SSet")
> tempsset1.Clear
> tempsset1.Select acSelectionSetAll, ,filterType,filterdata
> tempsset1.count
> tempsset1.delete
> End Function
> The tempsset1.count always is one instead of two
> although i am sure that there are two entities
> representing these application names.
>
> Please any one tell me why?
>
>
0 Likes
Message 8 of 9

Anonymous
Not applicable
Hi Mark:
I tried this one but it also didn't work as well
as the and it seems that the filter cann't take
more than one critera.

Thanks for your concern.
Nermeen.
0 Likes
Message 9 of 9

Anonymous
Not applicable
Hi Mark:
I tried it again it worked but it works only with
or but i still can't make a filter combined from
or and AND.this is way it was working with me because
i was trying it with an and condition too.

Thanks for help.
0 Likes