PURGE Regapps Except...

PURGE Regapps Except...

bstrandberg
Enthusiast Enthusiast
407 Views
4 Replies
Message 1 of 5

PURGE Regapps Except...

bstrandberg
Enthusiast
Enthusiast

I have a routine that runs on startup that purges unused registered applications.  It turns out it is removing some Regapps we need to keep.  

 

So, I need to come up with a routine that purges all Regapps except those starting with "AeccuiQTO".  I'm having a bit of trouble coding this.

 

Any suggestions?

 

Thanks for your help!

0 Likes
408 Views
4 Replies
Replies (4)
Message 2 of 5

ronjonp
Advisor
Advisor

Perhaps:

 

(defun c:foo (/ n)
  (vlax-for a (vla-get-registeredapplications (vla-get-activedocument (vlax-get-acad-object)))
    (if	(wcmatch (strcase (setq n (vla-get-name a))) "AECCUIQTO*")
      (princ (strcat "\nSkipping: " n))
      (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list a)))
	(princ (strcat "\nError Deleting: " n))
	(princ (strcat "\nDeleted: " n))
      )
    )
  )
  (princ)
)

 

 

 

 

 

0 Likes
Message 3 of 5

bstrandberg
Enthusiast
Enthusiast

Sorry for the delay, this looks great!  I have not been able to try it out yet but once I do I will let you know.

 

Thanks.

0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor

What @ronjonp provided you is excellent, but think about it...

regapps cannot be purged unless they aren't assigned to any objects, which means there existence has no value.

I'd say to let AutoCAD purge them all and if you need one again, recreating it is a snap.  You can include a function to check and do so in whatever function you have to add xdata.  That's what I do.  Here's an example...

   (defun @regapp_label_it ()
      (setq |appname "CADLANTIC_LABEL_IT")
      (if (null (tblsearch "appid" |appname))
         (if (not (regapp |appname))
            (progn
               (prompt "\nUnable to initialize LABEL_IT application.")
               (exit)
            )
         )
      )
   )
;; Which could be written more genericly...
   (defun @regapp (appname)
     (or
      (tblsearch "appid" appname)
      (regapp appname)
      (progn
        (alert (strcat "Unable to initialize " appname " application."))
        (exit)
      )
    )

 

John F. Uhden

0 Likes
Message 5 of 5

pbejse
Mentor
Mentor
(Defun c:PExAec	(/ a rn)
(setvar 'cmdecho 0)  
  (while
    (setq a (tblnext "appid" (null a)))
     (if (not
	   (wcmatch (strcase (setq rn (Cdr (assoc 2 a)))) "AECCUIQTO*")
	 )
       (command-s "-purge" "regapp" rn "N")
     )
  )
)

HTH

 

0 Likes