Drawing contains annotative objects?

Drawing contains annotative objects?

Anonymous
Not applicable
1,125 Views
4 Replies
Message 1 of 5

Drawing contains annotative objects?

Anonymous
Not applicable

Anyone have a LISP application that will check to see if a drawing has any 'annotative' objects?

 

Accepted solutions (1)
1,126 Views
4 Replies
Replies (4)
Message 2 of 5

SeeMSixty7
Advisor
Advisor

you can try something like

 

(if (ssget "X" (list (list -3 (list "AcadAnnotative")))) T nil)

 

T - Has Annotative Elements

nil does not.

 

This won't look at blocks that are annotative or blocks that contain annotative text, though. I will have to dig into that a little more for those.

Message 3 of 5

dbroad
Mentor
Mentor

One technique that would allow variations in depth of search.

;;D. C. Broad, Jr. 5/25/2017
;;Returns T if the drawing has annotative objects
;;Tested with hatch, text, inserts, and dimensions
;;Will not flag annotative text style, dimstyle, or block definitions
;;unless those styles or definitions are referenced or if block definitions contain
;;nested annotative objects. ;;USE: (hasannotativeobjects nil) to look only at entities in model space and layouts. ;; (hasannotativeobjects t) to include objects nested in user block definitions. (defun hasannotativeobjects (nested / i ed return) (VL-CATCH-ALL-APPLY ;;will break loop at the first annotative object ;;warning: all errors will remain hidden within the catch all function. '(lambda (x) (vlax-for n x (if (or nested (= :vlax-true (vla-get-islayout n))) (vlax-for m n (and (= :vlax-true (vla-get-hasextensiondictionary m)) (setq i 0 ed (vla-GetExtensionDictionary m) ) (repeat (vla-get-count ed) (if (= (vla-get-name (vla-item ed 0)) "AcDbContextDataManager" ) (progn (setq return t) (exit) ;;stop loop ) ) (setq i (1+ i)) ) ) ) ) ) ) (list ;;block collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object) ) ) ) ) return ;;predicate value )
Architect, Registered NC, VA, SC, & GA.
Message 4 of 5

cadffm
Consultant
Consultant
Accepted solution

@ SeeMSixty7
You are only checking if there AcadAnnotative -Xdata on the Objects have the AcadAnnotative Xdata information, but these Data will not be deleted when you change the Annotative propertie to false.

(Set Annotative Property of Objetk from True to False, then check the Xdata)

same

@Anonymous
You do not check whether the objects refer to the AnnotativeInformation,
With your code you also get a statement about annotative objects AND objects which once annotative=true (current are =false).

(Set Annotative Property of Object from True to False, then check the programm output)


Note: XDATA:
The Annotative = false property is when no XDatas append *, or if present: The 2nd dottedpair is 1070 = 0.

The Annotative = trtue property is when XDatas append and the 2nd dottedpair 1070 = 1

* XDATA: Poor programming may have deleted the Xdata, but the Dictionary information still exists in the file.
This can create very "funny" effects when further processing the objects or when making copies.

 


dbroad-Code with a small edit:

 

;;D. C. Broad, Jr. 5/25/2017                                
;;Returns T if the drawing has annotative objects                    
;;Tested with hatch, text, inserts, and dimensions                    
;;Will not flag annotative text style, dimstyle, or block definitions            
;;unless those styles or definitions are referenced or if block definitions contain    
;;nested annotative objects.                                 
;;USE:  (hasannotativeobjects nil) to look only at entities in model space and layouts.    
;;      (hasannotativeobjects t) to include objects nested in user block definitions.    
;;                                            
;; edit cadffm 5/26/2017                                
;;                                            

(defun hasannotativeobjects (nested / i ed return)
  (VL-CATCH-ALL-APPLY ;;will break loop at the first annotative object
    ;;warning: all errors will remain hidden within the catch all function.
    '(lambda (x)
       (vlax-for n x
     (if (or nested (= :vlax-true (vla-get-islayout n)))
       (vlax-for m n
         (and
           (= :vlax-true (vla-get-hasextensiondictionary m))
           (setq i    0
             ed    (vla-GetExtensionDictionary m)
           )
;;;           (repeat (vla-get-count ed)
;;;         (if (=    (vla-get-name (vla-item ed 0))
;;;            "AcDbContextDataManager"
;;;             )
;;;           (progn
;;;             (setq return t)
;;;             (exit) ;;stop loop
;;;           )
;;;         )
;;;         (setq i (1+ i))
;;;           )
               (progn ; edit cadffm 5/26/2017
                (setq ed (vl-catch-all-apply 'vla-Item (list ed "AcDbContextDataManager")))
                (not (vl-catch-all-error-p ed))
                (setq ed (vl-catch-all-apply 'vla-Item (list ed "ACDB_ANNOTATIONSCALES")))
                (not (vl-catch-all-error-p ed))
            (vlax-for od ed
               (if (wcmatch (vla-get-ObjectName od) "*ContextData")
                           (progn(setq return t)(exit))
               )
            )
               );_progn
         )
       )
     )
       )
     )
    (list ;;block collection
      (vla-get-blocks
    (vla-get-activedocument
      (vlax-get-acad-object)
    )
      )
    )
  )
  return  ;;predicate value
)

 

 

Sebastian

Message 5 of 5

dbroad
Mentor
Mentor

Good catch on the persistent dictionary.  I think your code fix was a bit mangled however, using PROGN instead of AND.  Here is a corrected version.

;;D. C. Broad, Jr. 5/26/2017 with suggestions by CADFFM
;;Returns T if the drawing has annotative objects
;;Tested with hatch, text, inserts, and dimensions
;;Will not flag annotative text style, dimstyle, or block definitions
;;unless those styles or definitions are referenced or unless block
;;definitions contain nested annotative objects. 
;;USE:  (hasannotativeobjects nil) to look only at entities in model space and layouts.
;;      (hasannotativeobjects t) to include objects nested in user block definitions.

(defun hasannotativeobjects (nested / i ed return)
  (VL-CATCH-ALL-APPLY
    ;;will break loop at the first annotative object
    ;;warning: all errors will remain hidden within the catch all function.
    '
     (lambda (x)
       (vlax-for n x
	 (if (or nested (= :vlax-true (vla-get-islayout n)))
	   (vlax-for m n
	     (and
	       (= :vlax-true (vla-get-hasextensiondictionary m))
	       (setq i	0
		     ed	(vla-GetExtensionDictionary m)
	       )
	       (setq ed	(vl-catch-all-apply
			  'vla-Item
			  (list ed "AcDbContextDataManager")
			)
	       )
	       (not (vl-catch-all-error-p ed))
	       (setq ed	(vl-catch-all-apply
			  'vla-Item
			  (list ed "ACDB_ANNOTATIONSCALES")
			)
	       )
	       (not (vl-catch-all-error-p ed))
	       (vlax-for od ed
		 (if (wcmatch (vla-get-ObjectName od) "*ContextData")
		   (progn (setq return t) (exit))
		 )
	       )

	     )
	   )
	 )
       )
     )
    (list ;;block collection
	  (vla-get-blocks
	    (vla-get-activedocument
	      (vlax-get-acad-object)
	    )
	  )
    )
  )
  return
  ;;predicate value
)

 

Architect, Registered NC, VA, SC, & GA.
0 Likes