Filtered Selection Sets

Filtered Selection Sets

Anonymous
Not applicable
368 Views
6 Replies
Message 1 of 7

Filtered Selection Sets

Anonymous
Not applicable
Hi All,

Frank Oquendo was kind enough to send me code for a filtered selection set.
(see below) My question follows the code.

Public Sub
BuildFilter(typeArray, dataArray, ParamArray gCodes())

   
Dim fType() As Integer, fData()
    Dim index As Long, I As
Long

    index = LBound(gCodes) -
1

    For I = LBound(gCodes) To UBound(gCodes) Step
2
        index = index +
1
        ReDim Preserve fType(0 To
index)
        ReDim Preserve fData(0 To
index)
        fType(index) =
CInt(gCodes(I))
        fData(index) =
gCodes(I + 1)
    Next
    typeArray =
fType: dataArray = fData

End Sub

With ThisDrawing.Utility
    Set ss =
CreateSelectionSet()
    BuildFilter fType, fData, 0,
"INSERT", 2, "ROOMTAG"
    ss.Select acSelectionSetAll, , ,
fType, fData
    .Prompt vbCr & "There are " &
ss.Count & " Roomtags in this drawing."
End With

 

I am wondering if it is possible to use this same filter to search for
all
instances of other entities beyond blocks.  I am assuming it has
something
to do with the dataArray and gCodes.  Is that right or am I
way off.  If
this is correct, are there lists for each type of entity
and if so where can
I find them.  I am trying to search for all closed
polylines.

Thanx,

Rob

0 Likes
369 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
This is the key line:

BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"

The fType data are the integers that correspond to the dxf-style codes
listed in the DXF reference on-line help. To get all closed plines, you
would use:

BuildFilter fType, fData, 0, "POLYLINE,LWPOLYLINE", 70, 1

BTW, Frank, how would this handle bit coded values such as the 70 group?

--
http://www.acadx.com
Win a free autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"Rob Outman" wrote in message
news:[email protected]...
| Hi All,
|
| Frank Oquendo was kind enough to send me code for a filtered selection
set. (see below) My question follows the code.
|
| Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
|
| Dim fType() As Integer, fData()
| Dim index As Long, I As Long
|
| index = LBound(gCodes) - 1
|
| For I = LBound(gCodes) To UBound(gCodes) Step 2
| index = index + 1
| ReDim Preserve fType(0 To index)
| ReDim Preserve fData(0 To index)
| fType(index) = CInt(gCodes(I))
| fData(index) = gCodes(I + 1)
| Next
| typeArray = fType: dataArray = fData
|
| End Sub
|
| With ThisDrawing.Utility
| Set ss = CreateSelectionSet()
| BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"
| ss.Select acSelectionSetAll, , , fType, fData
| .Prompt vbCr & "There are " & ss.Count & " Roomtags in this drawing."
| End With
|
| I am wondering if it is possible to use this same filter to search for all
| instances of other entities beyond blocks. I am assuming it has something
| to do with the dataArray and gCodes. Is that right or am I way off. If
| this is correct, are there lists for each type of entity and if so where
can
| I find them. I am trying to search for all closed polylines.
|
| Thanx,
|
| Rob
|
|
|
0 Likes
Message 3 of 7

Anonymous
Not applicable
> BTW, Frank, how would this handle bit coded values such as the 70
group?

I came across this little gem looking through VisualLISP help on
selection set filters:

BuildFilter fTpe, fData, 0 , "LWPOLYLINE, -4, "&=", 70, 1

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"R. Robert Bell" wrote in message
news:[email protected]...
> This is the key line:
0 Likes
Message 4 of 7

Anonymous
Not applicable
Thanx R. Robert Bell. (should I just call you R. kinda like Q. of James Bond
fame)

Let me see if I am understanding correctly. fType is searching for a "type"
of entity and fData is the properties of that entity. So, as in the case
below:

BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"

0 - This represents the block group code?
"Insert" - This represents the insert of the block?
2 - This represents the block name group code?
"Roomtag" - This represents the name of the block to search for?

and just to reassure myself that I have it:

BuildFilter fType, fData, 0, "POLYLINE,LWPOLYLINE", 70, 1

0 - ok stumped already. I could not find a 0 group code in Lwpolyline or
Polyline what is this? (maybe the ) (zero) from above is not for the block
group code?
Polyline,Lwpolyline - This represents all Lightweight polys and all polys
70 - This represents the polyline flag group code
1- This represents all closed polys

Ok, please tell me if I am way off or if I am on the right track.

How detailed can you get with a filter. For example:
If I wanted to search for all closed polylines on the "poly" layer that are
less than 100 SF in area.

Is it possible to go to this detail, and if so how would you format it?

Thanx again,

Rob

"R. Robert Bell" wrote in message
news:[email protected]...
> This is the key line:
>
> BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"
>
> The fType data are the integers that correspond to the dxf-style codes
> listed in the DXF reference on-line help. To get all closed plines, you
> would use:
>
> BuildFilter fType, fData, 0, "POLYLINE,LWPOLYLINE", 70, 1
>
> BTW, Frank, how would this handle bit coded values such as the 70 group?
>
> --
> http://www.acadx.com
> Win a free autographed copy of
> "Mastering AutoCAD 2000 Objects"
> by Dietmar Rudolph
>
> "Rob Outman" wrote in message
> news:[email protected]...
> | Hi All,
> |
> | Frank Oquendo was kind enough to send me code for a filtered selection
> set. (see below) My question follows the code.
> |
> | Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
> |
> | Dim fType() As Integer, fData()
> | Dim index As Long, I As Long
> |
> | index = LBound(gCodes) - 1
> |
> | For I = LBound(gCodes) To UBound(gCodes) Step 2
> | index = index + 1
> | ReDim Preserve fType(0 To index)
> | ReDim Preserve fData(0 To index)
> | fType(index) = CInt(gCodes(I))
> | fData(index) = gCodes(I + 1)
> | Next
> | typeArray = fType: dataArray = fData
> |
> | End Sub
> |
> | With ThisDrawing.Utility
> | Set ss = CreateSelectionSet()
> | BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"
> | ss.Select acSelectionSetAll, , , fType, fData
> | .Prompt vbCr & "There are " & ss.Count & " Roomtags in this
drawing."
> | End With
> |
> | I am wondering if it is possible to use this same filter to search for
all
> | instances of other entities beyond blocks. I am assuming it has
something
> | to do with the dataArray and gCodes. Is that right or am I way off. If
> | this is correct, are there lists for each type of entity and if so where
> can
> | I find them. I am trying to search for all closed polylines.
> |
> | Thanx,
> |
> | Rob
> |
> |
> |
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
> BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"
>
> 0 - This represents the block group code?
> "Insert" - This represents the insert of the block?
> 2 - This represents the block name group code?
> "Roomtag" - This represents the name of the block to search for?

That is correct.

> BuildFilter fType, fData, 0, "POLYLINE,LWPOLYLINE", 70, 1
>
> 0 - ok stumped already. I could not find a 0 group code in Lwpolyline or
> Polyline what is this? (maybe the ) (zero) from above is not for the block
> group code?

All entities have a group code 0. It identifies the type of entity.

> Polyline,Lwpolyline - This represents all Lightweight polys and all polys
> 70 - This represents the polyline flag group code
> 1- This represents all closed polys

Almost. If you specify 1, only polylines whose group 70 contains 1 will be
selected. Normally this isn't a problem but group code 70 is a bit-coded field
where multiple options are added together to form a final value. In this
example, any closed polylines that also have linetype generation enabled will
*not* be selected since group code 70 will be 129 instead of 1.

To get around that, use a bitmask:

BuildFilter 0, "LWPOLYLINE", -4, "&=", 70, 1

This expression selects all polylines whose group code 70 contains, but not
necessarily equal to, 1.

> How detailed can you get with a filter.

You can get extremely detailed but you are limited to filtering on information
contained in the entity's definition data. For example, this is possible:
> If I wanted to search for all closed polylines on the "poly" layer

but this is not:
> If I wanted to search for all closed polylines on the "poly" layer
> that are less than 100 SF in area.

The reason is that area is not stored with the entity. That's not to say that yu
can't start with a set that contains all the closed polys on the poly layer and
then weed out those that do not meet your criteria. It just requires additional
processing.

To learn more about DXF group codes and building complex filters, have a look in
the AutoCAD Help file. In specific, be sure to read the DXF Reference. The
Entities section give a very detailed list of DXF group codes. Hope this helps.

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"Rob Outman" wrote in message
news:[email protected]...
0 Likes
Message 6 of 7

Anonymous
Not applicable
Thanx Frank,

That helps greatly.

Rob

"Frank Oquendo" wrote in message
news:[email protected]...
> > BuildFilter fType, fData, 0, "INSERT", 2, "ROOMTAG"
> >
> > 0 - This represents the block group code?
> > "Insert" - This represents the insert of the block?
> > 2 - This represents the block name group code?
> > "Roomtag" - This represents the name of the block to search for?
>
> That is correct.
>
> > BuildFilter fType, fData, 0, "POLYLINE,LWPOLYLINE", 70, 1
> >
> > 0 - ok stumped already. I could not find a 0 group code in Lwpolyline
or
> > Polyline what is this? (maybe the ) (zero) from above is not for the
block
> > group code?
>
> All entities have a group code 0. It identifies the type of entity.
>
> > Polyline,Lwpolyline - This represents all Lightweight polys and all
polys
> > 70 - This represents the polyline flag group code
> > 1- This represents all closed polys
>
> Almost. If you specify 1, only polylines whose group 70 contains 1 will be
> selected. Normally this isn't a problem but group code 70 is a bit-coded
field
> where multiple options are added together to form a final value. In this
> example, any closed polylines that also have linetype generation enabled
will
> *not* be selected since group code 70 will be 129 instead of 1.
>
> To get around that, use a bitmask:
>
> BuildFilter 0, "LWPOLYLINE", -4, "&=", 70, 1
>
> This expression selects all polylines whose group code 70 contains, but
not
> necessarily equal to, 1.
>
> > How detailed can you get with a filter.
>
> You can get extremely detailed but you are limited to filtering on
information
> contained in the entity's definition data. For example, this is possible:
> > If I wanted to search for all closed polylines on the "poly" layer
>
> but this is not:
> > If I wanted to search for all closed polylines on the "poly" layer
> > that are less than 100 SF in area.
>
> The reason is that area is not stored with the entity. That's not to say
that yu
> can't start with a set that contains all the closed polys on the poly
layer and
> then weed out those that do not meet your criteria. It just requires
additional
> processing.
>
> To learn more about DXF group codes and building complex filters, have a
look in
> the AutoCAD Help file. In specific, be sure to read the DXF Reference. The
> Entities section give a very detailed list of DXF group codes. Hope this
helps.
>
> --
> http://www.acadx.com
> Win an autographed copy of
> "Mastering AutoCAD 2000 Objects"
> by Dietmar Rudolph
>
> "Rob Outman" wrote in message
> news:[email protected]...
>
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
Do'h! Should have thought of that... Grr

"Frank Oquendo" wrote in message
news:[email protected]...
| > BTW, Frank, how would this handle bit coded values such as the 70
| group?
|
| I came across this little gem looking through VisualLISP help on
| selection set filters:
|
| BuildFilter fTpe, fData, 0 , "LWPOLYLINE, -4, "&=", 70, 1
0 Likes