;;; ---------------------------------------------------------------------
;;;  DXFDMP-bgol.lsp
;;;  Command:  DXD
;;;
;;;  PURPOSE
;;;  Developer utility: selects an entity and prints its full raw DXF
;;;  association list (exactly as AutoLISP's entget would return it) to
;;;  the command line, one group code per line for readability. Useful
;;;  when writing or debugging AutoLISP routines that need to inspect an
;;;  entity's exact underlying data structure.
;;;
;;;  USAGE
;;;    1. Load this file (APPLOAD or drag-drop onto the drawing window).
;;;    2. Type   DXD   at the command line and press Enter.
;;;    3. Select an entity in the drawing.
;;;    4. The entity's full (entget) association list is printed to the
;;;       command line / text window, one DXF pair per line.
;;;
;;;  NOTES
;;;    - This is a read-only inspection tool; it creates no new entities
;;;      and modifies nothing in the drawing.
;;;    - This is an original, independently written implementation.
;;;      It is INSPIRED by the general idea of raw-DXF-dump developer
;;;      utilities common in AutoLISP development workflows, but the
;;;      code, command name and file name here are new and are NOT
;;;      copied from, nor identical to, any specific third-party
;;;      product.
;;;
;;;  ---------------------------------------------------------------------
;;;  Developed and shared for the CAD community by:  BGol Community
;;;  Community website:                              https://bgol.in/
;;;  License:  Open-source & free to use, modify, and share for all.
;;;            Provided "as is", without warranty of any kind.
;;;  ---------------------------------------------------------------------

(vl-load-com)

(defun BGOL:DXD-PrintPair (pr / code val)
  (setq code (car pr))
  (setq val (cdr pr))
  (princ (strcat "\n  (" (itoa code) " . "))
  (princ val)
  (princ ")")
)

(defun C:DXD ( / ent edata pr)
  (setq ent (car (entsel "\nSelect entity: ")))
  (if ent
    (progn
      (setq edata (entget ent))
      (princ "\n----------------------------------------------------------")
      (princ "\nDXD: raw DXF data (as returned by entget) --")
      (princ "\n----------------------------------------------------------")
      (foreach pr edata
        (BGOL:DXD-PrintPair pr)
      )
      (princ "\n----------------------------------------------------------")
      (princ (strcat "\n" (itoa (length edata)) " group code pair(s) total."))
    )
    (princ "\nNo entity selected.")
  )
  (princ)
)

(princ "\nDXFDMP-bgol.lsp loaded. Type DXD to dump an entity's raw DXF data.")
(princ "\n  -- Free & open-source, courtesy of BGol Community (https://bgol.in/) --")
(princ)
