Hi all, I have thrown together something to return the number of regapps in xref files (and the active file).
My problem is that if an xref is unloaded, it will become an automation error. I would really like to get the number of regapps even in unloaded xrefs.....but if that's not feasible, can anyone help me to only process loaded xrefs?
Any help is appreciated - I am still trying to learn quite a lot of lisp methods and habits. Thanks.
;; 2012-10-01 RJH. Goal is to retrieve the number of regapps ;; in the xref files. Purging regapps is useless if they come from the xrefs ;; Thanks to Balaji Ramamoorthy's post for helpful methods. ;; on ADN: http://adndevblog.typepad.com/autocad/2012/06/ ;; entity-name-of-an-xref-subentity-from-its-handle.h
tml (defun C:TestReg ( / activedoc activeblocks each xrefdb xrefregapps ) ;; Error handling (defun *error* (msg) (princ (strcat "\n " msg)) (princ) ) (vl-load-com) ;get active document (setq activedoc (vla-get-activedocument (vlax-get-acad-object))) ;get blocks in active document (setq activeblocks (vla-get-blocks activedoc)) ;for each block, (vlax-for each activeblocks ;if the block is an xref (if (= (vlax-get-property each 'IsXref) :vlax-true) (progn ;get xref database (setq xrefdb (vla-get-xrefdatabase each)) ;get the count of regapps in the xref (setq xrefRegapps (vlax-get-property (vla-get-RegisteredApplications xrefdb) 'Count)) ;output findings to command line. (princ (strcat "\n " (rtos xrefRegapps 2 0) " Regapps in " (vla-get-path each))) ) ) ;release the block (vlax-release-object each) ) ;release the active document. (vlax-release-object activedoc) (princ) );end defun
Solved! Go to Solution.
(and (= (vlax-get-property each 'IsXref) :vlax-true) (not (assoc 71 (entget (tblobjname "block" (vla-get-Name each))) ) ) )
cool, Thanks pbejse!
I was trying (entget (vlax-vla-object->ename each))...but I see that has a different return from the (entget (tblobjname...).
Can I ask where/how you found the 71 group code? I was looking in the Block section of the dxf reference (I think my dxf help file skills are lacking a bit).
In any case thanks again for the help!
this is what I ended up with for anyone interested. Type REGCOUNT to run the command and view the command line output.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.