replace multiple point objects with block and add nearest text as block attribute

replace multiple point objects with block and add nearest text as block attribute

nbortolussi
Participant Participant
880 Views
5 Replies
Message 1 of 6

replace multiple point objects with block and add nearest text as block attribute

nbortolussi
Participant
Participant

I often export layers from google earth to acad.  each GE placemark converts into 2 objects in acad (a point and a text object for the placemark name).  i have found a lisp that can replace the point object with a block that i choose, but I really want for it to also incorporate the name of placemark into the single attribute of the block.  the point and text objects are generally really close to each other so I am hoping there is a way to do this by proximity.  i would like it to automatically recognize the points selection even if i have some other things selected as well.  Alternatively, if it is easier, instead of replacing the points you could replace the text objects and place the block base point at the text objects justify anchor point and then use the text value in the block attribute.  now that i think about it...this might be the better way to go, but i will let you decide.

0 Likes
Accepted solutions (1)
881 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

Some hints so you can have a go,

 

Get all "Points" say on a layer using ssget with points filter '((0 . "POINT"))

Using the point insert point make a little box say 4 points. Only really need points not lines

Use SSGET "F" pts to look for text once found get text string.

Add block and put text into attribute.

 

See little green search box. Size to suit gap from point.

SeaHaven_0-1710906680148.png

 

The find text can be simplified even more as there is a pattern to where the text is located, so can actually use SSGET pt where pt would be within the text calculated from the insertion point.

 

SeaHaven_1-1710906908220.png

There are so many examples out there of this task.

0 Likes
Message 3 of 6

calderg1000
Mentor
Mentor
Accepted solution

Regards @nbortolussi 

Try this code. Select the block to replace, then select all the text by selection window and you will get what you require.

 

 

;;;___
(defun c:I_block (/ spm blkn ltxn x)
  (princ "\nSelect the base block to replace: ")
  (setq spm  (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        blkn (cdr (assoc 2
                         (entget (car (entsel "\n Select Block Base for Replace: ")))
                  )
             )
        ltxn (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "TEXT"))))))
  )
  (foreach x ltxn
    (vla-InsertBlock
      spm
      (vlax-make-variant (vlax-3d-point (cdr (assoc 11 (entget x)))))
      blkn
      1
      1
      1
      0
    )
    (entmod (subst (cons 1 (cdr (assoc 1 (entget x))))
                   (assoc 1 (entget (entnext (entlast))))
                   (entget (entnext (entlast)))
            )
    )
    (vla-erase (vlax-ename->vla-object x))
  )
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 4 of 6

nbortolussi
Participant
Participant
@calderg1000,
Thank you, Thank you, Thank you!!! This worked perfectly!
0 Likes
Message 5 of 6

nbortolussi
Participant
Participant
@Sea-Haven,
Thank you for your response, unfortunately I am not very well versed in the language.
0 Likes
Message 6 of 6

calderg1000
Mentor
Mentor
Glad to help...

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes