« AutoCAD 2017 ObjectARX and Managed .NET Documentation | Main | Getting the Current Date/Time with AutoLISP - Part 1 »


José Luis García Galán

Only a small correction:
(Getenv "ACADPrefix") ";") is erroneous.

Use: (getvar "acadprefix") or (getenv "ACAD")


Lee Ambrosius

Thanks for catching the issue, the sample has been fixed. The original content I had wrote used an environment variable.


I think you'll find this old 'parser' routine offers a substantial boost in efficiency:


(defun _Parser (char string / i segments segment)
(while (setq i (vl-string-search char string))
(setq segments (cons (setq segment (substr string 1 i)) segments))
(setq string (substr string (+ 2 i)))
(reverse (cons string segments))

Here's a quick speed test:

(setq s (getvar "acadprefix"))
(setq d ";")
(bench '(split) (list s d) 10000)
(bench '(_Parser) '(d s) 10000)

... And the results from console:


Elapsed: 2922
Average: 0.2922

Elapsed: 32
Average: 0.0032

Now, how often will someone parse a string anywhere near this many times - admittedly seldom - just offering simplicity, and efficiency where I can, based on what I've learned.

Please do with this what you like.


Lee Ambrosius

Thanks for sharing! There is always different ways to approach the same solution and performance is key when working with large data sets.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

My Photo

My Other Accounts

Twitter Updates

    follow me on Twitter