(setq ss1 (ssget '((0 . "LWPOLYLINE") (8 . "LAY1,LAY2,LAY3") (-3 ("AAA"))))) ;;selection set (if (= "AAA1" (cdr (car e2)));;retrieve first Xdata (progn (if (or (wcmatch (cdr (cadr e2)) "8..")(wcmatch (cdr (cadr e2)) "8#.")) (setq T1 "_NO_AAA1") (setq T1 (cdr (cadr e2))) ) ) ) (if (= "AAA2" (cdr (car e2)));;retrieve second Xdata (progn (if (= (cdr (cadr e2)) "???") (setq T2 "_NO_AAA2") (setq T2 (cdr (cadr e2))) );new ) ) (if (= "AAA3" (cdr (car e2)));;retrieve third Xdata (progn (if (= (cdr (cadr e2)) "?") (setq T3 "_NO_AAA3") (setq T3 (cdr (cadr e2))) ) ) ) (setq R1 (strcat T1 T2 T3));;make the string for the first polyline (command "leader" pause pause "" "" "" R1 "");;make the leader
Solved! Go to Solution.
Solved by _gile. Go to Solution.
This comes to mind...
(setq ss1 (ssget '((0 . "LWPOLYLINE") (8 . "LAY1,LAY2,LAY3") (-3 ("AAA"))))) ;;selection set (repeat (setq I (sslength ss1)) (setq e (ssname ss1 (setq I (1- I))) e2 (entget e '("AAA")) ) (setq X (cdr (car e2))) ;; this doesn't look right (cond ((= X "AAA1") ;;retrieve first Xdata ;; do something ) ((= X "AAA2") ;; do something else ) ;; etc. ) )
John F. Uhden
Hi John (and others),
Thanks for your reply. The repeat mechanism is indeed what I needed.
Your post has already given me a better understanding, thanks.
For the rest, I'm still struggling to make it work.
I feel like I'm missing some key insights to 'glue' everything together in the code.
I will provide more info below.
This is the result of an XDLIST of a polyline. I've put all important refererences in red.
Registered Application Name: AAA * Code 1000, ASCII string: VERSION * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: * Code 1002, Starting or ending brace: } * Code 1000, ASCII string: A1 * Code 1002, Starting or ending brace: { * Code 1002, Starting or ending brace: { * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: dwgname * Code 1000, ASCII string: 120 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A2 * Code 1000, ASCII string: 01AAA0 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: from * Code 1002, Starting or ending brace: { * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: 120 -More- * Code 1000, ASCII string: 01AAA0 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: to * Code 1002, Starting or ending brace: { * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: 120 * Code 1000, ASCII string: 01AAA0 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A3 * Code 1000, ASCII string: 027 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A3 * Code 1002, Starting or ending brace: { -More- * Code 1000, ASCII string: 027 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A4 * Code 1000, ASCII string: * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A5 * Code 1000, ASCII string: 1999 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: AAA1 * Code 1000, ASCII string: 888 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: A6 * Code 1000, ASCII string: * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: {
-More- * Code 1000, ASCII string: AAA2 * Code 1000, ASCII string: 444 * Code 1002, Starting or ending brace: } * Code 1002, Starting or ending brace: { * Code 1000, ASCII string: AAA3 * Code 1000, ASCII string: 2 * Code 1002, Starting or ending brace: }
I would need to extract these 3 Xdata values from each polyline and put them together in a string. (example from XDLIST: "8884442")
Then I would need to combine these in a single leader, which holds the data from the entire selection set like this:
(this example has 4 polylines, each polyline's data should be on a new line)
But i'm unsure how I can build this string in an easy way.
How do I go from the 'cond' to such a string?
How do I tell (auto)lisp to add a “\n” (new line) for each additional object in the selectionset that I will use in the leader?
If someone could please take the time to help me, it would be much appreciated 🙂
Are you adding the xdata yourself, or you are working with drawings that have that data already there and you just want to extract it? Also could you privide a drawing that contains those entities and the exact end result you are aiming for.
Hi,
Here's a quick and dirty:
(defun c:xdatafromssget (/ str ss i data p1 p2) (and (setq str "") (setq ss (ssget '((0 . "LWPOLYLINE") (8 . "LAY1,LAY2,LAY3") (-3 ("AAA"))))) (repeat (setq i (sslength ss)) (if (setq data (cdadr (assoc -3 (entget (ssname ss (setq i (1- i))) '("AAA"))))) (setq str (strcat str (cdadr (member '(1000 . "AAA1") data)) (cdadr (member '(1000 . "AAA2") data)) (cdadr (member '(1000 . "AAA3") data)) "\\P" ) ) ) ) (setq p1 (getpoint "\nSpecify leader arrowhead location ")) (setq p2 (getpoint p1 "\nSpecify leader landing location: ")) (command "_mleader" p1 p2 str) ) )
You always make things so simple and clear.
Just one thing... the (and ...) will return nil because of the (command) at the end. Not that it really matters here. I'm just being picky. (vl-cmdf) solves the miniscule problem.
John F. Uhden
T or nil, both are not pretty feedback for an AutoCAD command.. NOTHING or a senseful Text information is normal for an AutoCAD command feedback.
So my choice in this case is (princ) at last.
Sebastian
I'm looking for something similar to this but can't seem to figure it out. I'm trying to extract xdata "line number" from a cadworx drawing but not sure where to start. Seems like it would be as easy as modifying the lisp routine you provided but doubt it's that easy. Below is a screenshot of the XDLIST properties I'm needing. Thanks in advance.
Your XDLIST shows ten (10) 1000 codes, which are easy to extract from the whole list, but you'll have to figure out some method of choosing the right one, maybe by using wcmatch with wildcards.
John F. Uhden
Can't find what you're looking for? Ask the community or share your knowledge.