Modifying Entities

Parent Previous Next

Modifying Entities


Similar to creating entities, there are different ways to modify entities ... most of the above mentioned details apply here as well.


(command "_chprop" ...)

using (command) or (vl-cmdf) functions provide the least performance here again, 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;
should only be used when there is no other possibility or when performance does not matter


(entmod definition-data)

(entmod) provide much better performance than (command), and very few system variables have impact here; nevertheless, the definition-data must first be retrieved, then modified, and finally used with (entmod) - this costs a lot of operations and temporary memory; altogether it is a quite ineffective way to modify an entity


(vla-put-layer <entity> ...)

in majority of cases, the COM-based entity modification provides by far the best performance at all;
AutoCAD : in majority of cases, the (vla-put) function is also faster here
BricsCAD: as BricsCAD COM is faster by factor 3...4 in generally, the (vla-Add<Entity> functions are always significantly faster than any other method


Some background :
Same as with entity creation via (entmake) - it uses an assoc list, which the Lisp engine needs to transform into C/C++ resbuf list, which is finally parsed by a DxfIn-like operation to update the entity; both stages are heavy operations with lots of temporary memory needed; not to forget, the definition-data list needs to be retrieved by (entget) first, and the related data items need to be adjusted to desired values; so the indirect costs are much bigger.
On the opposite, the COM based (vla-put-<Property>) functions directly access the target entity and update only the desired properties, without large list data conversion and parsing; the only overhead is caused by data conversion from Lisp to COM data types for the provided arguments, also the memory usage is at minimum.

BricsCAD-specific :
The "Fast-COM" mode is already implemented for a large number of properties, so (vla-put-<Property>) is the highly recommended way here; the overhead is reduced to minimum, and performance of (vla-put<Property>) functions is very close to C/C++ code (like BRX and ARX); in other words, the performance advantage to classical (entmod) is about factor 10 ... 30 (and even more).

Suggestion : as all major CAD systems meanwhile support the (vla-) function family, it is safe to adjust Lisp code to use the (vla-put-<Property>) function family - 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.

If Lisp code needs to remain with (entmod) :
Even in this case the BricsCAD Lisp engine provides a high-performance alternative for (entmod) - the VLE function library offers (vle-entmod) and (vle-entmod-m) functions, which directly modify the entity data for a given DXF group code (or a list of DXF group code) without the need to use (entget) before;
for a large range of DXF group code, the BricsCAD Lisp engine does not internally generate the C/C++ resbuf list, but directly modifies the related entity data - only for entity-specific DXF codes, the Lisp engine uses that C/C++ resbuf list internally, without conversion into a Lisp list;
all VLE functions are also available under AutoCAD and other CAD software by emulation with vle-extension.lsp, so there is no compatibility problem with using VLE library functions (please see compatibility notes).




©  Menhirs NV. All rights reserved.