The form I work for has multiple departments and we share drawings on a daily basis. The way we currently work is the foundation dept. completes their drawing them I open his drawing and cut & paste whats visable into my drawing. We have looked at xrefs but it doesn't work. Their drawings have extra layers I don't need. If I try to use lisp to automatically insert their drawings into mine all layer are inserted and turned on. If I could read their current layer status without actually opening their drawing then I could turn off those unwanted layers or even purge them. I have the following which will retreive the layers from a drawing but I don't know how to get it's status. Any help?
(setq odbx (vla-getinterfaceobject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16"))
(vla-open odbx sfilename)
(setq lyrs (vla-get-layers odbx))
Hi,
I am not sure if I understand completely what you need. In any case maybe this example will help. It does open the drawing in memory and gets properties from each of the layers. (I was using AutoCAD 2011)
(DeFun c:LProps (/ odbx sfilename lyrs layer properties)
(vl-load-com)
(setq odbx (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument.18"
)
)
(setq sfilename "c:\\wbtest.dwg")
(vla-open odbx sfilename)
(setq lyrs (vla-get-layers odbx))
(vlax-for layer lyrs
(SetQ
properties
(Append
properties
(List
(vla-get-objectid layer)
(vla-get-Color layer)
(vla-get-Freeze layer)
(vla-get-LayerOn layer)
(vla-get-Linetype layer)
(vla-get-Lineweight layer)
(vla-get-PlotStyleName layer)
(vla-get-Plottable layer)
(vla-get-ViewportDefault layer)
)
)
)
)
(princ properties)
; close the document
(if odbx
(progn
(vlax-release-object odbx)
(setq odbx nil)
)
)
(princ)
)
Wayne Brill
Autodesk Developer Network
Thanks Wayne. That's exactly what I'm looking for. Can't wait to give it a try.
Tried it and I get a list of layer stuff but the layer name is just a bunch of numbers. How do I get the actual name?
-3257232 7 :vlax-false :vlax-true CONTINUOUS -3 Color_7 :vlax-true :vlax-false
Hi,
To get the layer name use:
(vla-get-name layer)
Add vla-get-name at the same place as where the other properties are being retrieved. Those numbers are the ObjectId of the layer. (returned from (vla-get-objectid layer).
Thanks,
Wayne Brill
Autodesk Developer Network
Thanks Wayne. That did it. I guess I'll need to learn a little more about visual lisp.
Can't find what you're looking for? Ask the community or share your knowledge.