Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hey Gang
How can i build a selection set of all circles and then retrieve the xdata attached to them? Thanks.
Southie
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
These sequences should give you some hints:
(regapp "myapp")
;Draw a test circle
(setq e (entlast));;Select circle
(entmod (list (cons -1 e) '(-3 ("myapp" (1000 . "this is xdata"))))) ;;add xdata to circle
(cdr (assoc -3 (entget e '("myapp")))) ;;get xdata from circle
(ssget '(0 . "circle"));;filtered selection set for circles.
(setq ss (ssget '((0 . "circle") (-3 ("myapp")))));;To filter for circles managed by "myapp".
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for the quick response. There use to be a Doug Broad who was a guru around here a while back.
Here is my attempt
(setq ss (ssget "x" '((0 . "circle") (-3 ("circ")))));;
(setq index 0)
(repeat (sslength ss)
(setq ent1 (entget (ssname ss index))
e (cdr (assoc -1 ent1))
xent (cdr (assoc -3 (entget e '("circ")))))
(setq index (+ index 1))
);repeat
xent = (("CIRC" (1002 . "{") (1000 . "qty 4") (1002 . "}"))) how do i assign "qty 4" to a variable. thanks.
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
That's me.
There are ways to get the data but the most productive process is to play with the list functions: car, cdr, their composites: caar cadr cdar cddr, etc. and assoc. The person who wrot the app that stores the xdata is responsible for the ordering of the information in the xdata and should know how to extract an individual object. Some examples for your particular case using X as the variable name are:
_$(setq x '(("CIRC" (1002 . "{") (1000 . "qty 4") (1002 . "}"))))
_$ (car x)
("CIRC" (1002 . "{") (1000 . "qty 4") (1002 . "}"))
_$ (caar x)
"CIRC"
_$ (cdr(car x))
((1002 . "{") (1000 . "qty 4") (1002 . "}"))
_$ (cdr(cdr(car x)))
((1000 . "qty 4") (1002 . "}"))
_$ (cdr(assoc 1000 (cdar x)))
"qty 4"
_$ (nth 1 (cdr(car x)) )
(1000 . "qty 4")
_$ (cdr(nth 1 (cdr(car x))))
"qty 4"
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Excellent! Thank you dbroad for your time and help.
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Mr. dbroad if you get a chance
stumped on this. With e being a valid entityname the following works
(entmod (list (cons -1 e) '(-3 ("idnumqty" (1000 . "3")))))
however,
(setq xqty "3")
(entmod (list (cons -1 e) '(-3 ("idnumqty" (1000 . xqty)))))
does not work & get this error ; error: bad DXF group: (-3 ("idnumqty" (1000 . XQTY)))
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
southie wrote:Mr. dbroad if you get a chance
stumped on this. With e being a valid entityname the following works
(entmod (list (cons -1 e) '(-3 ("idnumqty" (1000 . "3")))))
however,
(setq xqty "3")
(entmod (list (cons -1 e) '(-3 ("idnumqty" (1000 . xqty)))))
does not work & get this error ; error: bad DXF group: (-3 ("idnumqty" (1000 . XQTY)))
with ' (quote) the line will be treated on its face value
(entmod (list (cons -1 e) (list -3 (list "idnumqty" (cons 1000 xqty)))))
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks dbroad & pb for all the help and sharing of your knowledge.
Southie
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You're welcome. Glad to help.
Re: Retrieving xdat from an entity
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
southie wrote:Thanks dbroad & pb for all the help and sharing of your knowledge.
Southie
Good for you.
Cheers

