Layerstatemanager setdatabase method not working in A2004

Discussion in 'AutoCAD' started by James Maeding, Dec 19, 2003.

  1. I opened a blank drawing, saved it to a name and reopened.
    Then in a lisp I am running this code:

    (setq layerstateobject (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcadLayerStateManager"))
    (vla-setdatabase layerstateobject (vla-get-database (vla-get-activedocument (vlax-get-acad-object))))

    It errors out on me on the second line. I inspected all the variables with vlisp and they all return valid objects.
    I tried catch-all-apply for the get database method and all tricks I know for objects with no luck.
    This worked fine in A2002, not sure if something changed I should be aware of.
    thx
    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Dec 19, 2003
    #1
  2. oh, wow, I just noticed the way to get the object changed slightly in 2004, now you have to use:
    (setq layerstateobject (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcadLayerStateManager.16"))

    good thing the VBA object browser is available and had an example for that method, the lisp help did not mention this.

    James Maeding <>
    |>I opened a blank drawing, saved it to a name and reopened.
    |>Then in a lisp I am running this code:
    |>
    |>(setq layerstateobject (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcadLayerStateManager"))
    |>(vla-setdatabase layerstateobject (vla-get-database (vla-get-activedocument (vlax-get-acad-object))))
    |>
    |>It errors out on me on the second line. I inspected all the variables with vlisp and they all return valid objects.
    |>I tried catch-all-apply for the get database method and all tricks I know for objects with no luck.
    |>This worked fine in A2002, not sure if something changed I should be aware of.
    |>thx
    |>James Maeding
    |>Civil Engineer/Programmer

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Dec 19, 2003
    #2
  3. thanks for the reply, its good to see someone else ran into this...

    "James Buzbee" <>
    |>;;; This routine returns a pointer to the LayerStateManager - it works in
    |>2000 - 2004.
    |>(defun jb:GetLayerObject (/ file ret)
    |> (if (< (atoi (getvar "AcadVer")) 16)
    |> (setq file "AutoCAD.AcadLayerStateManager")
    |> (setq file "AutoCAD.AcadLayerStateManager.16"));<<<<<<2004
    |>
    |> (setq ret (vla-GetInterfaceObject
    |> (vlax-get-acad-object)
    |> file))
    |> ret)
    |>
    |>jb
    |>

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Dec 19, 2003
    #3
  4. James Maeding

    James Buzbee Guest

    ;;; This routine returns a pointer to the LayerStateManager - it works in
    2000 - 2004.
    (defun jb:GetLayerObject (/ file ret)
    (if (< (atoi (getvar "AcadVer")) 16)
    (setq file "AutoCAD.AcadLayerStateManager")
    (setq file "AutoCAD.AcadLayerStateManager.16"));<<<<<<2004

    (setq ret (vla-GetInterfaceObject
    (vlax-get-acad-object)
    file))
    ret)

    jb
     
    James Buzbee, Dec 19, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.