I do not have time to write code to discover which is faster so I wondered if anyone knew.....
Task: To obtain the Handle to an entity as a string to be used in legacy lisp routines.
Which is likely to be faster;
(cdr(assoc 5(entget eName)))
OR
A call to a .net DLL that returns the handle of the entity eName.
Opinions anyone?
Solved! Go to Solution.
Solved by chiefbraincloud. Go to Solution.
Use the LSP. If all you need is a Handle, it would be silly to have to load a .dll to replace 3 lsp function calls.
Agree, however, I already load a .net DLL that replaces other legacy routines - so the loading of the DLL isnt an issue.
Obtaining a handle occurs hundreds of times - so - question still stands... Lisp or .Net. =D
....can't rewrite all of the lisp routines in .net yet because of time constraints.
I still say, for this case, use the LSP. For routines that you are converting from LSP to .NET, I would go ahead and convert them completely to use all .NET and no LSP, but for the particular case you presented, I do not think there would be a benefit to a .NET function to return the handle as a string. On the contrary, I think it would result in more CPU instructions and memory read/writes rather than less.
The previous answer still stands 🙂 A couple of hundred calls to extracting a handle from an (entget...) list? That won't get any faster with .NET. If speed is critical and you keep pulling the same handles, then consider some optimization such as caching the handle values alongside the entity codes in a list of dotted pairs e.g. (<Ecode> . "Handle").