Originally Posted by
stusic
I am doing something horribly wrong. If I snip out all of the (what I believe to be unneeded) lines, I get the wrong list. I want it to print out the list of values to verify I'm actually getting the right values, but I get results like:
Code:
Command: foo
((#<VLA-OBJECT IAcadBlockReference2 28de439c> . 3) (#<VLA-OBJECT
IAcadBlockReference2 28de4324> . 3) (#<VLA-OBJECT IAcadBlockReference2
28de42ac> . 5) (#<VLA-OBJECT IAcadBlockReference2 28de4234> . 96) (#<VLA-OBJECT
IAcadBlockReference2 28de41bc> . 7) (#<VLA-OBJECT IAcadBlockReference2
28de4144> . 3) (#<VLA-OBJECT IAcadBlockReference2 28de40cc> . 3) (#<VLA-OBJECT
IAcadBlockReference2 28de4054> . 3)
<snip>
To explain the output you received, see the 'item' description noted in this adaptation of my earlier offering:
Code:
(defun c:FOO (/ *error* adoResults ss pageNo data)
(defun *error* (msg)
(if (and ss (= 'VLA-OBJECT (type ss)))
(vla-delete ss)
)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
;; Represents the dataset for the ADOLisp results for each pageNo
(setq adoResults '((1 . "6") (2 . "10") (3 . "5") (4 . "7")))
;; Main code
(if (setq
ss (ssget "_x" '((0 . "INSERT") (2 . "TITLE_BLOCK") (66 . 1)))
)
(progn
;; Get page_no attribute values from blocks
(vlax-for x (setq ss (setq acDoc
(vla-get-activeselectionset
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
)
(foreach att (vlax-invoke x 'getattributes)
(if (= "PAGE_NO" (vla-get-tagstring att))
(progn
(setq pageNo (atoi (vla-get-textstring att)))
(setq data (cons (cons x pageNo) data))
)
)
)
)
;;; ;; Put revision attribute values into blocks
;;; (foreach item data
;;; (foreach att (vlax-invoke (car item) 'getattributes)
;;; (if (= "REV" (vla-get-tagstring att))
;;; (vla-put-textstring
;;; att
;;;
;;; ;; This is a pseudo ADO query
;;; (cdr (assoc (cdr item) adoResults))
;;; )
;;; )
;;; )
;;; )
;; for each item in data (a list of grouped pairs,
;; where the first element is the attribute object,
;; and the second element is the attribute object's
;; textstring property value converted to an integer
(foreach item data
;; print
(print
;; the second element of the association list returned
;; by a query against the ADO by searching for the second
;; element of the item's grouped pair (an integer)
(cdr (assoc (cdr item) adoResults))
)
)
(*error* nil)
)
)
)