VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Collection

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
408 Views, 9 Replies

Custom Collection

Hi all,
I wish to make my own collection through VBA. Can I do it?
please, help me.
Rgds
Hector
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

There are many types of collections...
What specifically?
Message 3 of 10
Anonymous
in reply to: Anonymous

I want to build a collection based on drawing's objects, but of several types (circles, lines, polyline....) and layers.
Message 4 of 10
Anonymous
in reply to: Anonymous

Here is a Collection sample. Check out a Scripting.Dictionary also.
To add the layers in the drawing just iterate ThisDrawing.Layers
similar to the way I did the Layouts.

[code]
Sub stub()
Dim coll As New Collection
Dim layout As AcadLayout
Dim ent As AcadEntity

'add all entities in all layouts to a collection
For Each layout In ThisDrawing.Layouts
For Each ent In layout.Block
coll.Add ent, ent.Handle
Next ent
Next layout

Dim entBlock As AcadBlock

'print all entities in the collection
'and the block they reside in
For Each ent In coll
Set entBlock = ThisDrawing.ObjectIdToObject(ent.OwnerID)
Debug.Print ent.ObjectName & " " & entBlock.Name
Next ent

End Sub
[/code]

--
gl - Paul
wrote in message news:5188195@discussion.autodesk.com...
I want to build a collection based on drawing's objects, but of several
types (circles, lines, polyline....) and layers.
Message 5 of 10
Anonymous
in reply to: Anonymous

Paul, thank you very much. My problem is solved !!
Message 6 of 10
Anonymous
in reply to: Anonymous

but how to use a collection,
if it is save as a part of a drawing and will be got ever since
thanks


"Paul Richardson" wrote in message
news:5188242@discussion.autodesk.com...
Here is a Collection sample. Check out a Scripting.Dictionary also.
To add the layers in the drawing just iterate ThisDrawing.Layers
similar to the way I did the Layouts.

[code]
Sub stub()
Dim coll As New Collection
Dim layout As AcadLayout
Dim ent As AcadEntity

'add all entities in all layouts to a collection
For Each layout In ThisDrawing.Layouts
For Each ent In layout.Block
coll.Add ent, ent.Handle
Next ent
Next layout

Dim entBlock As AcadBlock

'print all entities in the collection
'and the block they reside in
For Each ent In coll
Set entBlock = ThisDrawing.ObjectIdToObject(ent.OwnerID)
Debug.Print ent.ObjectName & " " & entBlock.Name
Next ent

End Sub
[/code]

--
gl - Paul
wrote in message news:5188195@discussion.autodesk.com...
I want to build a collection based on drawing's objects, but of several
types (circles, lines, polyline....) and layers.
Message 7 of 10
Anonymous
in reply to: Anonymous

no a Collection is not saved with the drawing. An XRecord
is saved in the drawing, or you an use an external flat file or
database.


--
gl - Paul
"youngman" wrote in message
news:5188916@discussion.autodesk.com...
but how to use a collection,
if it is save as a part of a drawing and will be got ever since
thanks


"Paul Richardson" wrote in message
news:5188242@discussion.autodesk.com...
Here is a Collection sample. Check out a Scripting.Dictionary also.
To add the layers in the drawing just iterate ThisDrawing.Layers
similar to the way I did the Layouts.

[code]
Sub stub()
Dim coll As New Collection
Dim layout As AcadLayout
Dim ent As AcadEntity

'add all entities in all layouts to a collection
For Each layout In ThisDrawing.Layouts
For Each ent In layout.Block
coll.Add ent, ent.Handle
Next ent
Next layout

Dim entBlock As AcadBlock

'print all entities in the collection
'and the block they reside in
For Each ent In coll
Set entBlock = ThisDrawing.ObjectIdToObject(ent.OwnerID)
Debug.Print ent.ObjectName & " " & entBlock.Name
Next ent

End Sub
[/code]

--
gl - Paul
wrote in message news:5188195@discussion.autodesk.com...
I want to build a collection based on drawing's objects, but of several
types (circles, lines, polyline....) and layers.
Message 8 of 10
Anonymous
in reply to: Anonymous

Thanks a lot.

so if i want to make use of collectionlike objects, i have to use,as you
said,
XRecord,xdata,dictionary,group , or , database ,
is that so,

best regards





"Paul Richardson" wrote in message
news:5189008@discussion.autodesk.com...
no a Collection is not saved with the drawing. An XRecord
is saved in the drawing, or you an use an external flat file or
database.


--
gl - Paul
"youngman" wrote in message
news:5188916@discussion.autodesk.com...
but how to use a collection,
if it is save as a part of a drawing and will be got ever since
thanks


"Paul Richardson" wrote in message
news:5188242@discussion.autodesk.com...
Here is a Collection sample. Check out a Scripting.Dictionary also.
To add the layers in the drawing just iterate ThisDrawing.Layers
similar to the way I did the Layouts.

[code]
Sub stub()
Dim coll As New Collection
Dim layout As AcadLayout
Dim ent As AcadEntity

'add all entities in all layouts to a collection
For Each layout In ThisDrawing.Layouts
For Each ent In layout.Block
coll.Add ent, ent.Handle
Next ent
Next layout

Dim entBlock As AcadBlock

'print all entities in the collection
'and the block they reside in
For Each ent In coll
Set entBlock = ThisDrawing.ObjectIdToObject(ent.OwnerID)
Debug.Print ent.ObjectName & " " & entBlock.Name
Next ent

End Sub
[/code]

--
gl - Paul
wrote in message news:5188195@discussion.autodesk.com...
I want to build a collection based on drawing's objects, but of several
types (circles, lines, polyline....) and layers.
Message 9 of 10
Paul Richardson
in reply to: Anonymous

yes...
Message 10 of 10
Anonymous
in reply to: Anonymous

thanks 
wrote in message news:5191711@discussion.autodesk.com...
yes...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost