Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
spykat
Posts: 180
Registered: ‎08-13-2003
Message 1 of 6 (201 Views)

retrieve layer status without opening the drawing.

201 Views, 5 Replies
06-29-2011 07:57 AM

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))

ADN Support Specialist
wayne.brill
Posts: 230
Registered: ‎08-25-2004
Message 2 of 6 (189 Views)

Re: retrieve layer status without opening the drawing.

06-29-2011 12:57 PM in reply to: spykat

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
spykat
Posts: 180
Registered: ‎08-13-2003
Message 3 of 6 (183 Views)

Re: retrieve layer status without opening the drawing.

06-29-2011 01:04 PM in reply to: wayne.brill

Thanks Wayne. That's exactly what I'm looking for. Can't wait to give it a try.

Distinguished Contributor
spykat
Posts: 180
Registered: ‎08-13-2003
Message 4 of 6 (164 Views)

Re: retrieve layer status without opening the drawing.

06-29-2011 02:51 PM in reply to: spykat

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

ADN Support Specialist
wayne.brill
Posts: 230
Registered: ‎08-25-2004
Message 5 of 6 (154 Views)

Re: retrieve layer status without opening the drawing.

06-29-2011 04:32 PM in reply to: spykat

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
spykat
Posts: 180
Registered: ‎08-13-2003
Message 6 of 6 (145 Views)

Re: retrieve layer status without opening the drawing.

06-30-2011 07:06 AM in reply to: wayne.brill

Thanks Wayne. That did it. I guess I'll need to learn a little more about visual lisp.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.