Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using dictionaries...

0 views
Skip to first unread message

Tim Grote

unread,
Mar 28, 1999, 3:00:00 AM3/28/99
to

Testing out A2K, I'm trying to use a dictionary to store a table of layers
that I can access by something other than their name. But when I try to add
a layer to a dictionary, the code fails on the object name the code follows:

'===========================================================================
gbDebug = True
On Error Resume Next
If ThisDrawing.Dictionaries("IDALayers") Is Nothing Then
Set dicIDALayers = ThisDrawing.Dictionaries.Add("IDALayers")
On Error GoTo 0
Set laySprink = dicIDALayers.AddObject("sprink",
"AcDbLayerTableRecord")<===failure
MsgBox "Just made IDALayers dictionary!"
Exit Sub
End If
'===========================================================================

the error is "AcRxClassName entry is not in the system registry"


From the documentation it looks like perhaps dictionaries should only be
used for custom objects. Which explains the failure. If so, is there any
type of collection I can keep with the drawing to accomplish this?
Perhaps there is a way to access layers through the layer collection by some
sort of read-write key(other than the name) any ideas??


Albert Szilvasy

unread,
Mar 28, 1999, 3:00:00 AM3/28/99
to
You cannot store layer table records in a dictionary. You need to create an
xrecord in the dictionary which in turn can reference the layer table
record.

Albert

Tim Grote <TimG...@worldnet.att.net> wrote in message
news:7dlj3c$bh...@adesknews2.autodesk.com...

AEI Staff

unread,
Mar 29, 1999, 3:00:00 AM3/29/99
to
Albert,

thanks for the tip, but now another question: How would I implement xrecords in
this fashion?

I have read the documentation in the help file on xrecords, but I'm still fairly
lost. Would I add one xrecord for each layer, or just to the layer table. Where
would I create this layer table?

For reference: I want to access a layer by something other than the name.
Whatever key I use, I would like it to be read write. Perhaps I could create
collection and imbed it in the drawing. This seems like it might cause a bit of
overhead though.

Thanks

Tim Grote


Albert Szilvasy

unread,
Mar 30, 1999, 3:00:00 AM3/30/99
to
Hi there,

Here's some AutoCAD 2000 script that shows what I was suggesting. This
creates an xrecord in the named object dictionary that holds an array of
object ids. Object Ids of the layers.

Cheers,
Albert

Public Sub test()
Dim oDict As AcadDictionary
Set oDict = ThisDrawing.Dictionaries.Add("AsdkDict")
Dim oX As AcadXRecord
Set oX = oDict.AddXRecord("Layers")
Dim dtype() As Integer
Dim dvalue() As Variant
Dim nLayers As Integer
nLayers = ThisDrawing.Layers.Count()
ReDim dtype(nLayers)
ReDim dvalue(nLayers)
Dim oLayer As AcadLayer
Dim i As Integer
i = 0
For Each oLayer In ThisDrawing.Layers
dtype(i) = 1005
dvalue(i) = oLayer.Handle
i = i + 1
Next oLayer
oX.SetXRecordData dtype, dvalue
End Sub

AEI Staff <aeis...@aquaengr.com> wrote in message
news:36FFECE1...@aquaengr.com...

0 new messages