Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 11 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-30-2009 06:18 AM in reply to: framednlv
Using the X option with insertion-point filtering is just saying "find me whatever piece of text in this drawing has its insertion point at this location." It's not a point location as though you picked there on-screen, but an element of the entity data.

The what-if-there-is-a-space question is exactly why it's probably better to filter by insertion point, since the OP seems to know what the insertion point will always be. It doesn't depend on there being some actual element of the text graphically at that location, the way C or W or CP or WP or F selection would.

You're right about the variability of 10 & 11 codes in Text entity data, but it's not quite as inscrutable as you make it sound -- see another reply of mine above.

--
Kent Cooper


curmudgeon wrote:

I am confused at using (ssget "_X" ) with a point location. Just does not feel right.

You want to select text blind? What if there is a space at your selection point?
....
Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 12 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-30-2009 06:36 AM in reply to: framednlv
When I said you should replace 'yourx' and 'youry' with the coordinates of the known insertion point, I meant literally replace, rather than set to variables and use those variable names. When using point lists in (ssget) filtering, you need to use plain values *without* variables, if they're in a plain unevaluated list with the apostrophe at the beginning, like this [changing the 10 to 11 as in another reply]:

(setq txtsel (ssget "X" '((0 . "TEXT") (11 0.0 0.0 0.0))))

or if you're setting variables that will need to be *evaluated*, you need to use the (list) command explicitly, like this:

(setq txtsel (ssget "X" (list '(0 . "TEXT") (list 11 yourx youry 0.0))))

[The '(0 . "TEXT") still gets the apostrophe, because that inner list doesn't need evaluation -- you know the expected values exactly.]

If you do it the latter way, you can easily throw in another evaluation, to get to yourx + 1:

(setq txtsel (ssget "X" (list '(0 . "TEXT") (list 11 (1+ yourx) youry 0.0))))

--
Kent Cooper


framednlv wrote:
....
How can I setq for (10 yourx youry 0.0) and how can I change it from yourx to yourx + 1

I tried:
(setq yourx 0.0)
(setq youry 0.0)
....
(setq txt
(if (setq txtsel (ssget "X" '((0 . "TEXT") (10 yourx youry 0.0))))
(cdr (assoc 1 (entget (ssname txtsel 0))))
","
); end if
); end setq
....
Kent Cooper
Distinguished Contributor
framednlv
Posts: 145
Registered: ‎08-03-2004
Message 13 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-30-2009 03:46 PM in reply to: framednlv
Thanks Everyone,

I got cought up trying to use parts of everyones example with out reading exactly what what going on.

I found that this is working just fine:
{code}(setq lcode
(if (setq txtsel (ssget "_f" '((28.341 522.674)( 37.372 522.674 )) '((0 . "TEXT") )))
(cdr (assoc 1 (entget (ssname txtsel 0))))
","
); end if
); end setq{code}

What I would like to do is set my Y value and use something like this:
{code}
(setq Yline '(522.674))
(setq ltrip
(if (setq txtsel (ssget "_f" '((43.378 Yline)( 57.551 Yline )) '((0 . "TEXT") )))
(cdr (assoc 1 (entget (ssname txtsel 0))))
","
); end if
); end setq
{code}
How can I get the Yline to work in the code?

I really do thank all of you for the help. I didn't want to ask for anyone to write my code for me but help with how to get some of the parts working. I didn't realise there were so many ways to look at it.

Thanks,
Chris
Distinguished Contributor
curmudgeon
Posts: 156
Registered: ‎05-22-2007
Message 14 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-30-2009 05:14 PM in reply to: framednlv
my apologies Kent, for not scrolling in the scroll box and reading the length of your string of code.

glad the fence selection is working for you.
there are two parts to the crossing, window, fence and crossing polygon selection sets.
the first is a points list - the second is a filter list. the filter list is where you put '((0 . "TEXT"))

you could
(setq pt_lst '( (43.378 522.674) ( 57.551 522.674) ) )
(setq txtsel (ssget "_f" pt_lst '((0 . "TEXT") )))

or

(setq pt_lst (list (list 43.378 (setq y 522.674)) (cons 57.551 y)))
(setq txtsel (ssget "_f" pt_lst '((0 . "TEXT") )))

or

(setq x1 (getpoint "\nPick X1 :")
x2 (getpoint x1 "\nPick X2 :")
y 522.674
my_list (list (cons x1 y) (cons x2 y))
txtsel (ssget "_f" pt_lst '((0 . "TEXT") )))
)

any of theses tickle your fancy?
Mentor
southie
Posts: 291
Registered: ‎03-15-2007
Message 15 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-30-2009 08:45 PM in reply to: framednlv
working with layout tabs that could number in the hundreds and do not want program have to go to each tab to select text located at an x coord of 1.2. Would below be safe/good_programming_practice? Have used (foreach n (layoutlist) (setvar "ctab" n) (ssget "c".. in the past but its slow. Or is there a a better way?
Thanks

(setq index 0)
(setq ss (ssget "x" (list (cons 0 "text"))))
(repeat (sslength ss)
(setq ent (entget (ssname ss index))
ent1 (nth 0 (cdr (assoc 10 ent)))

(if (= ent1 1.2) (progn
do stuff.....

));if progn
(setq index (+ index 1))
);repeat
Distinguished Contributor
framednlv
Posts: 145
Registered: ‎08-03-2004
Message 16 of 16 (121 Views)

Re: text value from a specific location (x,y)

03-31-2009 09:11 AM in reply to: framednlv
Thanks Everyone,

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community