SetDatabase Method (ActiveX)

Associates an AutoCAD database with the LayerStateManager object.

Supported platforms: Windows only

Signature

VBA:

object.SetDatabase Database
object

Type: LayerStateManager

The object this method applies to.

Database

Access: Input-only

Type: Database

The Database object to be associated with the LayerStateManager object.

Return Value (RetVal)

No return value.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_SetDatabase()
    ' The following code saves the color and linetype settings
    ' of the current layer. It uses the SetDatabase method to
    ' associate the current drawing database with the
    ' LayerStateManager object. 

    Dim oLSM As AcadLayerStateManager

    ' Access the LayerStateManager object
    Set oLSM = ThisDrawing.Application. _
       GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

    ' Associate the current drawing database with LayerStateManager
    oLSM.SetDatabase ThisDrawing.Database

    oLSM.Save "ColorLinetype", acLsColor + acLsLineType

End Sub

Visual LISP:

(defun c:Example_SetDatabase()
    ;; The following code saves the color and linetype settings
    ;; of the current layer. It uses the SetDatabase method to
    ;; associate the current drawing database with the
    ;; LayerStateManager object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Access the LayerStateManager object
    (setq oLSM (vla-GetInterfaceObject acadObj "AutoCAD.AcadLayerStateManager.20"))

    ;; Associate the current drawing database with LayerStateManager
    (vla-SetDatabase oLSM (vla-get-Database doc))

    (vla-Save oLSM "ColorLinetype" (+ acLsColor acLsLineType))
)