Jump to content

entname block closest to a point.


Anushka

Recommended Posts

How I adapt the program to get the name of the nearest block.
with text it works.

 

(defun :closestname (pt ss)
  (cdar
    (vl-sort
      (mapcar '(lambda (e) (cons (distance (cdr (assoc 10 (entget e))) pt) (cdr (assoc 1 (entget e)))))
	       (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      ) 
      '(lambda (p1 p2) (< (car p1) (car p2)))
    )
  )
)

 

Link to comment
Share on other sites

Quote
23 minutes ago, Anushka said:

How I adapt the program to get the name of the nearest block.
with text it works.

 



(defun :closestname (pt ss)
  (cdar
    (vl-sort
      (mapcar '(lambda (e) (cons (distance (cdr (assoc 10 (entget e))) pt) (cdr (assoc 1 (entget e)))))
	       (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      ) 
      '(lambda (p1 p2) (< (car p1) (car p2)))
    )
  )
)

 

 

 

If you are only selecting blocks change (cdr (assoc 1 (entget e))) to (cdr (assoc 2 (entget e)))

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Anushka said:

@dlanorh It's YES!!! lol lol

 

-1 worked

 

Glad I could help. (assoc 2) is the actual name of the block, (assoc -1) is the entity name.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...