Author Topic: DXF Code to Access PMARKER Text Contents  (Read 246 times)

0 Members and 1 Guest are viewing this topic.

encepta

  • Mosquito
  • Posts: 3
DXF Code to Access PMARKER Text Contents
« on: January 23, 2023, 07:11:53 PM »
I can't figure out how to access the text contents of a PMarker using the dxf code. I've read the DXF code list to try and find out more but 1. (what they say should return the primary text value) only returns nil.

I can access it directly by calling the element of the list using nth, but that limits this script, i.e. the text position in the entity list changes when using different .dwg or method of generating PMarker.

here is how i can access the other elements, i.e. ename, coords, text size:

(setq ename (cdr (assoc -1 entObj))
                    coords (cdr (assoc 10 entObj))
                    textSize (cdr (assoc 40 entObj))
                )

I want the text contents though.
i.e. textString (cdr (assoc ?? entObj))

I've attached a picture of my properties in autocad and entity object properties output.

Is this possible? You can see in the output that there are two values for (1 . ) and (1 . thetextstringiwant). I have a feeling that when I call 1. it returns the first (empty) string rather than the second one. Any help is much appreciated!

danAllen

  • Newt
  • Posts: 50
Re: DXF Code to Access PMARKER Text Contents
« Reply #1 on: January 23, 2023, 08:29:59 PM »
here is a utility to retrieve multiple values
Code: [Select]
;;;=========================================================================
;;; massoc
;;;
;;; get multiple items from an association list (instead of just 1st one)
;;;
;;; From: Tony Tanzillo (tony.tanzillo@worldnet.att.net)
;;; Subject: Re: extracting multiple assoc from list
;;; Newsgroups: autodesk.autocad.customization
;;; Date: 1999/09/29
;;;
;;; revised by Dan, 2017
;;; to add option for key to be a list of assoc codes, '(10 11), or just a single
;;;=========================================================================
(defun massoc (key alist / x nlist)
  (if (not (= 'LIST (type key)))
    (setq key (list key))
  )
  (foreach y key
    (foreach x alist
      (if (eq y (car x))
        (setq nlist (cons (cdr x) nlist))
      )
    )
  )
  (reverse nlist)
) ;end defun

BIGAL

  • Swamp Rat
  • Posts: 1138
  • 40 + years of using Autocad
Re: DXF Code to Access PMARKER Text Contents
« Reply #2 on: January 23, 2023, 09:15:02 PM »
(cdr (assoc 1
A man who never made a mistake never made anything

encepta

  • Mosquito
  • Posts: 3
Re: DXF Code to Access PMARKER Text Contents
« Reply #3 on: January 24, 2023, 01:59:43 PM »
(cdr (assoc 1

I explicitly said in the OP that (cdr (assoc 1 entObj)) returns NIL.

encepta

  • Mosquito
  • Posts: 3
Re: DXF Code to Access PMARKER Text Contents
« Reply #4 on: January 24, 2023, 02:13:58 PM »
here is a utility to retrieve multiple values
Code: [Select]
;;;=========================================================================
;;; massoc
;;;
;;; get multiple items from an association list (instead of just 1st one)
;;;
;;; From: Tony Tanzillo (tony.tanzillo@worldnet.att.net)
;;; Subject: Re: extracting multiple assoc from list
;;; Newsgroups: autodesk.autocad.customization
;;; Date: 1999/09/29
;;;
;;; revised by Dan, 2017
;;; to add option for key to be a list of assoc codes, '(10 11), or just a single
;;;=========================================================================
(defun massoc (key alist / x nlist)
  (if (not (= 'LIST (type key)))
    (setq key (list key))
  )
  (foreach y key
    (foreach x alist
      (if (eq y (car x))
        (setq nlist (cons (cdr x) nlist))
      )
    )
  )
  (reverse nlist)
) ;end defun

Hey Dan,

Thanks for the function. This worked great.

Cheers,
Henry

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: DXF Code to Access PMARKER Text Contents
« Reply #5 on: January 24, 2023, 02:24:14 PM »
Alternatively you could use -
Code - Auto/Visual Lisp: [Select]
  1. (cdr (assoc 1 (reverse entObj)))