The problem is to get all properties in an entity.
I am trying to use below codes to scan all properties in an entity.
(defun c:ScanEntities ()
(setq ss (ssget "_X"))
(if ss
(progn
(setq total (sslength ss))
(setq count 0)
(while (< count total)
(setq ent (ssname ss count))
(setq ent_data (entget ent))
(setq count (1+ count))
(princ (strcat "Entity name: " (cdr (assoc 0 ent_data)) "\n"))
; Loop through entity data and print attributes
(foreach data_item ent_data
(setq data_type (car data_item))
(setq data_value (cdr data_item))
; Print attribute data
(if (not (eq data_type 0))
(princ (strcat "Attribute - Type: " (itoa data_type) ", Value: " (vl-princ-to-string data_value) "\n"))
)
)
(princ "\n")
)
)
(princ "No entities found.")
)
(princ)
)
However, the result I got is below:
It is missing some properties auch as "(** , 41), (***, 650)" as below graph.
May some expert give me a hint why I cannot get all properties by:
foreach data_item ent_data
To access attribute reference entities, you'll need to iterate over the subentities which follow the block reference entity in the drawing database, until you reach a terminating SEQEND
entity.
To do this, you can use the entnext
function, initially supplied with the block reference entity (to obtain the first attribute reference), and then with each successive attribute reference entity (to obtain the next entity in the drawing database), until you reach the terminating SEQEND
entity.
Perhaps review my Get Attribute Values function for an example of how to accomplish this.