Author Topic: VLE lisp functions in Bricscad  (Read 3421 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8843
  • AKA Daniel
VLE lisp functions in Bricscad
« on: May 15, 2012, 07:10:48 AM »
Anyone play with the new VLE lisp functions in Bricscad
see http://www.cadconcepts.co.nz/vle-lisp-function-summary/
and http://blog.bricsys.com/2012/04/preview-new-vle-functions-in-lisp-in.html

VLE-END-TRANSACTION
VLE-START-TRANSACTION
VLE-SELECTIONSET->LIST

these look interesting  :-)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8843
  • AKA Daniel
Re: VLE lisp functions in Bricscad
« Reply #1 on: May 15, 2012, 08:02:49 AM »
pretty snappy

Code: [Select]
(defun c:Test (/)
  (setq elist (VLE-SELECTIONSET->LIST (ssget)))
  (VLE-START-TRANSACTION)
  (foreach item elist
    (VLE-ENTMOD 8 item "1_8_TEXT")
  )
  (VLE-END-TRANSACTION)
)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: VLE lisp functions in Bricscad
« Reply #2 on: May 15, 2012, 12:18:23 PM »
It is nice. Especially as it's supposed to become a free addon for other CADs as well.  ;D

Noticed though the comments on that blog page: the vle-remove-all function is superfluous as the existing VLisp vl-remove does exactly the same thing, only faster.

Some of the others might be very efficient though. Especially those extracting and/or modifying only the dxf code you wanted instead of the entire list as entget/entmod does. Should speed up these things drastically - perhaps even faster than the vla methods since there's no need to vlax-ename->vla-object anymore. I wonder if this would get around the issue of annotative text scaling each time an entmod is performed on it.

Some things which might also help is (e.g.) if the vle-entget could retrieve more than one code at a time. E.g. if the dxf code is a list, then retrieve all values assoc'ed in that list. Same goes for the vle-entmod. And if those codes with defaults could be included in the vle-entget (e.g. bylayer colour/linetype) it might save yet some more coding.

Not too sure about the predicator functions for variable type though. Is (vle-integerp obj) a lot faster than simply typing (= (type obj) 'Int)? It's not a lot of saving on keypresses.

The vle-file->list seems awesome! Finally a full read of a file in one go! Must be a lot faster than reading character for character / line by line! How does it handle binary files? Could it be set to keep all \N \R combinations at the end of each line?

One function I can suggest is a vle-insert: Would allow an item (or list of items) to be inserted at an index position. E.g.
Code - Auto/Visual Lisp: [Select]
  1. (setq lst '(1 2 3 4 5 6 7))
  2. (vle-insert lst 4 'A) ;==> (1 2 3 4 A 5 6 7)
  3. (vle-insert lst 3 '(A B)) ;==> (1 2 3 A B 4 5 6 7)

And a whole set of functions which would be a great help is some decent string handling routines which works on UniCode values as well (e.g. sending unicode strings to the vl-string-* functions result in "?" wherever non-ANSI characters are placed.) Also some sort of RegularExpression search / replace would be awesome!
« Last Edit: May 15, 2012, 12:28:44 PM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Daniel Eiszele

  • Newt
  • Posts: 85
Re: VLE lisp functions in Bricscad
« Reply #3 on: May 15, 2012, 10:32:26 PM »
Before you get too excited. These functions will only provide the speed bonuses on bricscad. On other cad platforms they will be implemented in lisp to ensure cross platform compatability
 without rewriting code.
« Last Edit: May 16, 2012, 03:42:17 AM by Daniel Eiszele »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: VLE lisp functions in Bricscad
« Reply #4 on: May 16, 2012, 03:14:54 AM »
I have tested (vle-start-transaction) and (vle-end-transaction) on two of my utilities:

1. Deleting mutiple layers:
Speed gain ca. 50%.

2. Creating and filling a table:
Table with 50 rows and 4 columns on a sloooow laptop.
Code: [Select]
; Benchmarking .......... elapsed milliseconds / relative timing <1 iterations>

  ; (TEST_CREATETABLEWITHTRANSACTION LST) .......... 266 / 64.85 <fastest>
  ; (TEST_CREATETABLEWITHOUTTRANSACTION LST) ..... 17250 / 1.00 <slowest>
Snappy indeed! But note: (vla-put-regeneratetablesuppressed) has yet to be implemented in Bricscad. So both test functions do not use this optimization.

What I have learned is that you have to be careful where you start a transaction. When working with tables you have to create the table before (vle-start-transaction) or some table functions will fail.

TMoses

  • Guest
Re: VLE lisp functions in Bricscad
« Reply #5 on: May 23, 2012, 07:28:57 PM »
@irneb

Thanks for the hints  :-D
Just improved (vle-entget) to always return non-NIL, in other words, "default" values are returned now, vle-extension.lsp has also been updated (for older Bricscad + non-Bricscad).
Should indeed make coding easier.

Besides, I plan to have (vle-entget-m dxfList ename) and (vle-entmod-m KeyDataList ename) or like that, which uses assoc lists (dxf . value) as return resp. input.

Many greetings to all, Torsten

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: VLE lisp functions in Bricscad
« Reply #6 on: May 24, 2012, 05:37:32 AM »
Sounds great, I'll definitely look into those.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.