Layerstatemanager setdatabase method not working in A2004

James Maeding

Usenet Archive
Joined
Jul 7, 2003
Messages
331
Reaction score
0
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
 
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
 
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
 
;;; 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
 

Latest threads

Back
Top