Robert
For the yes/no boxes, you code just needs to be the following, as the value
is either "True" or "False":
layer.Plottable = rs.fields(5).value
For the linetype, look at the AutoCAD Linetypes collection. On of the
methods of this collection is "load" that will take a linetype name and a
file to load it from. No DXF codes!!!! Just linetype names. To set the
linetype of a layer, it is just:
layer.linetype = "layer name"
You should get the linetype name and make sure that it is loaded, if not
load it before you set a layer to it. Watch out for the "CONT" linetype in
your database.
For the capitalization, use UCase(string), a VBA function that will force
upper case on the layer name. (check out "VB & VBA in a Nutshell", by Paul
Lomax, an O'Reilly book, for a great VBA resource guide)
For the order, you could have Access sort the layers when it makes the
record set, but unless this is a problem, I won't worry about it, the order
that layers are made shouldn't make any difference.
Cheers,
Peter Funk
API Product Manager
Building Industry Group
Autodesk, Inc.
FYI, if your field names didn't have spaces, then you could use the
following syntax:
layer.Plottable = rs!PlotLayer
"Robert Asher"
wrote in message
news:16DFA4E65B6C7ACF4C25DD949B611CCB@in.WebX.maYIadrTaRb...
> Peter, thanks again for your great help. I've got your routine working.
Now
> a couple more questions:
>
> This segment doesn't work right. My plot settings in the Access database
are
> yes/no checkboxes. What would the code be to get the checkboxes to be
read?
> This will be useful to apply to many other routines where I'm pulling
> department specific layers, as I'm using yes/no checkboxes to determine
what
> departments a specific layer is associated with.
>
> If rs.fields(5).Value <> "" Then
> layer.Plottable = False
>
> One more question, if I may: To have the macro restore linetypes off the
> database, how does that get coded? The fields in the database are
currently
> text, but I think ACAD would have to have those linetypes restored by DXF
> number? Perhaps I code a number key related to the text content of the
> linetype? (ie CONT = 1 (or whatever the DXF code is...))
>
> Thanks
>
> --
> Robert Asher
> Staff Architect
> George Butler Associates, Inc.
> "Peter Funk - Autodesk, Inc" wrote in message
> news:7B774217CE8D4A20F3EBBE3D51094379@in.WebX.maYIadrTaRb...
> > Robert,
> >
> > It's pretty easy, here is a little code that will just dump your
database
> > into the drawing as layers. The key is that you need to include a
> reference
> > to the DAO 3.6 Type Library inside your VBA project. This example is
very
> > hard coded. Notice that I'm using rs.fields(1) to get at the first
column
> in
> > your database. This just will walk the database and add the layers. It
> > should get you started working with the Access database and the AutoCAD
> > layer table.
> >
> > Cheers,
> >
> > Peter
> >
> >
> > Public Sub layerDump()
> >
> > Dim db As Database
> > Dim rs As recordSet
> > Dim fields As fields
> > Dim name As String
> > Dim cLayers As AcadLayers
> > Dim layer As AcadLayer
> > Dim layername As String
> >
> > Set cLayers = ThisDrawing.Layers
> >
> > name = "c:\Layer.mdb"
> >
> > Set db = OpenDatabase(name)
> > Set rs = db.OpenRecordset("Master AIA Layer Table")
> >
> > With rs
> > .MoveLast
> > .MoveFirst
> > Do While True
> > .MoveNext
> > If .EOF Then
> > Exit Do
> > End If
> > layername = rs.fields(1).Value
> > If Left(layername, 1) <> "*" Then
> > Set layer = cLayers.Add(layername)
> > If rs.fields(4).Value <> "" Then
> > layer.Color = rs.fields(4).Value
> > End If
> > End If
> > Loop
> > End With
> > rs.Close
> > db.Close
> > Set rs = Nothing
> > Set db = Nothing
> > End Sub
> >
> >
> >
>
>