std-entget, std-init-entget | ![]() |
STD-ENTGET forces the ele argument to be converted to an entget list as returned by (ENTGET ele). It accepts entity types, entget-lists or entsel picklists.
STD-INIT-ENTGET clears the entget cache. It is only rarely needed, in special usercode, when you change any entity property without any stdlib function, e.g. by not using STD-ENTMOD.
You are not advised to do so, but if so you have to call (STD-INIT-ENTGET) otherwise you will get old results, not reflecting your changes. It is defined as below:
(defun STD-INIT-ENTGET () (setq *ENTGET-CACHE* nil))
The implementation uses an entget caching mechanism, because ENTGET is usually the slowest, which speeds up consecutive (STD-ENTGET) calls on the same element.
This mechanism is used by (STD-ENTGET) which is called by (STD-GETVAL) which is called by every STD-GETXXX entity property accessor, like (STD-GETTYPE), (STD-GETNAME), (STD-GETPT) and so on.
Problems with modified or deleted entities and internal caching
ENTGET may also be used to check if an entity is deleted. However with the internal chaching mechanism, the cache may get fooled, if an element is deleted with (ENTDEL) instead of (STD-ENTDEL) or modified with (ENTMOD) instead of (STD-ENTMOD) between two consecutive STD-ENTGET calls.
Then you'll have to use (ENTGET) instead of (STD-ENTGET) or better use (STD-ENTDEL) and (STD-ENTMOD).
(if (setq ele (std-entsel nil)) (progn (setq lay (std-getlay ele)) ; uses implicitly std-getval ;; bad: deletion should be done with (std-entdel) instead! (entdel (setq ele (std-entity ele))) (setq col (std-getcolor ele)) ; this is not valid! but okay ;; check for deletion (if (entget ele) (princ " deleted") (princ " not deleted") ) ) ) ;; another bad example how NOT to do it, and how to take care. (if (setq ele (std-entsel nil)) (progn (setq lay (std-getlay ele)) ; uses implicitly std-getval ;; stupid way to call (std-entchg ele nil 8 "1") (entmod (subst '(8 . "1") (assoc 8 (entget (car ele)) (entget (car ele)))) ;; now the cache still thinks lay is the layer property ;; we have to call this to force an update on the next access (std-init-entget) (std-print (list "\nold layer: " lay "\nnew layer: " (std-getval 8 ele))) ) )
To synchronize the cache either call (STD-INIT-ENTGET) or do a STD-GETVAL on any other valid entity.
ele: Either an entity type, entget-list or entsel picklist.
An entget-list or or nil.
None. (It may set an internal *ENTGET-CACHE* symbol, but direct access is forbidden)
(std-require 'STDENT)
Defined in STDENT