common dxf group 410 to filter Blocks on the current Layout?

common dxf group 410 to filter Blocks on the current Layout?

Anonymous
Not applicable
732 Views
8 Replies
Message 1 of 9

common dxf group 410 to filter Blocks on the current Layout?

Anonymous
Not applicable
Hi,

Why does this not work?
I'm trying to filter all blocks within the active layout. as soon as i try
to use the common dxf group 410 to filter Blocks on the current Layout the
selectionset is empty.

Dim gpCode(1) As Integer
Dim dataValue(1) As Variant


gpCode(0) = 410 ' common group for Layout
gpCode(1) = 0

dataValue(0) = ThisDrawing.ActiveLayout.Name ' current Layout Name
dataValue(1) = "INSERT" ' value for Group 2

Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue

ssetObj.Select acSelectionSetAll, , , groupCode, dataCode

--

--
Geuko Rooseboom
Decoprojekt
+31-315-270 856
g.rooseboom@decoprojekt.nl
0 Likes
733 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
I think you need to enclose your two filter criteria in an "AND" structure like this.

dim fType(3) as Integer
dim fData(3) as Variant

fType(0) = -4
fData(0) = " fType(1) = 410
fData(1) = ThisDrawing.ActiveLayout.Name
fType(2) = 0
fData(2) = "INSERT"
fType(3) = -4
fData(3) = "AND>"
ssetObj.Select acSelectionSetAll, , , fType, fData

Incidentally, I don't follow why you are assigning your filter array to a second set of
variables (groupCode and dataCode).

Also, if you take a look on AcadX.com at Frank Oquendo's BuildFilter sub, I think you will
find that it makes creating selection set filters a lot easier. With BuildFilter, the
previous code could be abbreviated to the following.

dim fType() as Integer
dim fData() as Variant

BuildFilter fType, fData, -4, " "AND>"
ssetObj.Select acSelectionSetAll, , , fType, fData

Happy Hunting.

Chuck Gabriel


"Geuko#" wrote in message
news:3D6A4EC88E866A9C276F16640BBFCF6B@in.WebX.maYIadrTaRb...
> Hi,
>
> Why does this not work?
> I'm trying to filter all blocks within the active layout. as soon as i try
> to use the common dxf group 410 to filter Blocks on the current Layout the
> selectionset is empty.
>
> Dim gpCode(1) As Integer
> Dim dataValue(1) As Variant
>
>
> gpCode(0) = 410 ' common group for Layout
> gpCode(1) = 0
>
> dataValue(0) = ThisDrawing.ActiveLayout.Name ' current Layout Name
> dataValue(1) = "INSERT" ' value for Group 2
>
> Dim groupCode As Variant, dataCode As Variant
> groupCode = gpCode
> dataCode = dataValue
>
> ssetObj.Select acSelectionSetAll, , , groupCode, dataCode
>
> --
>
> --
> Geuko Rooseboom
> Decoprojekt
> +31-315-270 856
> g.rooseboom@decoprojekt.nl
>
>
0 Likes
Message 3 of 9

Anonymous
Not applicable
> Why does this not work?

VBA will not filter on group code 410. Here's an alternative approach.
Pass it your selection set and the name of the layout from which you
want to select objects.

Public Sub FilterLayout(ss As AcadSelectionSet, layoutName As String)

Dim max As Long, objArray() As AcadEntity

max = -1

For i = 0 To ss.Count - 1
If
LCase(acadApp.ActiveDocument.ObjectIdToObject(ss.Item(i).OwnerID).Layo
ut.Name) _
<> LCase(layoutName) Then
max = max + 1
ReDim Preserve objArray(0 To max)
Set objArray(max) = ss.Item(i)
End If
Next

ss.RemoveItems objArray

End Sub

--
http://www.acadx.com
0 Likes
Message 4 of 9

Anonymous
Not applicable
"Chuck Gabriel" wrote in message
news:EB28007372F1017067219B7D3B01A696@in.WebX.maYIadrTaRb...
> I think you need to enclose your two filter criteria in an "AND" structure
like this.
>
> dim fType(3) as Integer
> dim fData(3) as Variant
>
> fType(0) = -4
> fData(0) = " > fType(1) = 410
> fData(1) = ThisDrawing.ActiveLayout.Name
> fType(2) = 0
> fData(2) = "INSERT"
> fType(3) = -4
> fData(3) = "AND>"
> ssetObj.Select acSelectionSetAll, , , fType, fData

I tried that, but it seems the -4 groups are not really needed.
>
> Incidentally, I don't follow why you are assigning your filter array to a
second set of
> variables (groupCode and dataCode).

I copied the initial code from an online sample

>
> Also, if you take a look on AcadX.com at Frank Oquendo's BuildFilter sub,
I think you will
> find that it makes creating selection set filters a lot easier. With
BuildFilter, the
> previous code could be abbreviated to the following.
>
> dim fType() as Integer
> dim fData() as Variant
>
> BuildFilter fType, fData, -4, " 0, "INSERT", -4,
> "AND>"
> ssetObj.Select acSelectionSetAll, , , fType, fData
>
> Happy Hunting.
>
> Chuck Gabriel
>
>
> "Geuko#" wrote in message
> news:3D6A4EC88E866A9C276F16640BBFCF6B@in.WebX.maYIadrTaRb...
> > Hi,
> >
> > Why does this not work?
> > I'm trying to filter all blocks within the active layout. as soon as i
try
> > to use the common dxf group 410 to filter Blocks on the current Layout
the
> > selectionset is empty.
> >
> > Dim gpCode(1) As Integer
> > Dim dataValue(1) As Variant
> >
> >
> > gpCode(0) = 410 ' common group for Layout
> > gpCode(1) = 0
> >
> > dataValue(0) = ThisDrawing.ActiveLayout.Name ' current Layout Name
> > dataValue(1) = "INSERT" ' value for Group 2
> >
> > Dim groupCode As Variant, dataCode As Variant
> > groupCode = gpCode
> > dataCode = dataValue
> >
> > ssetObj.Select acSelectionSetAll, , , groupCode, dataCode
> >
> > --
> >
> > --
> > Geuko Rooseboom
> > Decoprojekt
> > +31-315-270 856
> > g.rooseboom@decoprojekt.nl
> >
> >
>
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
Thanks for your approuch, i tried looping through the selection set but i
could not find a way to get the layout property.

But the question that bothers me is why this is not possilble in VBA, is it
AutoCAD being inconsequent?


Geuko

"Frank Oquendo" wrote in message
news:9F26E82D19455F6F7EAF18857EA1C3F0@in.WebX.maYIadrTaRb...
> > Why does this not work?
>
> VBA will not filter on group code 410. Here's an alternative approach.
> Pass it your selection set and the name of the layout from which you
> want to select objects.
>
> Public Sub FilterLayout(ss As AcadSelectionSet, layoutName As String)
>
> Dim max As Long, objArray() As AcadEntity
>
> max = -1
>
> For i = 0 To ss.Count - 1
> If
> LCase(acadApp.ActiveDocument.ObjectIdToObject(ss.Item(i).OwnerID).Layo
> ut.Name) _
> <> LCase(layoutName) Then
> max = max + 1
> ReDim Preserve objArray(0 To max)
> Set objArray(max) = ss.Item(i)
> End If
> Next
>
> ss.RemoveItems objArray
>
> End Sub
>
> --
> http://www.acadx.com
>
>
0 Likes
Message 6 of 9

Anonymous
Not applicable
Hey Geuko,

I've been wrestling with the exact same problem all day today. Dxf group code
410. It works in lisp like, (ssget "X" '((0. "INSERT")(2 . "myblock")(410 .
"Layout1"))). I'm sure you've tried this. There is a vba function that passes
lisp to the acad command line. I'm going to try and pass the above lisp code
and then grab the "previous" selection set in VBA. Just an idea. I'll let you
know if it works.

Eric

Geuko# wrote:

> Thanks for your approuch, i tried looping through the selection set but i
> could not find a way to get the layout property.
>
> But the question that bothers me is why this is not possilble in VBA, is it
> AutoCAD being inconsequent?
>
> Geuko
>
> "Frank Oquendo" wrote in message
> news:9F26E82D19455F6F7EAF18857EA1C3F0@in.WebX.maYIadrTaRb...
> > > Why does this not work?
> >
> > VBA will not filter on group code 410. Here's an alternative approach.
> > Pass it your selection set and the name of the layout from which you
> > want to select objects.
> >
> > Public Sub FilterLayout(ss As AcadSelectionSet, layoutName As String)
> >
> > Dim max As Long, objArray() As AcadEntity
> >
> > max = -1
> >
> > For i = 0 To ss.Count - 1
> > If
> > LCase(acadApp.ActiveDocument.ObjectIdToObject(ss.Item(i).OwnerID).Layo
> > ut.Name) _
> > <> LCase(layoutName) Then
> > max = max + 1
> > ReDim Preserve objArray(0 To max)
> > Set objArray(max) = ss.Item(i)
> > End If
> > Next
> >
> > ss.RemoveItems objArray
> >
> > End Sub
> >
> > --
> > http://www.acadx.com
> >
> >
0 Likes
Message 7 of 9

Anonymous
Not applicable


Geuko,

Frank Oquendo's code works. I tried it my self and it solved my problem.

This line of his code grabs the layout name of the entity passed to
it:

ThisDrawing.ObjectIdToObject(MY_ACAD_ENTITY.OwnerID).Layout.Name

Sincerely,

Eric

Geuko# wrote:

Hi,

Why does this not work?

I'm trying to filter all blocks within the active layout. as soon as
i try

to use the common dxf group 410 to filter Blocks on the current Layout
the

selectionset is empty.

    Dim gpCode(1) As Integer

    Dim dataValue(1) As Variant

    gpCode(0) = 410 ' common group for Layout

    gpCode(1) = 0

    dataValue(0) = ThisDrawing.ActiveLayout.Name ' current
Layout Name

    dataValue(1) = "INSERT" ' value for Group 2

    Dim groupCode As Variant, dataCode As Variant

    groupCode = gpCode

    dataCode = dataValue

    ssetObj.Select acSelectionSetAll, , , groupCode,
dataCode

--

--

Geuko Rooseboom

Decoprojekt

+31-315-270 856

g.rooseboom@decoprojekt.nl


0 Likes
Message 8 of 9

Anonymous
Not applicable
This code is OK.
1.- Open "SeleccionFiltrosLayout.dwg"
2.- Alt+F11 for IDE VBA
3.- Import Module "SelLayoutObject.bas"
4.- Run Sub "ListaObjetosLayouts"

** Attach Files of sample in "SeleccionFiltro.rar"

The CODE:
'**********************************************************************************
Public Sub ListaObjetosLayouts()
Dim cadena As String
Dim oL As AcadLayout
For Each oL In ThisDrawing.Layouts
cadena = cadena & DameObjetosLayout(oL.Name)
Next
MsgBox cadena
End Sub


Public Function DameObjetosLayout(queL As String) As String
Dim resultado As String
'' Definir "ssel" como el objeto selección y crearlo. Si ya existe
'' error y lo cojetos de la colección 'SelectionSets'
Dim ssel As AcadSelectionSet

On Error Resume Next
Set ssel = ThisDrawing.SelectionSets.Add("alberto")

If Err.Number <> 0 Then
Set ssel = ThisDrawing.SelectionSets.Item("alberto")
End If

'' Lo vaciamos, por si ya tenía objetos
ssel.Clear

'' Definir las variables para el código y valor del filtro
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
gpCode(0) = 410
dataValue(0) = queL

'' Pasamos estos objetos a otros 'Variant'
Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue

ssel.Select acSelectionSetAll, , , groupCode, dataCode
resultado = "Hay ( " & ssel.Count & " ) Objetos seleccionados en Layout ( " & queL & " )" & vbCrLf
ssel.Clear
Set ssel = Nothing
DameObjetosLayout = resultado
End Function
'**********************************************************************************
0 Likes
Message 9 of 9

Anonymous
Not applicable
Thats a known limitation of vba
you cant' use the 410 code in filter list (like you can in lisp)

google the archives for confirmation of this and previous discussions

you have to filter for your object then test it's layout owner

or to get the result in your code sample you would do
resultado = "Hay ( " & Layouts.Item("quel").Block.Count & " ) Objetos en
Layout ( " & queL & " )" & vbCrLf

hth
mark

wrote in message news:6212391@discussion.autodesk.com...
This code is OK.
1.- Open "SeleccionFiltrosLayout.dwg"
2.- Alt+F11 for IDE VBA
3.- Import Module "SelLayoutObject.bas"
4.- Run Sub "ListaObjetosLayouts"

** Attach Files of sample in "SeleccionFiltro.rar"

The CODE:
'***************************************************************************
*******
Public Sub ListaObjetosLayouts()
Dim cadena As String
Dim oL As AcadLayout
For Each oL In ThisDrawing.Layouts
cadena = cadena & DameObjetosLayout(oL.Name)
Next
MsgBox cadena
End Sub


Public Function DameObjetosLayout(queL As String) As String
Dim resultado As String
'' Definir "ssel" como el objeto selección y crearlo. Si ya existe
'' error y lo cojetos de la colección 'SelectionSets'
Dim ssel As AcadSelectionSet

On Error Resume Next
Set ssel = ThisDrawing.SelectionSets.Add("alberto")

If Err.Number <> 0 Then
Set ssel = ThisDrawing.SelectionSets.Item("alberto")
End If

'' Lo vaciamos, por si ya tenía objetos
ssel.Clear

'' Definir las variables para el código y valor del filtro
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
gpCode(0) = 410
dataValue(0) = queL

'' Pasamos estos objetos a otros 'Variant'
Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue

ssel.Select acSelectionSetAll, , , groupCode, dataCode
resultado = "Hay ( " & ssel.Count & " ) Objetos seleccionados en Layout
( " & queL & " )" & vbCrLf
ssel.Clear
Set ssel = Nothing
DameObjetosLayout = resultado
End Function
'***************************************************************************
*******
0 Likes