LISP to locate blocks / xdata objects

LISP to locate blocks / xdata objects

Anonymous
Not applicable
1,318 Views
7 Replies
Message 1 of 8

LISP to locate blocks / xdata objects

Anonymous
Not applicable

Sample.jpgHey Everyone,

I had a task to create x data for various blocks, however after checking on excel i found a duplicated x data with the same name, so i cant be sure if there are 2 blocks with the same name or 2 different blocks with the same xdata, ALL the blocks should have their name as their xdata

so is there any way someone can help me as they are more than 400 blocks 😞

 

0 Likes
1,319 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

This will list all the xdata recs for selected blocks with their block name. Then you can analyze the output in excel.

 

(defun c:BlockODList ( / s i d)

  (if (setq s (ssget '((0 . "INSERT"))))
    (repeat (setq i (sslength s))
      (setq d (entget (ssname s (setq i (1- i))) '("*")))
      (foreach e (cdr (assoc -3 d))
	(princ (strcat "\n" (cdr (assoc 2 d)) ": "))
	(princ e))))
  (princ)
  )

 

Message 3 of 8

john.uhden
Mentor
Mentor

To add to what @ВeekeeCZ told you, you can include xdata in selection set filtering.

I think it goes something like...

(setq ss (ssget "x" (list '(0 . "INSERT")'(2 . "<BlockName>")(cons -3 (list "<RegApp>")))),

though I still don't have any code copied to my new laptop to verify my response, but I know I'm close.

John F. Uhden

Message 4 of 8

braudpat
Mentor
Mentor

Hello @Anonymous 

 

To complete the excellent answers of @ВeekeeCZ & @john.uhden 

 

You will find attached a beautiful french routine XDA from Gilles (gile)

which displays into a dialog box ALL tha XDatas attached to an entity ...

 

It s very nice to see it and do a Copy / Paste ...

Please remind that you can't update / modify XData values with this XDA routine !

 

THE HEALTH, Bye, Patrice

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 5 of 8

Anonymous
Not applicable
Thanks guys for all your help, but what exactly that i need is that i type the xdata name and it locate it in the drawing, as already i have the xdata list n excel but the problem is i cant locate the duplicated ones on the drawing

0 Likes
Message 6 of 8

Anonymous
Not applicable

much appreciated, thank you, but still i need to locate them on the drawing (already i have the names)

 

0 Likes
Message 7 of 8

john.uhden
Mentor
Mentor

This might help...

(defun c:FindXdata ( / reg ss)
  (and
    (setq reg (getstring "\nEnter name of regapp (wildcards are welcomed): "))
    (setq ss (ssget "x" (list (cons 410 (getvar "ctab"))(cons -3 (list (list reg))))))
    (princ (strcat "\nSelected " (itoa (sslength ss)) " entities in current layout."))
    (sssetfirst nil ss)
  )
  (princ)
)

John F. Uhden

Message 8 of 8

braudpat
Mentor
Mentor

Hello

 

An other excellent french routine from Gilles (gile) : XDSEARCH

I use it often to Find Entities With (option A) or Without (option S) XDATA ...

 

THE HEALTH, Bye, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes