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

Comments

José Luis García Galán

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

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

regards

Lee Ambrosius

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

BlackBox

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

https://www.theswamp.org/index.php?topic=42354.msg475130#msg475130

[code]
(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))
)
[/code]

Here's a quick speed test:

[code]
(setq s (getvar "acadprefix"))
(setq d ";")
(bench '(split) (list s d) 10000)
(bench '(_Parser) '(d s) 10000)
[/code]

... And the results from console:

[code]
_$

SPLIT
Elapsed: 2922
Average: 0.2922


_PARSER
Elapsed: 32
Average: 0.0032
[/code]

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.

Cheers

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.

The comments to this entry are closed.

My Photo

My Other Accounts

Twitter Updates

    follow me on Twitter