Check if datalink exists in drawing

Check if datalink exists in drawing

DC-MWA
Collaborator Collaborator
1,033 Views
2 Replies
Message 1 of 3

Check if datalink exists in drawing

DC-MWA
Collaborator
Collaborator

Hi all,

I'm trying to check drawing to see if any datalinks exist, if they do I would like to update them.

I've played with tblsearch with no luck.

My reading has led me to dictionaries.

Not sure how to proceed. My knowledge of lisp is limited. 

Has anybody out there possibly done something similar?

-thanks!

0 Likes
Accepted solutions (1)
1,034 Views
2 Replies
Replies (2)
Message 2 of 3

DC-MWA
Collaborator
Collaborator

I figured it out.  Is there a better way to do this?

 

(defun c:dlinktest (/ mainDict dlinkDict)

(setq mainDict (namedobjdict))
(entget mainDict)
(setq dlinkDict (dictsearch (namedobjdict) "ACAD_DATALINK"))

(if (cdr (assoc 3 dlinkDict))
(alert "Datalinks exist in drawing.");testing
(alert "No Datalinks in drawing.");testing
);if(princ)
)

0 Likes
Message 3 of 3

dlanorh
Advisor
Advisor
Accepted solution

@DC-MWA wrote:

I figured it out.  Is there a better way to do this?

 

(defun c:dlinktest (/ mainDict dlinkDict)

(setq mainDict (namedobjdict))
(entget mainDict)
(setq dlinkDict (dictsearch (namedobjdict) "ACAD_DATALINK"))

(if (cdr (assoc 3 dlinkDict))
(alert "Datalinks exist in drawing.");testing
(alert "No Datalinks in drawing.");testing
);if(princ)
)


You're not using "maindict" therefore it is redundant, so this should work

 

(defun c:dlinktest (/)
  (if (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_DATALINK")))
    (alert "Datalinks exist in drawing.");testing
    (alert "No Datalinks in drawing.");testing
  );if
  (princ)
)

You'll need to test on a drawing that has datalinks. I don't have any so cannot test this part

I am not one of the robots you're looking for

0 Likes