Working with vl- vla- vlax- functions

Hi there,
I've used LISP for a number of years. I would now like to have a better understanding of vl- vla- vlax- functions. The help files list the functions but not their parameters.
I am currently looking to use the vla-get-layerstate and vla-put-layerstate functions.
At the start of my LISP routine I would like to save the current layer state then restore it again at the end of my LISP routine.
I would appreciate any feedback and/or direction (website, book, etc) that might help me better understand these functions and thereby make more use of them.
Thank you in advance for your help.
--
Phillip

Comments

  • Dear Philippe,

    just those (vla-get/put-layerstate) functions are not yet available with Bricscad -
    the LayerSTate interface is not exposed to COM, so Lisp can not access this ...

    BUT
    we have a workaround solution - see Bricscads ReleaseNotes.htm file :-)

    (vl-layerstates-list)
    (vl-layerstates-has lstate)
    (vl-layerstates-setpropertymask lstate bitFlags)
    (vl-layerstates-getpropertymask lstate)
    (vl-layerstates-setdescription lstate description)
    (vl-layerstates-getdescription lstate)
    (vl-layerstates-rename oldName newName)
    (vl-layerstates-delete lstate)
    (vl-layerstates-save lstate [bitFlags [VportEname]])
    (vl-layerstates-restore lstate [bitFlags [VportEname [undefAction]])

    this means, Bricscad Lisp provides similar functionality as (vl-) functions - so you might try this;

    These functions are not available in AutoCAD, of course ... there, you have (vla-get/put.layerstate).

    To get knowledge on how (vla) functions operate, it is best to use a COM viewer, and open the COM TypeLibrary,
    there you will see the "objects" with their "properties" and "methods", and the arguments;
    i.e. VB/VBA have such ObjectViewer built-in, Microsoft also provides tools like "OleView.exe" which allow to open
    and view *.tlb files (and to save as .IDL text file, so you have a good reference then)

    there are also a large number of websites around AutoLISP, also for advanced features like COM support
    (AfraLisp i.e.)

    Usually, the syntax is
    (vla-get/put- object [arguments])
    (vla- object [arguments]

    Similar, the generic functions are like
    (vlax-get/put-property object [arguments])
    (vlax-invoke-method object [arguments])

    the  < and > brackets are only to point to the particular property/method name - of course, to be omitted :-)

    I hope this is fine for beginning ?
    Many greetings !
  • That's wonderful. Thank you for your help and the very timely reply.

    --

    Phillip

  • For an explanation of the Bricscad layerstate functions (look for names without 'vl-'):
    http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-69d0.htm

    Tutorial in English:
    Search the WWW for "The Visual LISP Developers Bible.pdf".
    This not the best book out there, but it will get you started.

    Tutorial in German:
    http://www.visuallisp-tutorial.mapcar.net/

    References:
    An alternative to Torsten's suggestion:
    In the Bricscad Help look for "The Bricscad automation object model"
    And of course:
    http://docs.autodesk.com/ACD/2011/ENU/landing.html
    http://www.kxcad.net/autodesk/autocad/AutoCAD_ActiveX_and_VBA_Reference/index.htm
  • Dear Roy,
    I didn't notice that AutoCAD 2011 has new Lisp functions for layerstates ...
    so I have to qucikly implement those as well :-)
    Most of them are already there, as (vl-layerstate-...), so this work is mainly redirecting,
    besides new new functions.

    Many greetings & many thanks !
  • Hi Phillip,

    I would give a thumbs up on Afralisp. You could also check out the swamp if you want to make specific queries. There is a dearth of books on the subject of Visual lisp (or AutoLISP), which is more a reflection of the regard that it is held in by AutoDESK, it is kept alive by the affection of its users, and the massive amount of existing lisp routines out there. The Visual LISP Developer's Bible is available for Kindle (you don't need to have a Kindle) and is pretty cheap in that format, otherwise look for second hand. I think it is a good introduction considering the lack of other material available on the subject.

    To elaborate on Torsten's comment on using the COM viewer. You can access this from Bricscad by opening the VBA editor (press Alt + F11, or type _VBAIDE), then select the Object Browser button. See attached screen grab for reference.

    I also like to query objects from the command line, which you can do by using the following code:
    [code](defun dump (obj)
        (vlax-dump-object obj T)
    )
    (defun c:dump ()
     (vl-load-com)
        (setq *MyDump* (vlax-ename->vla-object (car (entsel))))
        (dump *MyDump*)
        (princ "\nObject name saved to *MyDump*")
     (textscr)
    (princ)
    )[/code]

    This will return the properties and methods for the selected object, or you can call directly for non selectable objects. For example:
    [code](dump (vlax-get-Acad-Object))[/code]

    Regards,

    Jason Bourhill

    CAD Concepts


    imageBricscadObjectBrowser.png
  • Thank you everyone for your help.
    --
    Phil
This discussion has been closed.