Creating Entities
Basically, there are 3 approaches to create
entities, based on pure Lisp :
|
(command "_line" point1 point2 ...) |
using (command) or (vl-cmdf)
functions provide the least performance, and additionally have many
side-effects : command reactors are called, significant part of
UserInterface code is involved which also costs performance, and
many system variables have impact on the behaviour; |
|
(entmake
definition-data) |
(entmake) and (entmakex) provide much better performance than (command), and very few system variables have impact here; (entmakex) should be preferred as it immediately returns the name of created entity |
|
(vla-addLine ...) |
in most cases, using the
COM-based entity creation provides the best performance; |
Some background :
using (entmake) and (entmakex) functions use
an assoc list - the Lisp engine needs to transform such list into a
resbuf list for C/C++ based APIs; there, the resbuf list is then
parsed by a DxfIn-like operation to fill the new entity; both
stages are heavy operations with lots of loops involved.
Additionally, temporary memory needs to be allocated and released,
which also reduces performance.
On the opposite, the COM based
(vla-add<Entity>) functions directly create the target entity
based on the provided parameters, the only overhead is caused by
data conversion from Lisp to COM data types.
BricsCAD-specific :
The "Fast-COM" mode for
(vla-add<Entity>) is about to be implemented very soon - the
COM data and function call marshalling is then bypassed as well, so
the overhead is reduced to minimum, and performance of
(vla-add<Entity>) functions is then very close to C/C++ code
(like BRX and ARX);
Suggestion : as
all major CAD systems meanwhile support the (vla-) function family,
it is safe to adjust Lisp code to COM style - the performance gain
is really significant; as all the vla/vlax/vlr functions become
available for Linux/Mac as well, there is no risk for
portability.
© Menhirs NV. All rights reserved. |