entdel to remove dictionary item?

entdel to remove dictionary item?

DC-MWA
Collaborator Collaborator
1,800 Views
11 Replies
Message 1 of 12

entdel to remove dictionary item?

DC-MWA
Collaborator
Collaborator

I have a strange item showing up randomly in some of our drawings.

I use

(cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_DATALINK")))

this should show nil or show the datalinks in the drawing.

Randomly "MWA template" shows up. We have no clue how this is created. It's the name of our office template.

I've tried  (dictremove (namedobjdict) "MWA template")  to remove it, no luck.

I've seen posts that mention entdel.

Not sure how to do this?  I've tried:

(setq test (namedobjdict) "MWA template")
(entdel test)

no luck.

 

 

0 Likes
Accepted solutions (1)
1,801 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable

Something like ?

(setq ss (ssget ((0 . "XXXX") (2 . "XXXXX")));;Filter DXF code
      i 0)

(repeat (setq i (sslength ss))
 (entdel (ssname ss (setq i (1- i))))
)
0 Likes
Message 3 of 12

DC-MWA
Collaborator
Collaborator

Not sure how this would work with what I'm trying to achieve?

0 Likes
Message 4 of 12

Anonymous
Not applicable

Use Code DXF to filter what you want to delete then delete (entdel) the entire length of your selection. The code below deletes all circles of cyan color.

(defun c:SE (/ ss i) ;;command name
  (setq ss (ssget "_X" '((0 . "CIRCLE") (62 . 4)));;Filter DXF code
      i 0) ;;id
  (repeat (setq i (sslength ss));; repeat t length
    (entdel (ssname ss (setq i (1- i)))) ;; delete
    )
  (princ)
)

 

0 Likes
Message 5 of 12

ronjonp
Mentor
Mentor

Try this .. you need to go one step deeper to get your "MWA template".

(and (setq e (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_DATALINK"))))
     (setq e (cdr (assoc -1 (dictsearch e "MWA template"))))
     (entdel e)
) 

 

0 Likes
Message 6 of 12

DC-MWA
Collaborator
Collaborator

I tried it, not sure whats going on....

Command: (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_DATALINK")));;check for item
"MWA template"

Command:

(and (setq e (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_DATALINK"))))
(_> (setq e (cdr (assoc -1 (dictsearch e "MWA template"))))
(_> (entdel e)
(_> )

Command: (cdr (assoc 3 (dictsearch (namedobjdict) "ACAD_DATALINK")));;check again
"MWA template (1)"  ;;;now shows name(1) ???

0 Likes
Message 7 of 12

ronjonp
Mentor
Mentor

You must have a mess going on 🙂 .. see what this returns:

(mapcar	'print
	(vl-remove-if '(lambda (x) (/= 3 (car x))) (dictsearch (namedobjdict) "ACAD_DATALINK"))
)

Note that (assoc 3 above will only return the first occurrence within the acad_datalink dictionary .. there could be many entries in there.

 

0 Likes
Message 8 of 12

DC-MWA
Collaborator
Collaborator

Here's what came up:

 

(3 . "MWA template")
(3 . "MWA template (1)")
(3 . "MWA template (2)")
(3 . "MWA template (3)") ((3 . "MWA template") (3 . "MWA template (1)") (3 . "MWA template (2)") (3 . "MWA template (3)"))

0 Likes
Message 9 of 12

ronjonp
Mentor
Mentor
Accepted solution

Yup looks like a mess 😛 .. this should clean it up assuming you don't want all those!

(defun c:foo (/ a b)
  ;; RJP » 2020-01-17
  ;; Delete MWA* datalinks
  (foreach e (setq a (dictsearch (namedobjdict) "ACAD_DATALINK"))
    (if	(and (= 3 (car e)) (wcmatch (strcase (setq b (cdr e))) "MWA*"))
      (progn (entdel (cdadr (member e a))) (print (strcat b " deleted...")))
    )
  )
  (princ)
)
0 Likes
Message 10 of 12

DC-MWA
Collaborator
Collaborator

I was able to incorporate this into my routine. Works perfectly.

Thank you.

 

Any idea what is creating these?  Our cad template (drawings) is named "MWA template", but these do not show up in every project produced using the template drawings. It's very random.

Any ideas?

0 Likes
Message 11 of 12

ronjonp
Mentor
Mentor

@DC-MWA wrote:

I was able to incorporate this into my routine. Works perfectly.

Thank you.

 

Any idea what is creating these?  Our cad template (drawings) is named "MWA template", but these do not show up in every project produced using the template drawings. It's very random.

Any ideas?


Glad to help out. 🍻 I'm not sure what is causing your datalink problems.

0 Likes
Message 12 of 12

DC-MWA
Collaborator
Collaborator

Thank you.

0 Likes