Jump to content

Need help removing Dictionary from file


Archiman86

Recommended Posts

I am trying to remove a specific dictionary from a bunch of files. The client we work with has issues in their document management system when this exists in the files. I am trying to get this to work so that it prints whether it did not already exist, or if it was deleted. Right now I keep getting an error that says:

error: bad function:

 

Here is what I have so far:

(defun c:GCI()

(setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict"))

(If

(= nil newdictlist) (princ "\nGcImageDef_Dict does not exist.")

((dictremove (namedobjdict) "GcImageDef_Dict") (princ"\nThe GcImageDef_Dict has been removed."))

)

(princ)

)

 

Thanks in advance for any help!

Link to comment
Share on other sites

I can't test it, but maybe something like this?

 

(defun c:GCI  (/ newdictlist)  
 (cond (  (setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict"))

          (dictremove (namedobjdict) "GcImageDef_Dict")
          (princ "\nThe GcImageDef_Dict has been removed."))

       (  (princ "\nGcImageDef_Dict does not exist.")))

 (princ))

Link to comment
Share on other sites

Lee, Thanks! Thats works. By chance, can you explain why it would return that error for me. In theory, to my knowledge that should work. I mean, my version DID work, it jsut put that error after printing "...has been removed." Thanks again!

 

-Dan

Link to comment
Share on other sites

It was this line:

 

((dictremove (namedobjdict) "GcImageDef_Dict") (princ"\nThe GcImageDef_Dict has been removed."))

Which would be interpreted as:

 

(<entity_name>   "\nThe GcImageDef_Dict has been removed.")

I.e. as if the was a function, (which it isn't, of course).

 

To wrap two expressions in the THEN statement of the IF function, you need to use a wrapper like PROGN:

 

(defun c:GCI (/ newdictlist)

  (setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict"))
  (If (= nil newdictlist)
   (princ "\nGcImageDef_Dict does not exist.")
   (progn
     (dictremove (namedobjdict) "GcImageDef_Dict") 
     (princ"\nThe  GcImageDef_Dict has been removed.")
   ) ; progn
 ) ; IF

(princ))

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...