Coordinates to all objects in specific layer

Coordinates to all objects in specific layer

Anonymous
Not applicable
1,020 Views
5 Replies
Message 1 of 6

Coordinates to all objects in specific layer

Anonymous
Not applicable
  • Hello!
  • I'm working on  layer that has objects (trees) and I need to show coordinates at label on each tree in my drawing based on insertion point.  Is there any lisp for that to load automatically these coordinates or is this trick possible at all?  I'am beginner at acad and I think its best to ask. Otherwise I m going to spend days for something that is impossible. 
  • Thank you. 
  • Bad bad english, sorry. 
  •  
0 Likes
1,021 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

This is a relatively easy task, a good learn lisp. So lets start.

 

Select a single tree, use "ENTSEL" then "ENTGET" to get 2 properties, Layer and Block name. assoc 8, assoc 2

Make a selection set, (setq ss (ssget (list  (cons 8 lay)(cons 2 Blkname))) did this one for you.

Use " REPEAT" with SSNAME and retrieve each block again use "ENTGET" and get assoc 10 this is insertion point

    Pull X & Y & Z from insertion point

    Add text with X Y Z and use insertion point

Do next until end of repeat 

 

Just have  a look on any of the pages for further examples.

 

You will get more help by having a go. Start with Google for "text label a point".

 

Message 3 of 6

lena.talkhina
Alumni
Alumni

@Anonymous wrote:
  • Bad bad english, sorry. 

No need to be sorry @Anonymous ! It is fine to understand you.
Hope our community and folks here will help you to find a solution.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

It's pretty easy. The manual version is done HERE ... and HERE is more about ssget filters... as  '((0 . "INSERT")) here

The automated one, for multiple selection, here:

 

(defun c:BCoords (/ sel pnt val i)

  (if (setq sel (ssget '((0 . "INSERT"))))
    (repeat (setq i (sslength sel))
      (setq pnt (cdr (assoc 10 (entget (ssname sel (setq i (1- i))))))
	    val (strcat "E="   (rtos (car pnt) 2 3)
			"\nN=" (rtos (cadr pnt) 2 3)))
      (command "_.mleader" "_none" (trans pnt 0 1) "_non" "@10,10" val)))
  (princ)
  )

 

HERE  is Lee's tutorial on how to process a selection set. I've used the 2a method which is very popular.

An explanation of each function used you can find in HELP HERE 

0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant

Ou, now I see that you wanted to select all objects in some layer.. That would be an easy fix.. and for you an opportunity to learn a bit from links I gave you. 

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

At this spot pick a tree block and retrieve its layer. Look at the code provide layer is assoc 8. The ssget becomes.

 

 

(defun c:BCoords (/ sel pnt val i)
put pick a block here
then get layer here
  (if (setq sel (ssget '((0 . "INSERT"))))

Hints
(setq ent (car (entsel "\nPick a tree")))
(cdr (assoc 8 (entget ent)))
(ssget '((0 . "INSERT")(8 . lay)))

 

 

0 Likes