Pick the point - get the name

Pick the point - get the name

Anonymous
Not applicable
883 Views
3 Replies
Message 1 of 4

Pick the point - get the name

Anonymous
Not applicable

Hello all,

I was trying to solve the following problem for months: I want to pick a point (or enter manually) anywhere inside the attached table and get the name of the cell I picked into. For example (see attached drawing), when i pick the point with coordinates 7435680,4980930 the message D33 (the name of the cell) should appear at command line or anywhere as local variable.

Note that the above mentioned table is not the real table but rather area divided into rows and columns 22500x15000 drawing units. It is important to keep above dimensions of the cells. Also, so called "table" won't be visible in drawing, I just want to load the lisp, enter (or pick) the point and get the name of the cell.

Hope I was clear enough. Any help would be highly appreciated, thank you very much.

 

Branko

0 Likes
Accepted solutions (1)
884 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor
Accepted solution

Untested...

 

(defun c:demo (/ col pt row xs ys)
    (if (and (setq pt (getpoint))
             (setq xs (car pt))
             (setq ys (cadr pt))
             (<= 7365000.0 (car pt) 7680000.0)
             (<= 4500000.0 (cadr pt) 5130000.0)
             (setq col (nth (fix (/ (- xs 7365000.0) 22500.0)) '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N")))
             (setq row (itoa (1+ (fix (/ (- ys 4500000.0) 15000.0)))))
        )
        (alert (strcat col row))
        (prompt "\nPoint specified outside the expected boundary... ")
    )
    (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 3 of 4

Anonymous
Not applicable

Henrique, that's perfect, thank you so much! It looks so simple (for those who know)...

Meanwhile, I have to go one level deeper into those cells: By choosing the option 1 or 2 or 3 (see attached dwg) before I pick the point, the result should be as it shown on drawing: If option 1 is selected, the result is D33-42, for option 2 is D33-92 and for option 3 is D33-213. The difference between options is only in number of subcells (option 1 - 5x10, option 2 - 10x10 and option 3 - 15x15 cells).

Again, thank you for previous solution. Hope that you or somebody else can help me on this.

 

Regards,

Branko

0 Likes
Message 4 of 4

hmsilva
Mentor
Mentor

@Anonymous wrote:

Henrique, that's perfect, thank you so much! It looks so simple (for those who know)...

Meanwhile, I have to go one level deeper into those cells: By choosing the option 1 or 2 or 3 (see attached dwg) before I pick the point, the result should be as it shown on drawing: If option 1 is selected, the result is D33-42, for option 2 is D33-92 and for option 3 is D33-213. The difference between options is only in number of subcells (option 1 - 5x10, option 2 - 10x10 and option 3 - 15x15 cells).

Again, thank you for previous solution. Hope that you or somebody else can help me on this.

 

Regards,

Branko


You're welcome, Branko!


To determine the subcells, It will not be so easy...

The subcells are numbered from the upper left corner to the bottom right corner and the coordinates are from lower left corner to the top right corner...

 

Henrique

Henrique

EESignature

0 Likes